Hi,
We're using or-tools to solve a multi-depot Vehicle Routing Problem. Occasionally we notice that it gives us a solution that looks a little suboptimal, but the problems we're solving are large enough that it's hard to tell by eye.
After some time, we've managed to find a 4-depot, 14-node (that is, ten nodes to visit) problem that displays this behaviour. We've also managed to distill the code required to show the problem down to about 100loc.
The code is at available at:
https://gist.github.com/geoffleyland/a2e721091207aa98f9a6aa5920c8e194
I'm using a freshly-compiled version of or-tools from git HEAD:
$ git log
commit 9a299d7fae511a8d906b8c5535e2a5761182c694
Author: Laurent Perron <
lpe...@google.com>
Date: Fri Sep 8 13:58:10 2017 +0200
minor improvement to internal comments
which was compiled on OS X (10.12.6) with clang (Apple LLVM version 8.1.0 (clang-802.0.42)). The test code was compiled with the following command-line:
c++ -std=c++11 -o ortools_vrp_4_depots_14_stops ortools_vrp_4_depots_14_stops.cpp -I/usr/local/include/or-tools -lortools
The code solves the problem three times:
- the first time, using the distance matrix as shown in the code. It obtains an optimal distance of 12409m, in which vehicles 0, 2 and 3 are used.
- we then swap the first two rows and columns of the distance matrix (essentially changing the ordering of the depots) and re-solve, obtaining a better distance of 11567m (842m less), and using all of the vehicles
- finally we swap back and run again, as a safety check, obtaining the same solution as the first run (as expected)
In the second solution the vehicle in row 0 gets the most work, but since we swapped, this is vehicle 1 from the previous solution. That is, the vehicle that gets most of the work in the better of the two solutions gets no work in the worse of the two.
We think that we should obtain the same solution regardless of the ordering of the depots in the distance matrix, and would appreciate any help spotting any deficiencies in our code, as we feel like we're running short of options we haven't explored.
If it's helpful, we have:
- tried a number of RoutingSearchParameters, but we haven't managed to make a difference, hence they are not shown in the code.
- made the distance matrix symmetric (as shown it is not) by coping the upper triangle. This didn't make a difference either.
- changed the order in which we specified the depots in the depots vector passed to the RoutingModel constructor. Nor did this make a difference.
As I said, we'd appreciate any help working out what's up.
Warm Regards,
Geoff