Optaplanner VRP增量得分-行程长度

时间:2019-03-05 07:39:49

标签: optaplanner

我想为VRP创建增量分数计算以最小化成本,其中成本是车辆的可变成本(usd / km)加上驾驶员成本(usd / h),而且我还有一个硬约束,即总成本游览时长(每司机8小时)(为此我向所有车辆以及驾驶员usd / h添加了行驶速度参数)。 我已经在轻松的分数计算中实现了它,但是对于大型数据集,它必须运行比我想要的更多的东西,所以我尝试了增量方式。

我试图简单地在原始增量分数计算中插入其他行,但是似乎失败了。 当我阅读其他资料时,我认为问题可能来自previousStandstill,vehicle和nextCustomer的更新顺序。因此,当它更新previousStandstill时,客户有时还没有添加车辆,因此我无法将行驶时间(与previousStandstill的距离/行驶速度)与给定的车辆配对。

我已经检查了Customer域是否具有@PlanningEntity批注以及getVehicle获取器具有@AnchorShadowVariable批注。

我真的被困在这里。任何帮助将不胜感激。

更新: 我已经将一些代码添加到了增量分数-> insertPreviousStandstill中,以获取previousStandstill的载体:

        Vehicle vehicle = null;
        Vehicle vehicle2 = null;
        Standstill previousStandstill2 = customer.getPreviousStandstill();
        while (vehicle == null) {
            if (previousStandstill2 instanceof Vehicle) {
                vehicle = previousStandstill2.getVehicle();
            } else {
                Customer customer2 = (Customer) previousStandstill2;
                vehicle2 = customer2.getVehicle();
                if (vehicle2 == null) {
                    previousStandstill2 = customer2.getPreviousStandstill();
                } else {
                    vehicle = vehicle2;
                }
            }
        }
        Long vehicle_varcost = vehicle.getVarCost();
        softScore -= customer.getDistanceFromPreviousStandstill() * vehicle_varcost / 1000;

(还为更改代码之前和之后的所有代码添加了vehicle_varcost) 直到构建启发式(在EasyScore中我得到相同的结果)之前,它都可以正常工作,但是如果此后失败。

0 个答案:

没有答案
相关问题