from gurobipy import *
# import gurobi_modelanalyzer as gma
m=read('file.lp')
m.printStats()
# m.setParam('getA()',)
m.setParam('Method' ,2)
m.setParam('BarHomogeneous' ,1)
# m.setParam('Crossover',0)
# m.setParam('OutputFlag', 1)
# m.setParam('LogToConsole', 1)
# m.setParam('NumericFocus', 3)
# m.setParam('IISMethod', 0)
# m.setParam('BarHomogeneous', 1)
# m.setParam('FeasRelaxS', 0)
# m.feasRelaxS(2, False, False, True)
# # m.write('p2.lp')
# m=m.presolve()
# m.write('caso209h_ps.lp')
m.optimize()
# m.printQuality()
# print(m.KappaExact)
# gma.kappa_explain(m)
m.computeIIS()
m.write('pp.ilp')
# Print out the IIS constraints and variables
# print('\nThe following constraints and variables are in the IIS:')
# for c in m.getConstrs():
# if c.IISConstr:
# print(f'\t{c.constrname}: {m.getRow(c)} {c.Sense} {c.RHS}')
# for v in m.getVars():
# if v.IISLB:
# print(f'\t{v.varname} ≥ {v.LB}')
# if v.IISUB:
# print(f'\t{v.varname} ≤ {v.UB}')
# m.getVarByName('vX(Algeciras_Madrid)').X
Additionally, there are some utilities in Pyomo for diagnosing infeasibilities, including :
Best,
John
io_options={'symbolic_solver_labels': True}