简体   繁体   English

如何使用CP Optimizer对收货和交付操作进行容量约束建模?

[英]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. 我想使用CPLEX的CP优化器,并且正在使用Java Eclipse对其建模。

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. 我尝试使用cumul函数表达式对此进行建模,因为我可以使用StepAtStart函数来指示操作开始时容量的增加。 However, the function does not model negative values. 但是,该函数不会对负值建模。

I have tried this code, inspired from the SchedRCPSP example. 我已经从SchedRCPSP示例获得启发,尝试了这段代码。 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. 我想建模一种方法,禁止违反容量限制的车辆使用一定的vistis排列。

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). 例如,如果我的车辆的容量为10个单位,初始负载为8个单位,并且有两个操作A和B(操作A:在城市1上取4个单元,操作B:在城市2上取5个单元)。 I expect that permutation (A->B) is not allowed, because it violates the capacity constraint of the vehicle at city 1. 我希望不允许排列(A-> B),因为它违反了城市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))); 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 希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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