These days I try to build a Gurobipy optimization model by Pyomo and I met a problem about outputing IIS file. I use

opt = SolverFactory("gurobi", solver_io="python")
option = {"MIPGAP":0.001, "TimeLimit":300}
obj = ...
for k, v in option.items():
  opt.options[k] = v
result = opt.solve(model, warmstart=True, tee=True, options_string="ResultFile=iis_{}.ilp".format("model"))

When model comes IIS, I find that the variables in IIS's constrains have no variable name or index I coded but some numeric serial number only like

x95729: -x36195 - 1.71 x40465 = 0

I can't figure out which constraint it is. Then I try to use

log_infeasiable_constraints(model, log_expression=True, log_variables=True)

to find out which constraints and variables issue the IIS, and I get a lot of constraints, the number of them far exceeds the number of constraints I got through the last approach (maybe I would have gotten a few with the last approach, whereas with log_infeasiable I would have gotten dozens) And I find that some variables' value in constraints is "None".

Are there some solutions that could calculate the minimum IIS constraints with variables' names and indexes? And where do these variables that turn into None values come from?


1 Answer 1


Try adding the symbolic_solver_labels=True option to your call to solve:

result = opt.solve(model, warmstart=True, tee=True, symbolic_solver_labels=True, options_string="ResultFile=iis_{}.ilp".format("model"))

This option should preserve the variable names that you set when the model gets passed to the solver.

  • $\begingroup$ thx for help.Yet when I add the symbolic_solver_labels=True option to my solver, it raise ValueError says it is a unrecognized keyword.My gurobi is 9.0.3, is this a problem caused by version differences? $\endgroup$
    – CangWangu
    Oct 24, 2023 at 8:04
  • $\begingroup$ There are a few different Pyomo interfaces to Gurobi so I suspect the one you're using doesn't support the option I mentioned. Another thing you could try is the pyomo.contrib.iis extension which you can find here: github.com/Pyomo/pyomo/blob/main/pyomo/contrib/iis/iis.py $\endgroup$ Oct 24, 2023 at 13:22
  • $\begingroup$ it's works! Thx for your help again! $\endgroup$
    – CangWangu
    Oct 26, 2023 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.