- Type Parameters:
T
- The class of the objects to be travelled to. Use a Locator to query the Location from these objects.
public class TravellingSalesman<T>
extends java.lang.Object
A simple solver for the Travelling Salesman Problem.
The solver tries to find good solution for the following question:
"Given a list of Locations, what is the shortest possible route that visits each Location?"
Optionally you can provide a start and/or end Location, e.g. the current machine Location, as the start Location
and/or a Location for the next task after that, as the end Location. These Locations can also be the same, to form
a loop. If left open (null) the solver will choose the best start and/or end Location for the route freely.
The solver uses Simulated Annealing.
The implementation is a bit extended from the typical school book examples to not only use "swaps" of two Locations
but also "twists", that reverse the travel direction between the swapped out Locations. The latter really improves the
solutions a lot, because it allows the solver to quickly "untwist" routes at (or near) crossing points. These crossing
points appear frequently for the rectangularly arrayed Location patterns assumed to be typically found on a PNP machine.