IBM ILOG Scheduler User's Manual > Getting Started with Scheduler > Using the Building Blocks > Adding Resources and Resource Constraints > Define the Problem, Design a Model

In the context of this example, it is clear that the worker is a unary resource who can perform only one activity at a time and thus has a capacity of 1. Each activity requires the worker.

Create the Resource

The following code creates the worker as an object of the IloUnaryResource class.

  /* CREATE THE RESOURCE. */
  IloUnaryResource worker(env);

Add the Resource Constraints

To add resource constraints, we use the member function IloActivity::requires which states that the invoking activity requires the capacity of the given resource (worker) from the beginning to the end of the activity's processing time.

The general form for specifying that an activity A requires a resource R is model.add(A.requires(R, capacity)); where model is an instance of the class IloModel, and capacity is either a constant or a constrained variable specifying the amount that the activity requires from the resource. Because the worker resource is a unary resource with a capacity of 1 and because the default capacity of the method requires is also 1, the capacity required by the activity does not have to be stated.

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

Define the Objective

Our objective is still to determine the least possible makespan for the project. The Concert Technology function IloMinimize is used to set the objective of minimizing the makespan in the model.

  /* SET THE MAKESPAN VARIABLE. */
  makespan = IloNumVar(env, 0, IloInfinity, ILOINT);
  model.add(moving.endsAt(makespan));

  /* SET THE OBJECTIVE */
  model.add(IloMinimize(env, makespan));