Starting from 5.4.0.CR1 (soon to be released), Planner will have chained support: a feature specifically designed to help solve Traveling Salesman and Vehicle Routing like problems with minimal code. It’s compatible with all the other planner features (construction heuristics, metaheuristics, real-time planning, …) and it replaces a ton boilerplate code I used to have in the TSP example.
From the documentation:
- Directly points to a planning fact, which is called an anchor.
- Points to another planning entity with the same planning variable, which recursively points to an anchor.
- A chain is never a loop. The tail is always open.
- Every chain always has exactly 1 anchor. The anchor is a problem fact, never a planning entity.
- A chain is never a tree, it is always a line. Every anchor or planning entity has at most 1 trailing planning entity.
- Every initialized planning entity is part of a chain.
- An anchor with no planning entities pointing to it, is also considered a chain.
MoveFactory‘s do chain correction to guarantee that the model stays valid: