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

In a solution to the problem, each possible assignment of an activity to a worker may be enforced or not. We use the function requires to express the fact that an activity requires one of the alternative workers. The member function setRejected expresses the idea that a certain resource cannot execute a certain activity. The call to the member function select expresses the fact that if some worker is selected for an activity, the activity has to occur during the "attendance on site" activity. In fact, this expresses the same idea as the time extent IloBeforeStartAndAfterEnd, and either of the two methods would suffice. We use the function select to demonstrate its use.

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 ACTIVITIES AND THE ASSIGNMENT VARIABLES. IT IS ASSUMED
     THAT THERE IS AT LEAST ONE POSSIBLE ASSIGNMENT PER ACTIVITY. */
  IloInt k = 0;
  IloActivityArray tasks(env,numberOfActivities);
  for (i = 0; i < numberOfActivities; i++) {
    IloActivity activity(env, processingTimes[i]);
    activity.setName(activityNames[i]);
    tasks[i] = activity;
    // RESOURCE ALLOCATION DEMAND
    IloResourceConstraint alternative = activity.requires(workersSet, 1);
    // REMOVE UNAVAILABLE WORKERS
    for (IloInt j = 0; j < numberOfWorkers; j++) {
      if (!possibleAssignments[k]) {
        alternative.setRejected(workers[j]);
      } else {
        model.add(IloIfThen(env,
                            alternative.select(workers[j]),
                            (((Worker*)
                              workers[j].getObject())->coverAttendance(activity))));
      }
      k++;
    }
    model.add(alternative);
  }
 
  /* ... */ 
}