Solver can't get to better solution because of "gets better before it gets worse" logic...advice sought #951
Replies: 1 comment 3 replies
-
Hello @mikepictor! Local search is generally well-suited to handle these situation. Both Late Acceptance (the default algorithm in Timefold Solver) and Simulated Annealing are designed to pick worsening solutions in order to escape local optima, up to a point. However, sometimes the solver needs a bit of help to understand that some things only move together, or that particular situations are unwanted. This is a typical use case for custom moves. In your case, your custom move would be to try to swap two tasks. If there is some logic in your business that tells you which two tasks it is beneficial to switch, even better; you get to avoid a lot of useless moves. But the more interesting question is: why would you even need to add this custom move? The fact that the solver didn't find a particular solution doesn't mean it couldn't. Given more time, perhaps it would've gotten there. Have you checked the best score graph? If you're not seeing a flat line there, it means the solver still has more to give. Or perhaps you have a score trap with some of your other constraints, resulting in the solver getting stuck on a number of different solutions which all result in the same score? Or perhaps you need a better configuration for local search, allowing the solver to be more adventurous in picking worsening moves. The benchmarker is your friend here. I have given you several avenues to investigate, but in general, I don't think this is a problem we can solve here. We do not know your problem, and even if we did, investigating this kind of an issue is time-consuming and usually a job for consulting. |
Beta Was this translation helpful? Give feedback.
-
I have a scenario where sometimes I end up with 2 tasks, one after another in a solver that is solving start times. The solution is ok, but not great, but it would be much better if task 2 came first, before task 1 (for various reasons, I will gloss over specifics). Being where it is is generating a fairly sizable soft constraint penalty. If it came first, it would be a much smaller penalty (or even maybe zero)
However if the tasks ever OVERLAP, then it generates a medium penalty equal to the number of minutes of overlap. So what I imagine is happening is that any time it tries to make task 2 come earlier, the soft penalty goes down, but the medium penalty goes up as the tasks start to overlap. The more they overlap, the larger the medium penalty. However, if it persevered until they no longer overlapped, things would be great, but I have to get over that hump of maximum overlap, and maximum medium penalty.
Is my thinking about the solver behaviour here at all realistic, and if so, what is the suggested way of handling this? The best idea I have is to always delete the old solution before trying again (rather than starting with the previous solve), and sometimes task 2 does come first and everything is great. It seems almost random if task 2 will come second or not.
Beta Was this translation helpful? Give feedback.
All reactions