Search code examples
pythongurobipyomo

AttributeError: "AbstractModel" object has no attribute "computeIIS"


I have a Stochastic Mixed Integer Problem where some of the scenarios may give infeasible issues.

The model is formulated as an Abstract Pyomo Model and the solver I'm using is gurobi 8.1.0

I want to see the Irreducible Inconsistent Subsystem (IIS) so I could fix my infallibility problems.

In the link below is the function I'm trying to use, model.computeIIS().

http://www.gurobi.com/documentation/8.1/refman/py_model_computeiis.html

I have tried copy pasting from time link above and implemented the code below (http://www.gurobi.com/documentation/8.1/examples.pdf , workforce1.py page 401)

model.computeIIS()
     if model.IISMinimal :
         print("IIS is minimal \n")
     else :
         print ("IIS is not minimal \n")
         print ("\ n The following constraint (s) cannot be satisfied:")

for c in model.getConstrs():
     if c.IISConstr:
     print ("%s" % c.constrName)

I hoped that this would have printed the IIS. Unfortunately, it just gives me the Attribute Error:"AbstractModel" object has no attribute "computeISS"


Solution

  • Your model seems to be a Pyomo model, but the example is using the Gurobi Model class. The Pyomo class does not have the method computeIIS.

    The GurobiDirect class accepts some Gurobi parameters, including ResultFile. The following will make Gurobi write an IIS to a file:

    opt = SolverFactory('gurobi')
    opt.options['ResultFile'] = "test.ilp"
    

    The suffix of the filename determines the type of the result file; .ilp is for IISs. See here.