OptaPlanner v8.0.0.Final
I want to set my OptaPlanner engine configs’ moveThreadCount
s to AUTO
, but I need to be able to reproduce runs even if it means I must take the moveThreadCount
value from the logs/stdout/whatever (that is the plan).
I see the value is resolved in DefaultSolverFactory::buildSolver
line 82:
Integer moveThreadCount_ = new MoveThreadCountResolver().resolveMoveThreadCount(solverConfig.getMoveThreadCount());
This value is then saved to a HeuristicConfigPolicy
on line 90 of the same file, but I cannot figure out a way to get the HeuristicConfigPolicy
instance, let alone the moveThreadCount
.
I could, of course, copy-paste MoveThreadCountResolver::resolveMoveThreadCount
, as it is not public but, even if it was public or I did copy-paste, Runtime.getRuntime().availableProcessors()
is not guaranteed to return the same result on every call.
Thoughts?
I suppose quick-and-dirty solution is to just manually determine what moveThreadCount
(via copy-paste, my own alg., etc.) to use and then do `SolverConfig::setMoveThreadCount’.
Thanks!
Advertisement
Answer
Casting the Solver to DefaultSolver won’t work, because there is no getter for moveThreadCountDescription. Alternatively, going into the CH/LS to detect the Decider implementation is just asking for trouble.
I am less and less recommending people to use AUTO
, mainly because currently (in 8.5 and lower) you can have too many threads (8 threads giving worse results than 4 threads due to congestion). That will be fixed in a future version.
So, yes, don’t use AUTO
and determine the moveThreadCount yourself based on Runtime.getRuntime().availableProcessors()
and pass that along through SolverConfig::setMoveThreadCount
.