Is there a step by step post about how to access the IIS with pyomo and gurobi solver?

802 views
Skip to first unread message

Erik Rafael

unread,
Sep 23, 2015, 12:13:04 PM9/23/15
to Pyomo Forum
Hi,

I would like to know which commands I need to have in my pyomo code to access the gurobi IIS and detect which constraint are making my model infeasible.

I have tried this, but it is not working:

# Create an IMPORT Suffix to store the iis information that will
# be returned by gurobi_ampl
model.iis = Suffix(direction=Suffix.IMPORT)

instance = model.create('../DT8.dat')
instance.pprint()

opt = SolverFactory('gurobi')
opt.options['outlev']  = 1  # tell gurobi to be verbose with output
opt.options['iisfind'] = 1  # tell gurobi to find an iis table for the infeasible model
instance.preprocess()
results = opt.solve(instance,options="mipgap=0.20",tee=True,warmstart=True) #,options='logfile=gurobi.log' opt.solve(model, tee=True, warmstart=True)
instance.load(results)

I am getting back from the environment:

***The GUROBI solver plugin cannot extract solution suffix=iis
Traceback (most recent call last):
  File "C:\Users\Erik\Documents\workspace\InjPipeJul2015\src\App4ExactOffTake\__init__.py", line 382, in <module>
    solve(instance)
  File "C:\Users\Erik\Documents\workspace\InjPipeJul2015\src\App4ExactOffTake\__init__.py", line 348, in solve
    results = opt.solve(instance,options="mipgap=0.20",tee=True,warmstart=True) #,options='logfile=gurobi.log' opt.solve(model, tee=True, warmstart=True)
  File "c:\program files (x86)\python27\packages\coopr\src\coopr.opt\coopr\opt\base\solvers.py", line 325, in solve
    result = self._postsolve()
  File "c:\program files (x86)\python27\packages\coopr\src\coopr.plugins\coopr\plugins\solvers\GUROBI.py", line 464, in _postsolve
    results = ILMLicensedSystemCallSolver._postsolve(self)
  File "c:\program files (x86)\python27\packages\coopr\src\coopr.opt\coopr\opt\solver\shellcmd.py", line 165, in _postsolve
    results = self.process_output(self._rc)
  File "c:\program files (x86)\python27\packages\coopr\src\coopr.opt\coopr\opt\solver\shellcmd.py", line 215, in process_output
    self.process_soln_file(results)
  File "c:\program files (x86)\python27\packages\coopr\src\coopr.plugins\coopr\plugins\solvers\GUROBI.py", line 323, in process_soln_file
    raise RuntimeError("***The GUROBI solver plugin cannot extract solution suffix="+suffix)
RuntimeError: ***The GUROBI solver plugin cannot extract solution suffix=iis

Thanks in advance for help and guidance.
Regards,

Gabe Hackebeil

unread,
Sep 23, 2015, 12:51:50 PM9/23/15
to pyomo...@googlegroups.com
You need to use the NL file interface (SolverFactory("gurobi_ampl")).

Gabe
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Erik Rafael

unread,
Sep 23, 2015, 9:14:15 PM9/23/15
to Pyomo Forum
Sorry I did not get. What I need to do exactly? Is it just to change the line below?

From opt = SolverFactory('gurobi') to opt = SolverFactory('gurobi_ampl') and everything is gonna work?

Gabriel Hackebeil

unread,
Sep 24, 2015, 1:37:09 AM9/24/15
to pyomo...@googlegroups.com
Yes. There is also an existing example for this. If you installed via pip, you will have to download the Pyomo examples in a separate package.

https://software.sandia.gov/trac/pyomo/downloader

You should find it in pyomo/suffixes/gurobi_ampl_iis.py. Although, I think you already have it figured out.

Gabe

andreas.o...@gmail.com

unread,
Nov 23, 2016, 3:09:09 AM11/23/16
to Pyomo Forum
Hi guys, I have a similar problem.
The example works fine, but when I want to apply the ISS-Suffix to my model I get the following error message:
 
Solving with Gurobi_AMPL Solver...
iisfind=1
timelim=12000
presparsify=1
mipfocus=0
threads=2
outlev=1
mipgap=0.0001
heurfrac=0.05
presolve=1
lpmethod=0
Optimize a model with 1732 rows, 2088 columns and 14602 nonzeros
Presolve removed 2 rows and 1 columns
Presolve time: 0.00s
Explored 0 nodes (0 simplex iterations) in 0.01 seconds
Thread count was 1 (of 4 available processors)
Model is infeasible
Best objective -, best bound -, gap -
Computing Irreducible Inconsistent Subsystem (IIS)...
      Constraints           Bounds       Runtime
     Min       Max       Min      Max
------------------------------------------------
        0     1732         0     4176         0s
IIS computed: 1 constraints, 16 bounds
Gurobi 5.6.2: infeasible
Returning an IIS of 1 constraints and 16 variables.
No primal variables returned.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)
  File "Y:/EV/!Projekte/15AS03 - FlexASU/WP2 - Econ/30 Optimierung/03 Time-resolved Operation/V04.03 20161116/Main.py", line 180, in <module>
    Optimizer.Run_Opt(i)
  File "Opt_Pyomo.py", line 553, in Run_Opt
  File "C:\Python27\lib\site-packages\pyomo\opt\base\solvers.py", line 580, in solve
    result = self._postsolve()
  File "C:\Python27\lib\site-packages\pyomo\solvers\plugins\solvers\ASL.py", line 203, in _postsolve
    return SystemCallSolver._postsolve(self)
  File "C:\Python27\lib\site-packages\pyomo\opt\solver\shellcmd.py", line 267, in _postsolve
    results = self.process_output(self._rc)
  File "C:\Python27\lib\site-packages\pyomo\opt\solver\shellcmd.py", line 348, in process_output
    suffixes=self._suffixes)
  File "C:\Python27\lib\site-packages\pyomo\opt\plugins\sol.py", line 47, in __call__
    return self._load(f, res, soln, suffixes)
  File "C:\Python27\lib\site-packages\pyomo\opt\plugins\sol.py", line 216, in _load
    convert_function(suf_line[1])
KeyError: 'v1800'

I don't know what's wrong. Can you help me?
 
Thanks in advance for help.
Regards,
Andreas
 

Gabriel Hackebeil

unread,
Nov 23, 2016, 12:17:21 PM11/23/16
to pyomo...@googlegroups.com
That’s interesting. Looks like it might be a bug. Would you mind sharing your model with me (off of the forum if you prefer)?

Gabe

andreas.o...@gmail.com

unread,
Nov 26, 2016, 1:33:08 AM11/26/16
to Pyomo Forum
There was a bug in my constraint formulation routine. Depending on the input data a constraint was generated that is infeasible itself.
For instance:
2 + x <=1

Where x is a binary.

This propably causes the error. 
Is there a way to identify such constraints, since they are not obviously to find due to the variable constraint formulation.
Andreas


Reply all
Reply to author
Forward
0 new messages