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 |
Define the Problem, Design a Model |
INDEX
![]() |
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.
The following code creates the worker as an object of the IloUnaryResource
class.
/* CREATE THE RESOURCE. */ IloUnaryResource worker(env); |
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.
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)); |
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |