I am modeling a scheduling problem with capacity constraints. The task is to schedule a set of operations that have to be carried out by a specific machinez. More especifically, I have a set of vehicles and a set of locations, and the vehicles have to visit the locations to carry out some operations. Each location can handle at most one vehicle, and each vehicle has a maximum capacity. There are two types of operations: pick-up and delivery operations. Pick-up operations correspond to positive demand, whereas delivery operations correspond to negative demand. The task is to schedule all operations while respecting the capacity constraint of the vehicles.
I would like to use the CP optimizer from CPLEX, and I am using Java Eclipse to model it.
I have tried to model this with cumul function expressions, as I can use the StepAtStart function to indicate the increase of capacity at the beginning of the operation. However, the function does not model negative values.
I have tried this code, inspired from the SchedRCPSP example. But I cannot input negative values nor substract the expression for the negative demand.
IloIntervalVar[] opList = new IloIntervalVar[nbOp];
[...]
[...]
IloCumulFunctionExpr[] resources = new IloCumulFunctionExpr[nbVeh];
for(int v = 1; v < nbVeh -1 ; v++) {
resources[v] = cp.cumulFunctionExpr();
}
for(int i = 0; i < nbOp; i++) {
Operation opi = operations.get(i);
if(opi.Demand> 0) {
resources[opi.vehicle] =
cp.sum(resources[opi.vehicle],
cp.stepAtStart(opList[i], opi.Demand));
}else {
resources[opi.vehicle] =
// THIS SHOULD BE A SUBSTRACTION (NEGATIVE DEMAND)
cp.sum(resources[opi.vehicle],
cp.stepAtStart(opList[i],opi.Demand));
}
if(opi.StartOperation){
resources[opi.vehicle] =
cp.sum(resources[opi.vehicle],
cp.stepAtStart(opList[i],opi.initialLoad));
}
}
for(int v = 1; v < nbVeh - 1 ; v++) {
cp.add(cp.le(resources[v], inst.capacities.get(v)));
}
Is this the correct approach? Is there a way of modeling this fluctuation of cargo within the vehicle? I would like to model a way of forbidding certain permutation of vistis for the vehicle that violate the capacity constraints.
For example, if my vehicle has a capacity of 10 units, initial load of 8 units, and two operations A and B (Operation A: Pick-up 4 units at city 1. Operation B: Delivery 5 units at city 2). I expect that permutation (A->B) is not allowed, because it violates the capacity constraint of the vehicle at city 1.