10.9. Using a Custom Termination, MoveSelector, EntitySelector, ValueSelector or Acceptor

You can plug in a custom Termination, MoveSelector, EntitySelector, ValueSelector or Acceptor by extending the abstract class and also the related *Config class.
For example, to use a custom MoveSelector, extend the AbstractMoveSelector class, extend the MoveSelectorConfig class and configure it in the solver configuration.
Note
It's not possible to inject a Termination, ... instance directly (to avoid extending a Config class too) because:
  • A SolverFactory can build multiple Solver instances, which each require a distinct Termination, ... instance.
  • A solver configuration needs to be serializable to and from XML. This makes benchmarking with PlannerBenchmark particularly easy because you can configure different Solver variants in XML.
  • A Config class is often easier and clearer to configure. For example: TerminationConfig translates minutesSpentLimit and secondsSpentLimit into timeMillisSpentLimit.
If you build a better implementation that's not domain specific, consider contributing it back as a pull request on github: we'll optimize it and take it along in future refactorings.