IBM ILOG Scheduler User's Manual > Integrated Applications > Incremental Scheduling: Using Scheduler with Multiple Problem Sub-models > Designing the Models > Creating the Default Solution

Given the existing solution and the new job that is to be incorporated into it, we can calculate an upper-bound on the makespan of the new model by adding the makespan from the existing solution to the sum of the durations of the activities in the new job. This is true since we can find a new solution simply by copying the existing solution and placing the activities of the new job as the final activities on each resource. This will extend the makespan by, at most, the sum of the durations of the activities of the new job.

As a first step in incorporating the new job, we create an IloSchedulerSolution object that represents this solution. This is the "default" solution. We hope that we can find a better solution through search, however, it is possible that this search will fail due to lack of time or other computational resources. In such a case, we need a solution to fall back on.

IloSchedulerSolution CreateDefaultSolution(
					   IloSchedulerSolution originalSolution,
					   IloResourceConstraint* newJob,
					   IloNumVar makespan,
					   IloInt numberOfResources) {
  // The simplest way to add the new job is simply to place it at the
  // end of the existing schedule.
  IloEnv env = originalSolution.getEnv();

  IloNum newActStartMin = 0;
  IloSchedulerSolution defaultSolution = originalSolution.makeClone(env);
  for(IloInt i = 0; i < numberOfResources; ++i) {
    IloResource resource = newJob[i].getResource();

    // FIND THE ACTIVITY ON THE RESOURCE WITH THE MAX endMin 
    for(IloIterator<IloResourceConstraint> iter(env);
        iter.ok(); ++iter) {
      IloResourceConstraint rct = *iter;
      if ((rct.getImpl() != newJob[i].getImpl()) &&
	  (rct.getResource().getImpl() == resource.getImpl()) &&
	  (defaultSolution.getEndMin(rct.getActivity()) > newActStartMin)) 
	newActStartMin = defaultSolution.getEndMin(rct.getActivity());
    }

    IloActivity newAct = newJob[i].getActivity();
    defaultSolution.add(newAct);
    defaultSolution.setStartMin(newAct, newActStartMin);
    newActStartMin += newAct.getProcessingTimeVariable().getLB();
  }

  IloNum mkspValue = defaultSolution.getSolution().getMin(makespan);
  if (mkspValue < newActStartMin) {
    defaultSolution.getSolution().setMin(makespan, newActStartMin);
    defaultSolution.getSolution().setMax(makespan, newActStartMin);
  }

  return defaultSolution;
}