JuMP 0.21. How to stop the solver in callback?

Dear community,

in older JuMP versions, one was able to stop the solving process in a callback with JuMP.StopTheSolver. However, I did not find something similar in the documentation of the current release 0.21. Do have any suggestions?

Thanks in advance.

I don’t think we have a way to do this at present.

If you’re willing to use one particular solver, you can write a solver-dependent callback.
e.g., https://github.com/JuliaOpt/JuMP.jl/blob/13ad5db156210f805699e8a1004610d60bc3be3b/examples/callbacks.jl#L132-L149
You would need to find the write GLPK.ios_xxx function to call though (from memory, it’s something like ios_terminate(cb_data.tree)).

If you’re using Gurobi or CPLEX, you can do something similar, but it isn’t well documented. The best thing to do is look in the test/MOI_callbacks.jl file in each repository.