IBM ILOG Scheduler User's Manual > Getting Started with Scheduler > Using Reservoirs > Solve the Problem

To generate an optimal solution, and minimize makespan, we add the goal IloSetTimesForward to the model, set makespan as the objective variable with a call to IloMinimize, and search for a solution.

To select the activities, the predefined activity selector IloSelFirstActMinEndMax is used. This selector considers the earliest start and end times among the activities that can still be selected, and from the selectable activities having the minimal earliest start time, it chooses one having the maximal earliest end time

  /* SET THE OBJECTIVE */
  model.add(IloMinimize(env, makespan));
  /* ... */
    IloSolver solver(model);
 
    IloGoal goal = IloSetTimesForward(env, makespan);
    if (solver.solve(goal)) {
      PrintSolution(solver,makespan);
#if defined(ILO_SDXLOUTPUT)
      IloSDXLOutput output(env);
      ofstream outFile("gsReserv.xml");
      output.write(IlcScheduler(solver), outFile, solver.getIntVar(makespan));
      outFile.close();
#endif
    }
    else
      solver.out() << "No Solution" << endl;