如何为 Optaplanner 求解器实例化 EasyScoreCalculator?
How does one instantiate an EasyScoreCalculator for an Optaplanner Solver?
OptaPlanner documentation 列出了以下示例代码:
Alternatively, build a EasyScoreCalculator instance at runtime and set it with the programmatic API:
solverFactory.getSolverConfig().getScoreDirectorFactoryConfig.setEasyScoreCalculator(easyScoreCalculator);
我假设是:(缺少函数调用)
solverFactory.getSolverConfig().getScoreDirectorFactoryConfig().setEasyScoreCalculator(easyScoreCalculator);
但是,the JavaDoc describes没办法设置实例化EasyScoreCalculator
,只能指定一个class。我想在 运行 时间改变一些参数,构建一个 EasyScoreCalculator
在我看来是一个合理的方法。看起来好像是打算支持,但实际上不是。
我应该如何在 运行 时间的求解器 运行 之间改变分数计算器的参数?
setEasyScoreCalculator()
有意不可用,因为在 multi-threaded 中也解决了其他用例(例如 "explaining the score" - 请参阅docs), 会有多个 EasyScoreCalculator 实例并行激活,所以我们需要能够实例化它们。
How should I vary parameters for my score calculator between solver
runs at run-time?
<customPhase>
元素(参见 CustomPhaseConfig.java
)支持 Map<String, String> customProperties
改变自定义阶段的参数。 PartitionedSearchPhaseConfig.java
也以类似的方式支持其他功能。 在我们的问题跟踪器中创建一个问题(请参阅 optaplanner.org 上的 "get help")以在 EasyScoreCalculator、IncrementalScoreCalculator 和 Drools 上也支持这一点。 对于 Drools,它会将这些属性注入到全局字段。
在拉取请求中实施应该相当简单。在ScoreDirectorFactoryConfig.java中添加这样一个Map,传递给调用ConfigUtils的ScoreDirectorFactory在计算器实例上设置。
OptaPlanner documentation 列出了以下示例代码:
Alternatively, build a EasyScoreCalculator instance at runtime and set it with the programmatic API:
solverFactory.getSolverConfig().getScoreDirectorFactoryConfig.setEasyScoreCalculator(easyScoreCalculator);
我假设是:(缺少函数调用)
solverFactory.getSolverConfig().getScoreDirectorFactoryConfig().setEasyScoreCalculator(easyScoreCalculator);
但是,the JavaDoc describes没办法设置实例化EasyScoreCalculator
,只能指定一个class。我想在 运行 时间改变一些参数,构建一个 EasyScoreCalculator
在我看来是一个合理的方法。看起来好像是打算支持,但实际上不是。
我应该如何在 运行 时间的求解器 运行 之间改变分数计算器的参数?
setEasyScoreCalculator()
有意不可用,因为在 multi-threaded 中也解决了其他用例(例如 "explaining the score" - 请参阅docs), 会有多个 EasyScoreCalculator 实例并行激活,所以我们需要能够实例化它们。
How should I vary parameters for my score calculator between solver runs at run-time?
<customPhase>
元素(参见 CustomPhaseConfig.java
)支持 Map<String, String> customProperties
改变自定义阶段的参数。 PartitionedSearchPhaseConfig.java
也以类似的方式支持其他功能。 在我们的问题跟踪器中创建一个问题(请参阅 optaplanner.org 上的 "get help")以在 EasyScoreCalculator、IncrementalScoreCalculator 和 Drools 上也支持这一点。 对于 Drools,它会将这些属性注入到全局字段。
在拉取请求中实施应该相当简单。在ScoreDirectorFactoryConfig.java中添加这样一个Map,传递给调用ConfigUtils的ScoreDirectorFactory在计算器实例上设置。