In an MIP tool which utilizes cvxpy with Python MIP (CBC) as the solver, I am looking for a method to produce specifics of an infeasible solution for logging purposes. Does anyone know if this exists? I was reading that CPLEX has this capability (function) to point out specific constraints violations.
Asked
Active
Viewed 543 times
0
-
As far as i know, there is no support for this in MIP, cvxpy as well as Cbc itself. – sascha May 05 '21 at 12:01
-
This is why I suggested to either rely on python docplex or use cvxpy to export mps and then do the relaxation only with docplex – Alex Fleischer May 05 '21 at 15:22
1 Answers
-1
in python docplex you can get relaxation and conflict.
See example https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoorelaxationandconflict.py
So in your case you could either:
- Turn your model in python docplex
- Keep cvxpy, export mps file and then import mps file (with model.import_model) in docplex and then run relaxation in docplex
Here the model:
from docplex.mp.model import Model
from docplex.mp.relaxer import Relaxer
from docplex.mp.conflict_refiner import ConflictRefiner
mdl = Model(name='buses')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')
mdl.add_constraint(nbbus40 + nbbus30 <= 7, 'maxTotalBuses')
mdl.minimize(nbbus40*500 + nbbus30*400)
mdl.solve()
mdl.report()
print(f"* solve status is: '{mdl.solve_details.status}'") #infeasible model
print()
print("------- starting relaxation")
print()
rx = Relaxer()
rx.relax(mdl)
print ("number_of_relaxations= " + str(rx.number_of_relaxations))
rx.print_information()
mdl.report()
print(f"* status after relaxation is: {mdl.solve_details.status}")
#print(mdl.solution)
print()
print("------ starting conflict refiner")
print()
cr=ConflictRefiner()
conflicts=cr.refine_conflict(mdl)
conflicts.display()

Alex Fleischer
- 9,276
- 2
- 12
- 15
-
Hi Alex, thanks much for the reply I will investigate this approach further. – Mike Martley May 05 '21 at 14:44