spring-boot - 如何在使用 optaplanner-spring-boot-starter 时实现 questionFactChange?
问题描述
我将 Optaplanner 8.3.0.Final 与 optaplanner-spring-boot-starter 一起使用,一切都按预期工作,只是我不知道如何实现 issueFactChange。
这个问题:当使用带有 Optaplanner 的 autowired SolverManager 时,如何访问 scoreDirector?提到自动装配solverfactory,然后使用Solverfactory .getScoreDirectorFactory()。但是我看不到如何使用它来访问有线求解器管理器正在使用的求解器,我相信这就是我所需要的“addProblemFactChange”,当求解器可以这样做时,它应该会改变问题事实。
解决方案
存在SolverManager
缺少addProblemFactChange()
方法的 API 差距。
解决方法
如果没有高级SolverManager
API,解决方法是改用低级Solver
API:
@Autowired
SolverFactory<MySolution> solverFactory
public void runSolver() { // don't call this directly in an HTTP servlet/rest thread
Solver<MySolution> solver = solverFactory().buildSolver();
solver.solve(myProblem); // hogs the current thread
}
public void doChange() {
solver.addProblemFactChange( ... /* do change */);
}
推荐阅读
- firebase - 向 ListView.builder 添加一个项目颤振火力基地
- javascript - javascript不显示元素?
- python-3.x - 从乘法表打印输出生成 DataFrame - Python 3.x
- javascript - Laravel 5.6 - 在 javsascript 中获取路由名称
- javascript - 如何手动将“@material/drawer”包含到我的组件中?
- amazon-web-services - 如何使从 APIGateway 到 AWS Lambda 的 url 只能从某个域获得
- python - 如何使用日期时间字段执行 F() 查询?
- python-3.x - 在 wxpython 中将组合框选项作为参数返回
- javascript - 由于 firebase,我的 React 应用程序中的内存泄漏以及如何避免它?
- css - CSS 动画是否会导致 Angular 2 停止渲染?