[PULP+Gurobi solver]: computeIIS() method

769 views
Skip to first unread message

Baptiste Bapt

unread,
Dec 23, 2016, 5:01:29 AM12/23/16
to pulp-or-discuss

Hi everybody,

I’m currently using Pulp and the Gurobi solver and I would like to use some of gurobi method such as GUROBI.computeIIS() in order to catch the source of infeasibility in my optimization problem.

I didn’t find any way to do it…

Maybe you can give me some insight how to achieve that.

What I would like to achieve:

#problem is then solved with the default solver
whiskas_model.solve(pulp.GUROBI(mip=True, msg=True, timeLimit=None, epgap=None))


if whiskas_model.status == pulp.constants.LpStatusInfeasible:
           
# part not working!!
           
whiskas_model.computeIIS() #WHAT DO I HAVE TO WRITE HERE IN ORDER TO USE gurobi.COMPUTEIIS() ?
           
print('\nConstraints:')
           
for c in whiskas_model.constraints():
               
if c.IISConstr:
                   
print('%s' % c.constrName)
           
print('\nBounds:')
           
for v in whiskas_model.variables():
               
if v.IISLB > 0 :
                   
print('Lower bound: %s' % v.VarName)
               
elif v.IISUB > 0:
                   
print('Upper bound: %s' % v.VarName)

 

 

Thanks a lot for you answer,

Baptiste

Shawn Helm

unread,
Dec 23, 2016, 5:43:33 PM12/23/16
to pulp-or...@googlegroups.com
Hi Baptiste,

I suggest you save the model as a mps file, then use gurobi_cl.exe and ask the command-line tool to write a .ilp format file.  It will attempt to solve the model, and if the model is found to be infeasible, it will automatically compute an IIS and write it to the requested file name.

Good luck, Shawn



--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.

Baptiste Bapt

unread,
Jan 4, 2017, 10:12:43 AM1/4/17
to pulp-or-discuss
Thanks a lot Shawn :)

For interested person:
To create the .mps, you just need to solve your optimization problem in that way
whiskas_model.solve()
It will create a YYYY.mps file in your folder
To create the .ilp, you need to open your terminal in the folder with your YYYY.mps and find the path to the Gurobi solver executable (in my case C:\gurobi600\gurobi600\win64\bin)
Then you just have to write:
"C:\gurobi600\gurobi600\win64\bin\gurobi_cl.exe ResultFile:XXXX.ilp YYYYmps
It will finally create a remaining .ilp that you can open with an editor to identify the violated constrainted.

Hoping that it will help,
Baptiste

Baptiste Bapt

unread,
Jan 4, 2017, 11:40:44 AM1/4/17
to pulp-or-discuss
here the automatized way in order to compute IIS using GUROBI solver

import os, glob, pulp

status = whiskas_model.solve(pulp.GUROBI(mip=True, msg=True, timeLimit=None, epgap=None))

if whiskas_model.status == pulp.constants.LpStatusInfeasible:

print 'Model Infeasible catched'
'remove all the existing .mps in your directory'
os.system('"del '+str('*.mps')+'"')

'create the .mps using the default pulp solver in order to get the .mps'
whiskas_model.solve(pulp.PULP_CBC_CMD())

MPS_file_created = glob.glob("*.mps")
'transform the .mps into a .ilp'
os.system('"C:\gurobi600\gurobi600\win64'+str(r'\bin')+'\gurobi_cl.exe ResultFile=IISresults.ilp '+MPS_file_created[0]+'"')

Reply all
Reply to author
Forward
0 new messages