Suppress error for infeasible problem in Jump

Hello to everyone!
I am trying to solve a series of optimizations using Jump and Gurobi.
When a problem is found to be infeasible because of the impossibility to satisfy all the boundaries/constraints, Jump stops the process and returns the error in the REPL

ERROR: LoadError: MathOptInterface.ResultIndexBoundsError{MathOptInterface.ObjectiveValue}(MathOptInterface.ObjectiveValue(1), 0)

Now, I would like to avoid the stopping of my process by this error and evaluate if the single optimization converged with termination_status(model).
However, I cannot find any suggestion from the web about how to do that. Does anyone have any idea?

If I am not wrong, JuMP should not throw an error because o that. Are you sure you are not somehow trying to access the result before you check the termination status?

Thanks for the reply. You are right, there were some mispelled constraints. The correct error for the infeasibility of the problem is now:

ERROR: Result index of attribute MathOptInterface.ObjectiveValue(1) out of bounds. There are currently 0 solution(s) in the model

However, my question is still the same since this error breaks any process in which it is contained.

If I’m not mistaken you get this error from trying to acess the variable/objective value with an infeaseble problem.
I use a “try-catch” when accesing those values, but there might be better options for that.
Other than that you can set an environment for Gurobi, that will supress licence print and set the model to silence. But those only affect the text output while optimizing.
Gurobi env:

Set silent:


I don’t know if this is you problem, but I hope it helps.

1 Like

You are absolutely right, I did not realize that the error was due to fact that I was trying to access to the optimization results and not because of the execution of the optimization itself!
Thank you very much, the solution was easier than I was expecting.

1 Like

I use a “try-catch” when accesing those values, but there might be better options for that.


You can use something like:

if termination_status(model) == OPTIMAL
    @show value(x), objective_value(model)
    # Do something else