IBM ILOG Scheduler User's Manual > Advanced Concepts > Working with Transition Times: the Job Shop Problem > Defining Transition Types and Times

In this variant of the job-shop problem, each activity of each job has a given type, and each machine needs a transition time when it executes an activity that has a different type from the previously executed activity.

Arbitrarily, we decide the first activity of a given job has the type 0, the second one the type 1, and so on. To specify a type on an activity, the member function IloActivity::setTransitionType is used as follows.

    /* CREATE THE ACTIVITIES. */
  char buffer[128];
  k = 0;
  for (i = 0; i < numberOfJobs; i++) {
    IloActivity previousActivity;
    for (j = 0; j < numberOfResources; j++) {
      IloActivity activity(env, durations[k]);
      sprintf(buffer, "J%ldS%ldR%ld", i, j, resourceNumbers[k]);
      activity.setName(buffer);
      activity.setTransitionType(j);
 
      IloResourceConstraint rct = 
        activity.requires(resources[resourceNumbers[k]]);
      NbUnrankedExt* nbOfUnranked = 
        new (env) NbUnrankedExt();
      rct.setObject(nbOfUnranked);
      model.add(rct);
 
      if (j != 0)
        model.add(activity.startsAfterEnd(previousActivity));
      previousActivity = activity;
      k++;
    }
    model.add(previousActivity.endsBefore(makespan));
  }
 

The transition times between each type are stored in an array. For instance, for MT06, the array TransTime06 is declared like this:

IloInt TransTimes06 [] = { 0,  2,  7,  3,  1,  3,
                           3,  0,  4,  7,  8,  8,
                           4,  2,  0,  5,  3,  6,
                           3,  6,  4,  0,  4,  7,
                           2,  1,  5,  5,  0,  1,
                           6,  4,  6,  9,  4,  0};

The elements of the array are used to initialize the instance of IloTransitionParam.

  /* CREATE THE TRANSITION TIMES */
  IloTransitionParam ttParam(env, numberOfResources, IloFalse);
  IloInt i, j;
  for (i = 0; i < numberOfResources; i++) 
    for (j = 0; j < numberOfResources; j++)
      ttParam.setValue(i, j, transTimes[j + (numberOfResources * i)]); 

Now we have to specify the transition times related to a given machine at its creation. An instance of an IloTransitionTime is created and it associates the resource with ttParam, an instance of IloTranstionParam. The transition times on the resource will be computed using ttParam and the transition types of the activities

  IloUnaryResource *resources = 
    new (env) IloUnaryResource[numberOfResources];
  for (j = 0; j < numberOfResources; j++) {
    IloUnaryResource res = IloUnaryResource(env);
    IloTransitionTime( res, ttParam );
    resources[j] = res;
  }

The capacity enforcement and the precedence enforcement levels are set to IloMediumHigh so that more effort will be expended in enforcing the capacity constraints and transition times. This is not strictly necessary as transition times and capacity constraints will be taken into account at the default enforcement level, IloBasic. The problem is then solved using the dichotomizing search strategy discussed in Chapter 16; see that chapter for information on how that search algorithm can reduce the number of optimizing iterations and make the remaining iterations easier to compute.