IBM ILOG Scheduler User's Manual > Advanced Concepts > More Advanced Problem Modeling with Concert Technology > Solving the Problem

Once we have represented the issues of the problem in those ways, the following code is sufficient to generate a solution that minimizes the given criterion.

    IloNumVar criterion = ((minimizeMax) ? maxCriterion : sumCriterion);  
    model.add(IloMinimize(env, criterion));
    
    IloSolver solver(model);
    IloGoal goal = IloAssignAlternative(env) &&
      IloSetTimesForward(env,
                         criterion,
                         IloSelFirstActMinEndMin);
    
    if (solver.solve(goal)) {
      IlcInt maxCrit = solver.getIntVar(maxCriterion).getMin();
      IlcInt sumCrit = solver.getIntVar(sumCriterion).getMin();
      PrintSolution(solver, maxCrit, sumCrit);
#if defined(ILO_SDXLOUTPUT)
      IloSDXLOutput output(env);
      ofstream outFile("cassign.xml");
      output.write(IlcScheduler(solver), outFile);
      outFile.close();
#endif
    } else
      solver.out() << "No solution!" << endl;
    solver.printInformation();
    env.end();
  } catch (IloException& exc) {
    cout << exc << endl;
  }
  
  return 0;
 

The goal returned by the function IloAssignAlternative assigns a resource to all activities. The goal returned by IloSetTimesForward assigns a start time to all activities, starting with the activity that has the minimal earliest start time among those activities with the minimal earliest end times.