IBM ILOG Scheduler User's Manual > Integrated Applications > Representing Time-Varying Resource Capacity > Defining the Problem, Designing a Model

To create the corresponding resource and, especially, the resource timetable, we have to determine the maximal theoretic capacity. The following code performs this computation and keeps the result in a C++ variable, capacity.

With the member function setCapacityMax, we specify the number of people actually available each day. As its arguments, this function receives two points in time, timeMin and timeMax, (defining an interval [timeMin timeMax)) and an integer specifying the maximal capacity available over this interval. Here, for each day, timeMin is equal to day, timeMax is equal to day+1, and the available capacity is equal to availableCapacities[day].

  /* CREATE THE RESOURCE. */
  IloNum capacity = 0;
  IloInt day;
  for (day = 0; day < numberOfDays; day++)
    if (capacity < availableCapacities[day])
      capacity = availableCapacities[day];
  resource = IloDiscreteResource(env, capacity);
  /* POST THE MAXIMAL CAPACITY CONSTRAINTS. */
  for (day = 0; day < NumberOfDays; day++)
    resource.setCapacityMax(day, day + 1, availableCapacities[day]);

The following code creates the activities and specifies the number of people required for each activity.

  /* CREATE THE ACTIVITIES AND POST THE RESOURCE REQUIREMENT
     CONSTRAINTS. */
  char buffer[128];
  IloInt i;
  for (i = 0; i < numberOfActivities; i++) {
    IloActivity activity(env, durations[i]);
    sprintf(buffer, "A%ld", i);
    activity.setName(buffer);
    model.add(activity.requires(resource, requiredCapacities[i]));
  }