IBM ILOG Scheduler User's Manual > Local Search in Scheduler > Tabu Search for the Jobshop Problem with Alternatives > Solving the Problem > Calculating the Critical Path

The critical path calculation is the same as that performed in the previous chapter. However, both the N1NHood and the new neighborhood (see Creating the Relocate Neighborhood) require the critical path to be calculated in order to generate moves. With our previous implementation, we would unnecessarily calculate the critical path twice, once for each neighborhood. To avoid this we add a _needsRecomputing flag to the CriticalPath object. This flag can be set using a public method:

  void needsRecomputing() { _needsRecomputing = IloTrue; }

The CriticalPath::computeCP method is modified to check this flag and only recompute if it is IloTrue.

IloArray<IloResourceConstraint>& CriticalPath::computeCP(
                                       IloSchedulerSolution solution,
                                       IloInt& cpSize) {
  if (_needsRecomputing) {
    IloInt nbCriticalRCs = 0;
    RCSortElement *sortArray = getCriticalRCs(solution, nbCriticalRCs);
    
    // pick one (randomly selected) critical path
    pickRandomCP(sortArray, solution, nbCriticalRCs);
    delete [] sortArray;
    _needsRecomputing = IloFalse;
  }

  cpSize = _cpSize;
  return _cpArray;
}

The CriticalPath implementation is otherwise identical to that used in the previous two chapters.