Closed H3ADLESS closed 4 years ago
For a NeighbourSelection, returning null is an indication that the neighborhood has been exhausted and the search should progress with the next one. For example, the BranchBoundSelection (that is used by the student sectioning solver, and that tries to find the best possible schedule for each student while everything else is fixed) returns null when all student has been tried. Please note that the NeighbourSelection.init(Solver) is called before the selection is used. It is, for instance, used to reset the list of students that will be tried during the next phase (consecutive calling of NeighbourSelection. selectNeighbour(solution), until null is returned).
It is not, however, expected that all neighbor selections would keep returning null values and nothing else. That said, it would be possible to add a termination condition check within or just before the changeSelection called.
Hey there,
I have just spend some time to detect why my custom solver didn't terminate. It's probably a good idea to return null, if all registered neighbourSelections fail to find a neighbour or check for terminationCondition. Adding a random selection helps preventing this issue.
Maybe there are other ways to avoid this problem? Probably the most selections will at some point return a valid neighbour.
This is the relating code of RoundRobinNeighbourSelection