How can I stop a Gurobi solve in JuMP in real time (like Ctrl+C) and still keep the solution?

amit_97
Fri, 03 Oct 2025 04:43:06 +0000
Optimization (Mathematical)

I am using JuMP with Gurobi.jl to solve a MIP.

In Julia, pressing Ctrl+C usually kills the entire Julia process instead of just stopping Gurobi.

My goal is:

Stop the optimization at any arbitrary time (not using MIPGap, TimeLimit, or NodeLimit).

Still retrieve the best feasible solution found so far.

I’ve seen that Gurobi supports callbacks via JuMP/MOI. Is it possible to have something like a user interrupt (e.g., pressing a key) that triggers a callback to terminate the solver gracefully?

If yes, could someone show me the minimal working example of how to set this up in Julia?

Thanks!

12 posts - 3 participants