使用optaplanner返回多个解决方案来解决计划问题 [英] Returning multiple solutions to a scheduling issue with optaplanner
问题描述
强文本您好,Optaplanner专家,
strong textHello Optaplanner experts,
我对OptaPlanner来说还很陌生,所以请原谅任何天真的或基本的问题.我正在使用它来计划:
I am pretty new to OptaPlanner, so please pardon any naive or basic questions. I am using it to schedule a:
set of jobs, A, B and C, which can be completed by 5 resources, say Will, Jane, Roy, Tom, Jeff.
这些工作中的每一项都可以由5种资源中的任何一种来完成.将会有一些算法基于软约束来计算谁最适合,但我还没有.现在,我只需要想出多种解决方案,例如
Each of these jobs can be done by any of the 5 resources. There will be some algorithm to calculate who is the best fit based on soft constraints, but I am not there yet. For now, I just need to come up with multiple solutions, say
1. Will - A, Roy - B and Jeff - C
2. Roy - B, Tom - B and Jane - C
... and so on
在OptaPlanner 6.2.0 Final版本中是否可以执行此操作?我只看到一种获得最佳解决方案的方法.我确定我缺少什么,只是不确定什么.任何指针将不胜感激.
Is there a way to do this in OptaPlanner 6.2.0 Final version? I only see a method for getting the best solution. I am sure I am missing something, just not sure what. Any pointers will be greatly appreciated.
感谢您的时间,
爱丽丝
推荐答案
There may be a better solution but I recommend adding a SolverEventListener to your solver via:
solver.addEventListener(new SolverEventListener<Solution>() {
@Override
public void bestSolutionChanged(BestSolutionChangedEvent<Solution> event) {
// TODO Auto-generated method stub
}
});
每次找到更好的解决方案时,都会调用bestSolutionChanged方法.从这里开始,您将需要克隆(我认为,Geoffrey会更好地知道)解决方案并将其保存到列表中(也许保留最后5个最佳解决方案之类的东西?)我将检查克隆过程需要多长时间,因为该方法应该返回
The bestSolutionChanged method will be called every time a better solution is found. From here you will need to clone(I think, Geoffrey would know better) the solution and save it to a list(maybe keep the last 5 best solutions or something? I would check how long the cloning process takes since the method should return rather quickly.
这篇关于使用optaplanner返回多个解决方案来解决计划问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!