IBM ILOG Scheduler User's Manual > Getting Started with Scheduler > Using the Building Blocks > Satisfying Temporal Constraints > Create the Model |
Create the Model |
INDEX
![]() |
In Scheduler, activities and resources are created in an environment, an instance of the Concert Technology class IloEnv
. Within that environment, a model of the scheduling problem is created, and this model will contain all the constraints necessary to define the problem. The following code creates the initial model
in the environment env.
IloModel DefineModel(const IloEnv env, IloNumVar& makespan)
{
IloModel model(env);
Activities are defined by the class IloActivity
. The following constructor creates a new instance of IloActivity
and adds it to the set of activities managed in the environment env
. The activity has a processing time of processingTime
, and the activity name is set to name
. Other constructors of activities are available and will be discussed later.
IloActivity(IloEnv& env, IloNum processingTime, const char* name = 0); |
The following code creates the activities for our first example: masonry
, carpentry
, plumbing
, ceiling
, roofing
, painting
, windows
, facade
, garden
, and moving
, in the context of the environment env
.
In this example, the only temporal constraints required are precedence constraints. Certain activities can only start after other activities have been completed. To add these constraints, we use the predefined member function startsAfterEnd
of the class IloActivity
.
In the code above, model
is the instance of IloModel
that contains the functions used to declare the model. The method add
specifies that the given parameters, expressions, or constraints must be verified by a solution.
The makespan is the time that elapses between the beginning of the first activity (masonry
) and the end of the last activity (moving
). The objective of most of these examples is to minimize the makespan. The following code sets makespan
equal to the end time of the moving
activity.
/* SET THE MAKESPAN VARIABLE. */ makespan = IloNumVar(env, 0, IloInfinity, ILOINT); model.add(moving.endsAt(makespan)); return model; } |
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |