Returning multiple solutions to a scheduling issue with optaplanner

独自空忆成欢 提交于 2019-12-11 03:01:33

问题


strong textHello Optaplanner experts,

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. 

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

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.

Thank you for your time,

Alice


回答1:


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  
    }
});

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.



来源:https://stackoverflow.com/questions/30945343/returning-multiple-solutions-to-a-scheduling-issue-with-optaplanner

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!