0

I implemented an asymmetric distance matrix for VRP in the examples of OptaPlanner as suggested in option B of answer https://stackoverflow.com/a/19420978/3743175

However the values of soft constraints does not coincide with the total value of the calculated distance of routes in the tests.

Anyone have any idea of the cause of this? I've checked several times, my matrix is correct and the problem does not occur for symmetric instances.

Any help is welcome.

Thanks.

Solution Found:

I found problem in lines with softScore calculation of the examples: the softscore is calculated with reverse arcs.

I replaced this lines in VehicleRoutingIncrementalScoreCalculator class:

...
softScore -= vehicle.getLocation().getDistance(customer.getLocation());
...
softScore += vehicle.getLocation().getDistance(customer.getLocation());

with:

...
softScore -= customer.getLocation().getDistance(vehicle.getLocation());
...
softScore += customer.getLocation().getDistance(vehicle.getLocation());

and I fixed the Customer class with following method:

public int getDistanceToPreviousStandstill() {
    if (previousStandstill == null) {
        return 0;
    }
    return previousStandstill.getLocation().getDistance(location);
}
Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0