To solve the problem, the model is extracted by an algorithm (IloSolver
). That instance of IloSolver
extracts the appropriate objects from the model and creates the corresponding objects needed by the algorithm to do the search.
The Solver function IloInstantiate
creates the goal
to instantiate the makespan
. The solution search is then started using that goal
. Constraint propagation is sufficient in this example to determine the earliest and latest start and end times of the activities.
// Model
IloEnv env;
IloNumVar makespan;
IloModel model = DefineModel(env, makespan);
// Algorithm
IloSolver solver(model);
IloGoal goal = IloInstantiate(env, makespan);
|
Print the Solution
We use an instance of IlcScheduler
to define a function to print the results. IlcScheduler
is the repository of all the information used during the solve process. It allows retrieval of the search object (Ilc
) that has been extracted from a scheduler extractable (Ilo
). We use it here to retrieve the activities for printing, with an iterator (an instance of the class IloIterator
) stepping through the activities.
void PrintSolution(const IloSolver solver)
{
IlcScheduler scheduler(solver);
IloEnv env = solver.getEnv();
for(IloIterator<IloActivity> act(env);
act.ok();
++act)
env.out() << scheduler.getActivity(*act) << endl;
solver.printInformation();
}
|