IBM ILOG Scheduler User's Manual > Advanced Concepts > More Advanced Problem Modeling with Concert Technology > Defining the Problem, Designing a Model > Optimization Criteria

The two optimization criteria are easy to define from the processing times of the "attendance activities." The maxCriterion is a variable constrained to be greater than or equal to all of these processing times. The sumCriterion is a variable defined as the sum of these variables.

Two parameters, sumCriterion and maxCriterion, can be passed by reference to the function DefineProblem and set when the instances of the Worker class are created. In our model, the workers are represented by an instance of the class IloAltResSet, defining the fact that the workers can be viewed as alternatives to each other. If an activity requires an instance of the class IloAltResSet, this means that it requires exactly one of the alternatives in that instance.

IloModel
DefineProblem(IloEnv env,
              IloInt numberOfActivities,
              IloInt numberOfWorkers,
              const char** activityNames,
              const char** workerNames,
              IloNum* processingTimes,
              const char** possibleAssignments,
              IloAltResSet& workersSet,
              IloNumVar& maxCriterion,
              IloNumVar& sumCriterion)
{
 
  /* CREATE THE MODEL. */
  IloNum origin = 0;
  IloNum horizon = 18;
 
  IloModel model(env);
  IloSchedulerEnv schedEnv(env);
  schedEnv.setOrigin(origin);
  schedEnv.setHorizon(horizon);
 
  /* CREATE THE WORKERS AND SET THE OPTIMIZATION CRITERIA. */
  IloUnaryResourceArray workers(env, numberOfWorkers);
  IloNumVarArray attendancies(env, numberOfWorkers);
  IloInt i;
  for (i = 0; i < numberOfWorkers; i++) {
    Worker* worker =
      new (env) Worker(model, horizon, workerNames[i]);
    attendancies[i] = worker->getAttendanceProcessingTime();
    workers[i]      = worker->getResource();
    workersSet.add(workers[i]);
  }
 
  sumCriterion = IloNumVar(env, 0, numberOfWorkers * horizon, IloNumVar::Int);
  maxCriterion = IloNumVar(env, 0, horizon, IloNumVar::Int);
  model.add(sumCriterion == IloSum(attendancies));
  model.add(maxCriterion == IloMax(attendancies));
 
  /* ... */ 
}