Is there a way to stop optimization process when feasible solution is found?

Hey there.

I am solving a problem with lazy constraints using MOI callback interface. I want to know if there is a way to stop the branch-and-bound process when finding a new incumbent solution that is feasible? I don’t want to close the gap down.

I appreciate any help you can provide!

Hi there. I just moved this to the “Optimization (mathematical)” section.

No, there is no generic way to terminate the solution process. But you can write a solver-dependent callback to do so. Which solver are you using?

If Gurobi, see the GRBterminate call here: GitHub - jump-dev/Gurobi.jl: Julia interface for Gurobi Optimizer

1 Like

If you do not care about the objective value, you can zero-out the objective. Any solver should terminate as soon as one feasible solution is found.

If you are using Gurobi, you can also use the parameter SolutionLimit. Setting it to 1 will make Gurobi terminate as soon as the first feasible solution is found (note that “feasible” includes “must satisfy all lazy constraints”). Other solvers may have a similar parameter, but I do know those as well.


Hey odow, thanks!

I am using Gurobi as solver. Thanks for the suggestions.

1 Like

The parameter works! Thank youuuuuu