OptaPlanner 多线程:我可以检索内部解析的 "moveThreadCount" 以实现再现性吗?
OptaPlanner Multithreading: Can I retrieve internally resolved "moveThreadCount" for reproducibility?
OptaPlanner v8.0.0.Final
我想将我的 OptaPlanner 引擎配置的 moveThreadCount
设置为 AUTO
,但我需要能够重现运行,即使这意味着我必须采用 moveThreadCount
值来自logs/stdout/whatever(即计划)。
我看到值已在 DefaultSolverFactory::buildSolver
第 82 行中解析:
Integer moveThreadCount_ = new MoveThreadCountResolver().resolveMoveThreadCount(solverConfig.getMoveThreadCount());
然后这个值被保存到同一文件第 90 行的 HeuristicConfigPolicy
,但我无法找到获取 HeuristicConfigPolicy
实例的方法,更不用说 moveThreadCount
.
我当然可以复制粘贴 MoveThreadCountResolver::resolveMoveThreadCount
,因为它不是 public 但是,即使它是 public 或者我做了复制粘贴,Runtime.getRuntime().availableProcessors()
不保证 return 每次调用的结果相同。
想法?
我认为快速而肮脏的解决方案是手动确定要使用的 moveThreadCount
(通过复制粘贴、我自己的算法等),然后执行“SolverConfig::setMoveThreadCount”。
谢谢!
将 Solver 转换为 DefaultSolver 将不起作用,因为没有 getter 用于 moveThreadCountDescription。或者,进入 CH/LS 检测 Decider 实现只是自找麻烦。
我越来越不推荐人们使用 AUTO
,主要是因为目前(在 8.5 及更低版本中)您可能拥有太多线程(由于拥塞,8 个线程的结果比 4 个线程的结果更差)。这将在未来的版本中修复。
所以,是的,不要使用 AUTO
并根据 Runtime.getRuntime().availableProcessors()
自己确定 moveThreadCount 并将其传递给 SolverConfig::setMoveThreadCount
。
OptaPlanner v8.0.0.Final
我想将我的 OptaPlanner 引擎配置的 moveThreadCount
设置为 AUTO
,但我需要能够重现运行,即使这意味着我必须采用 moveThreadCount
值来自logs/stdout/whatever(即计划)。
我看到值已在 DefaultSolverFactory::buildSolver
第 82 行中解析:
Integer moveThreadCount_ = new MoveThreadCountResolver().resolveMoveThreadCount(solverConfig.getMoveThreadCount());
然后这个值被保存到同一文件第 90 行的 HeuristicConfigPolicy
,但我无法找到获取 HeuristicConfigPolicy
实例的方法,更不用说 moveThreadCount
.
我当然可以复制粘贴 MoveThreadCountResolver::resolveMoveThreadCount
,因为它不是 public 但是,即使它是 public 或者我做了复制粘贴,Runtime.getRuntime().availableProcessors()
不保证 return 每次调用的结果相同。
想法?
我认为快速而肮脏的解决方案是手动确定要使用的 moveThreadCount
(通过复制粘贴、我自己的算法等),然后执行“SolverConfig::setMoveThreadCount”。
谢谢!
将 Solver 转换为 DefaultSolver 将不起作用,因为没有 getter 用于 moveThreadCountDescription。或者,进入 CH/LS 检测 Decider 实现只是自找麻烦。
我越来越不推荐人们使用 AUTO
,主要是因为目前(在 8.5 及更低版本中)您可能拥有太多线程(由于拥塞,8 个线程的结果比 4 个线程的结果更差)。这将在未来的版本中修复。
所以,是的,不要使用 AUTO
并根据 Runtime.getRuntime().availableProcessors()
自己确定 moveThreadCount 并将其传递给 SolverConfig::setMoveThreadCount
。