Returning multiple solutions to a scheduling issue with optaplanner

679 views Asked by At

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 are 1 answers

5
Eugene Shvartsman On BEST ANSWER

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.