You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would just like to report that we can not get the intermediate solution after a keyboard interruption.
However, this feature is available when we use Minizinc through the terminal to solve an optimization problem.
The current Python interface outputs the intermediate solution when the time limit reaches. So, is it possible to add this feature for the keyboard interruptions as well?
The text was updated successfully, but these errors were encountered:
This is slightly tricky. The simple workaround to do this is to actually capture the intermediate solutions, and keep (only) the incumbent. You can then trap the keyboard interrupt in your Python script, and then outputting the captured incumbent before exiting.
The problem is that this pays the overhead of output/parsing for all the intermediate solutions. Depending on the amount of solutions (read: if there are thousands), this might be a large overhead to pay (especially in Python).
Instead, we would have to use MiniZinc behaviour, and, when the solutions() function is interrupted, output the last solution that is given when the terminate() method is completed on the process. This was part of the initial design of the solutions() function, but I found that Python would throw an error if you yielded values after the async generator was already cancelled. This means we would have to provide our own terminate method for the solution() generator. This is not impossible, but might be a lot of work.
I'm not sure if it's worth it . Especially since it should be noted that MiniZinc Python is currently set to always output and parse intermediate solutions since there are still various solvers that cannot be trusted to output their final solutions when reaching the time limit or when interrupted.
Hopefully the workaround works for you. Otherwise, maybe we can investigate what is possible.
Hello all,
I would just like to report that we can not get the intermediate solution after a keyboard interruption.
However, this feature is available when we use Minizinc through the terminal to solve an optimization problem.
The current Python interface outputs the intermediate solution when the time limit reaches. So, is it possible to add this feature for the keyboard interruptions as well?
The text was updated successfully, but these errors were encountered: