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;
}
|