简体   繁体   中英

How to model capacity constraints with pick-up and delivery operations with CP Optimizer?

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.

A better solution would be to create for each item and each possible vehicle whose start date an optional Interval Variable is the load date, end date the unload date, setting its minimum size the temporal distance between load and unload location. (do not forget to add the alternative of vehicle for an item)

Then the added cumulative constraint for each vehicle is :

cp.add(cp.le(cp.sum(pulse(transport[v][i],opi.initialLoad)), inst.capacities.get(v)));

This will simplify the model declaration and improve the performance of the solver thanks to the temporal correlation between load and unload date

Hope that help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM