【问题标题】:Optaplanner VRP incremental score overconstrained planningOptaplanner VRP 增量分数过度约束规划
【发布时间】:2017-03-11 12:48:25
【问题描述】:

我想为规划过度受限的 VRP 创建增量分数。我创建了一个额外的虚拟车辆,其中包括所有计划外的客户。

问题是当 optaplanner 将客户移动到其他车辆时,它使用变量名 previousStandstill 调用 afterVariableChanged 并且该客户的车辆未刷新。然后我不知道该客户的车辆,我不知道我是否需要添加软成本(对于虚拟车辆我无法添加成本)。

如何解决这个问题?

例子:

Optaplanner 将 Customer1 从 Vehicle1 移动到 Vehicle2:

beforeVariableChanged:  previousStandstill(Customer1),  customer.GetVehicle() = Vehicle1
beforeVariableChanged:  nextCustomer(Customer0),        customer.GetVehicle() = Vehicle1
afterVariableChanged:   nextCustomer(Customer0),        customer.GetVehicle() = Vehicle1
afterVariableChanged:   previousStandstill(Customer1),  customer.GetVehicle() = Vehicle1
beforeVariableChanged:  vehicle(Customer1),             customer.GetVehicle() = Vehicle1
afterVariableChanged:   vehicle(Customer1),             customer.GetVehicle() = Vehicle2

当我在 customer.GetVehicle() 中得到 afterVariableChanged: previousStandstill(Customer1) 时,我有旧的车辆价值,我不知道是否需要添加软成本(因为虚拟车辆成本被忽略)。 有没有办法在 afterVariableChanged - previousStandstill 而不是 afterVariableChanged - vehicle 中获取实际车辆。

【问题讨论】:

    标签: optaplanner


    【解决方案1】:

    检查您是否使用 AnchorShadowVariable 注释了车辆字段:

    @AnchorShadowVariable(sourceVariableName = "previousStandstill")
    public VehicleNode getVehicleNode() {
        return vehicleNode;
    }
    

    该注释告诉 Optaplanner 更新车辆字段。

    【讨论】:

    • 是的,我有 AnchorShadowVariable。问题是 Customer 中的车辆变量在调用 afterVariableChanged 后更新,变量名称为 previousStandstill
    • 包含这个注解的类也有PlanningEntity注解吗?这应该有效。
    • 是的,确实如此。问题是车辆字段更新的时间。
    猜你喜欢
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多