IBM ILOG Scheduler User's Manual > Advanced Concepts > Using Strong Propagation on Reservoirs: the Balance Constraint > Solving the Problem

Once the model has been created, we solve it using the predefined goal IloRankForward until an optimal schedule is found. Each solution found in the optimization process is displayed. For each solution, the slack time corresponding to the cumulative waiting time between activities is also displayed. Note that minimizing the makespan is the same as minimizing this slack time as the slack is equal to the makespan minus the total duration of activities.

    IloNumVar makespan;
    IloModel model = DefineModel(env,
                                 numberOfActivities,
                                 numberOfConstraints,
                                 durations,
                                 constraints,
                                 makespan);
    
    model.add(IloMinimize(env, makespan));
    IloSolver solver(model);
    IlcSearch search = solver.newSearch(IloRankForward(env, makespan));
    
    IloInt sumd = 0;
    for (IloInt i=0; i < numberOfActivities; i++)
      sumd += durations[i];
    
    while (search.next()) {
      solver.out() << "SOLUTION WITH SLACK = " 
                   << solver.getIntVar(makespan).getMin() - sumd << endl;    
      PrintSolution(solver);
    }
 
void
PrintSolution(const IloSolver& solver)
{
  IlcScheduler sched(solver);
  IlcUnaryResource res = *(IlcUnaryResourceIterator(sched));
  for(IlcResourceConstraintIterator ite(res); ite.ok(); ++ite)
    solver.out() << (*ite).getActivity() << endl;
}
 

The complete program allows the solving of different predefined problems. The argument given to the executable corresponds to the instance of the problem to solve.