# Obtain and print IIS using Gurobi

**URL:** <https://discourse.julialang.org/t/obtain-and-print-iis-using-gurobi/27116>\
**Category:** Optimization (Mathematical)\
**Created:** [August 2, 2019, 3:01pm UTC](https://discourse.julialang.org/t/obtain-and-print-iis-using-gurobi/27116 "2019-08-02T15:01:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgo/32/48751_2.png) [@lgo](https://discourse.julialang.org/u/lgo)\
**Post date:** [August 2, 2019, 3:01pm UTC](https://discourse.julialang.org/t/obtain-and-print-iis-using-gurobi/27116/1 "2019-08-02T15:01:27Z")

</div>

Hello,

Gurobi has a function to obtain a Irreducible Inconsistent Subsystem (ISS), which refers to a subset of equations causing infeasibility. This obviously comes in very handy when debugging your problem.

I succeeded to compute the ISS for a JuMP problem with the following code, but I fail to obtain the actual equations causing infeasibility.

> using JuMP, Gurobi  
> model = Model(with\_optimizer(Gurobi.Optimizer))
> 
> @variable(model, x \>= 0)  
> @variable(model, y \>= 0)
> 
> @constraint(model, con1, x + y \<= 3)  
> @constraint(model, con2, x + y \>= 5)  
> @objective(model, Min, x)  
> optimize!(model)
> 
> grb\_model = model.moi\_backend.optimizer.model.inner  
> computeIIS(grb\_model)

Actually, there is an extensive GitHub thread on this topic [here](https://github.com/JuliaOpt/JuMP.jl/issues/1035) providing two ways to obtain the IIS:

The first one is from back from 2017 and probably outdated. It’s posted below and returns `MethodError: no method matching Array{Int32,N} where N(::Int64)` on `Gurobi.get_intattrarray` in my example.

> num\_constrs = Gurobi.num\_constrs(grb\_model)  
> iis\_constrs = Gurobi.get\_intattrarray(grb\_model, “IISConstr”, 1, num\_constrs)  
> model.linconstr[find(iis\_constrs)]

The second one is a new commit to the Gurobi package adding a `compute_conflict` function. However, altough the new function appears to be on the master branch and Gurobi is updated, I can’t access it and it does not show up in my local package files.

---

<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:** [August 3, 2019, 8:40am UTC](https://discourse.julialang.org/t/obtain-and-print-iis-using-gurobi/27116/2 "2019-08-03T08:40:48Z")

</div>

Use

```nohighlight
] add Gurobi#master

```

to get the latest version of Gurobi.

---

<div class="post-metadata">

**Author:** ![lgo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgo/32/48751_2.png) [@lgo](https://discourse.julialang.org/u/lgo)\
**Post date:** [August 3, 2019, 6:21pm UTC](https://discourse.julialang.org/t/obtain-and-print-iis-using-gurobi/27116/3 "2019-08-03T18:21:15Z")

</div>

> [@lgo](#):
>
> model.moi\_backend.optimizer.model

Thanks. I was not aware of that. I can now use the newly added functions, but I still don’t know how to determine the constraints within the IIS. The package only enables you to test for certain constraints via their MOI object, but I’m working on the JuMP level.

Edit: Got it working like this:  
I got my minimal example working like this:

```julia
Gurobi.compute_conflict(model.moi_backend.optimizer.model)
MOI.get(model.moi_backend, Gurobi.ConstraintConflictStatus(), con1.index)

```
