IBM ILOG Scheduler User's Manual > Getting Started with Scheduler > Using Discrete Resources > Working with Discrete Resources > Define the Problem, Design a Model

Because the workers in this problem are considered to be identical, we can represent them as a discrete resource with a capacity of 2. Each activity requires one of the workers.

Create the Resource

The following code creates the workers as an instance of IloDiscreteResource with a capacity of 2.

  /* CREATE THE RESOURCE. */
  IloDiscreteResource workers(env, 2); 

Add the Resource Constraints

The resource constraints are once again declared using the method IloActivity::requires, which states that the invoking activity requires the capacity of the given resource (workers) from the beginning to the end of its execution. Because the default capacity of the method requires is 1, the capacity required by the activity does not have to be stated.

  /* ADD THE RESOURCE CONSTRAINTS. */
  model.add(masonry.requires(workers));
  model.add(carpentry.requires(workers));
  model.add(plumbing.requires(workers));
  model.add(ceiling.requires(workers));
  model.add(roofing.requires(workers));
  model.add(painting.requires(workers));
  model.add(windows.requires(workers));
  model.add(facade.requires(workers));
  model.add(garden.requires(workers));
  model.add(moving.requires(workers));

Define the Objective

Our objective is still to minimize the makespan for the project. IloMinimize is used just as for the previous example.