# Suppress error for infeasible problem in Jump

**URL:** https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [March 29, 2023, 8:40am UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758 "2023-03-29T08:40:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![umbe](https://avatars.discourse-cdn.com/v4/letter/u/f19dbf/32.png) [@umbe](https://discourse.julialang.org/u/umbe)
#### Post date: [March 29, 2023, 8:40am UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758/1 "2023-03-29T08:40:45Z")

</div>

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

```julia
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?

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [March 29, 2023, 12:02pm UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758/2 "2023-03-29T12:02:42Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![umbe](https://avatars.discourse-cdn.com/v4/letter/u/f19dbf/32.png) [@umbe](https://discourse.julialang.org/u/umbe)
#### Post date: [March 29, 2023, 1:27pm UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758/3 "2023-03-29T13:27:48Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

### Author: ![Yuri\_Mizusawa](https://avatars.discourse-cdn.com/v4/letter/y/e480ec/32.png) [@Yuri\_Mizusawa](https://discourse.julialang.org/u/Yuri_Mizusawa)
#### Post date: [March 29, 2023, 2:00pm UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758/4 "2023-03-29T14:00:55Z")

</div>

Hi,  
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:

> [@Suppress license output from solver in JuMP.Model](https://discourse.julialang.org/t/suppress-license-output-from-solver-in-jump-model/20828):
>
> using JuMP, Gurobi m = Model(solver=GurobiSolver(OutputFlag=0)) I have a program where the second line gets called frequently. Every time it does, this gets printed to stdout: Academic license - for non-commercial use only How can I suppress this notice? In an old version of the JuMP FAQ it is suggested to use TT = stdout redirect\_stdout() m = Model(solver=GurobiSolver(OutputFlag = 0)) redirect\_stdout(TT) But I didn’t find this to work – perhaps it is outdated?

Set silent:

```julia
set_silent(model)

```

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

---

<div class="post-metadata">

### Author: ![umbe](https://avatars.discourse-cdn.com/v4/letter/u/f19dbf/32.png) [@umbe](https://discourse.julialang.org/u/umbe)
#### Post date: [March 29, 2023, 5:13pm UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758/5 "2023-03-29T17:13:50Z")

</div>

> [@Yuri\_Mizusawa](#):
>
> If I’m not mistaken you get this error from trying to acess the variable/objective value with an infeaseble problem.

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.

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [March 29, 2023, 5:51pm UTC](https://discourse.julialang.org/t/suppress-error-for-infeasible-problem-in-jump/96758/6 "2023-03-29T17:51:44Z")

</div>

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

See

- [Solutions · JuMP](https://jump.dev/JuMP.jl/stable/manual/solutions/#Recommended-workflow)

You can use something like:

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

```
