Maintenance operations require the discrete resource representing the workers. The durations, required capacities, and precedence constraints are defined from the transition cost variable on the machines.
Two kinds of activities are created. One for the maintenance operation after an activity on a machine; the other for the setup operation on a machine.
IloActivity
MakeMaintenanceTask(IloModel model,
IloResourceConstraint rct,
IloDiscreteResource workers,
IloTransitionCost durTCost,
IloTransitionCost capTCost,
const char* name) {
IloEnv env = model.getEnv();
IloNumVar ptVar(env, 0, IloInfinity, ILOINT);
IloActivity act(env, ptVar);
model.add(ptVar == durTCost.getNextCostExpr(rct));
act.setName(name);
model.add(act.startsAfterEnd(rct.getActivity()));
IloNumVar capVar(env, 0, IloInfinity, ILOINT);
model.add(act.requires(workers, capVar));
model.add(capVar == capTCost.getNextCostExpr(rct));
// Mark maintenance activity
act.setObject((IloAny)1);
return act;
}
IloActivity
MakeSetupTask(IloModel model,
IloDiscreteResource workers,
IloTransitionCost durTCost,
IloTransitionCost capTCost,
const char* name) {
IloEnv env = model.getEnv();
IloNumVar ptVar(env, 0, IloInfinity, ILOINT);
IloActivity act(env, ptVar);
model.add(ptVar == durTCost.getSetupCostExpr());
act.setName(name);
// Mark maintenance activity
act.setObject((IloAny)1);
IloNumVar capVar(env, 0, IloInfinity, ILOINT);
model.add(act.requires(workers, capVar));
model.add(capVar == capTCost.getSetupCostExpr());
return act;
}