IBM ILOG Scheduler User's Manual > Integrated Applications > Scheduling with State Resources: the Trolley Problem, with Transition Times > Describing the Problem

The time taken by the trolley to move from one area to another is shown in Figure 33.1.

schedulingStateRes2ca.gif

Figure 33.1 Machines, Areas, and Durations for the Trolley Problem with Transition Times

We define an array, TransitDurations, to represent the trolley transition times.

                              // M1   M2   M3   A     S
IloNum TransitDurations[] = {    0,  50,  60,  50,   90,    // M1
                                50,   0,  60,  90,   50,    // M2
                                60,  60,  0,   80,   80,    // M3  
                                50,  90,  80,   0,  120,    // A
                                90,  50,  80, 120,    0   };// S

A function, getMaxTransitDuration, is defined on this array. It returns the longest transit duration between two areas of the shop.


IloNum getMaxTransitDuration(IloInt nbArea, IloNum* transitDurations){
  IloNum max = 0;
  IloInt size = nbArea*nbArea;
  for (IloInt i = 0; i < size; i++)
    if (transitDurations[i] > max) max = transitDurations[i];
  return max;
}


Now, the transit duration array is added to the function DefineModel as an extra argument.

    IloEnv env;
    IloAnyArray jobs;
    IloStateResource trolley;
    IloArray<IloUnaryResource> machines;
    IloNumVar makespan;
    IloModel model = DefineModel(env,
        JobNames,
        TransitDurations,
        Machines1, Durations1,
        Machines2, Durations2,
        jobs,
        trolley,
        machines,
        makespan);


In the next section we show how the DefineModel function is modified to take transition times into account.