我正在使用Optaplanner 8.3.0,最后使用了optaplanner-spring-boot-starter,除了我不知道如何实现problemFactChange之外,一切都像预期的那样工作。
这个问题:How is the scoreDirector accessed when using the autowired SolverManager with Optaplanner?提到自动装配解算器工厂,然后使用解算器工厂.getScoreDirectorFactory()。但我不知道如何使用它来访问有线solverManager正在使用的求解器,我相信这就是我所需要的"addProblemFactChange",当求解器可以这样做时,它应该会改变问题事实。
发布于 2021-04-13 15:34:25
有一个API缺口,SolverManager
缺少addProblemFactChange()
方法。
解决方法
如果没有高级API,解决方法是改用低级Solver
SolverManager
:
@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 */);
}
https://stackoverflow.com/questions/67025030
复制相似问题