The out-of-the-box SolutionCloner works well for most use cases: it's fast, yet still does a few sanity checks to detect errors.
Custom solution cloningYou can still choose to roll your own solution cloning. Now, it's also documented what Planner expects you to do:
A planning clone of a
Solutionmust fulfill these requirements:
- The clone must represent the same planning problem. Usually it reuses the same instances of the problem facts and problem fact collections as the original.
- The clone must use different, cloned instances of the entities and entity collections. Changes to the
Solution's entities must not effect its clone.
And there's also warning, in case you're using chained planning variables, for a common pitfall:
Cloning an entity with a chained variable is devious: a variable of an entity A might point to another entity B. If A is cloned, then it's variable must point to the clone of B, not the original B.
But don't worry about that: just use the default SolutionCloner, which will take care of all that for you.