Obtain and print IIS using Gurobi

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

Use

] add Gurobi#master

to get the latest version of Gurobi.

1 Like

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:

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