简体   繁体   中英

Optaplanner VRP incremental score overconstrained planning

I want to create incremental score for VRP with overconstrained planning. I create one aditional dummy vehicle, which includes all unplanned customers.

The problem is when optaplanner move customer to other vehicle, it call afterVariableChanged with variable name previousStandstill and vehicle for that customer are not refreshed. Then i don't know vehicle for that customer, i don't know if i need add soft cost or no (for dummy vehicle i could not add cost).

How to solve this problem?

Example:

Optaplanner move Customer1 from Vehicle1 to 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

When I get afterVariableChanged: previousStandstill(Customer1), in customer.GetVehicle() I have old Vehicle value and I don't know if need to add soft cost (for dummy vehicle cost are ignored). Is there any way to get actual vehicle in afterVariableChanged - previousStandstill rather than in afterVariableChanged - vehicle.

Check if you annotated the vechicle field with AnchorShadowVariable:

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

That annotation says to Optaplanner to update the vechicle field.

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