Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

promblems in pyomo

56 views
Skip to first unread message

jinyu yue

unread,
Mar 25, 2025, 9:36:30 AMMar 25
to Pyomo Forum
Something wrong with my code, and gurobi with pyomo cant solve the problem. It seems wrong at presolve progress and I dont know how to make it right.

Optimize a model with 50163 rows, 967 columns and 4569 nonzeros
Model fingerprint: 0x3c53ad90
Variable types: 751 continuous, 216 integer (216 binary)
Coefficient statistics:
  Matrix range     [2e-01, 1e+02]
  Objective range  [1e+00, 1e+00]
  Bounds range     [1e+00, 1e+03]
  RHS range        [5e-02, 1e+02]
Presolve removed 48419 rows and 199 columns
Presolve time: 0.00s

Explored 0 nodes (0 simplex iterations) in 0.00 seconds (0.00 work units)
Thread count was 1 (of 16 available processors)

Solution count 0

Model is infeasible
Best objective -, best bound -, gap -
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
    - termination condition: infeasible
    - message from solver: Model was proven to be infeasible.

Andres Ramos

unread,
Mar 25, 2025, 9:40:58 AMMar 25
to Pyomo Forum
For solving infeasibilities we write the lp file and then we use gurobipy with the iis option to detect the constraint or variable that is causing the infeasibility.
Alternatively, we can send me the lp file and I can try to do it
Regards
Andrés


De: 'jinyu yue' via Pyomo Forum <pyomo...@googlegroups.com>
Enviado: martes, 25 de marzo de 2025 14:11
Para: Pyomo Forum <pyomo...@googlegroups.com>
Asunto: promblems in pyomo
 
--
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.
To view this discussion visit https://groups.google.com/d/msgid/pyomo-forum/44178156-a38e-475e-b830-b9894f1fa66cn%40googlegroups.com.

Andres Ramos

unread,
Mar 25, 2025, 9:43:18 AMMar 25
to Pyomo Forum
Yo can use this file as starting point
Andrés
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


De: 'jinyu yue' via Pyomo Forum <pyomo...@googlegroups.com>
Enviado: martes, 25 de marzo de 2025 14:11
Para: Pyomo Forum <pyomo...@googlegroups.com>
Asunto: promblems in pyomo
 

Siirola, John

unread,
Mar 25, 2025, 12:35:52 PMMar 25
to pyomo...@googlegroups.com

Additionally, there are some utilities in Pyomo for diagnosing infeasibilities, including :

 

Best,

John

.

unread,
Mar 27, 2025, 11:02:11 PMMar 27
to pyomo-forum
Thank you for the program, I use it to check the lp file. But I can't understand the output, because the constraint and bounds aren't what I write in my main file, what are they and what can I do now.  Meanwhile the lp flie is also strange.
T - T
------------------ 原始邮件 ------------------


发件人: "pyomo-forum" <arg...@gmail.com>;
发送时间: 2025年3月25日(星期二) 晚上9:43
收件人: "Pyomo Forum"<pyomo...@googlegroups.com>;
主题: RE: promblems in pyomo
DE350431@9825D744.2811E667.png
0A90898A@5E1ACB03.2811E667.png

.

unread,
Mar 27, 2025, 11:05:28 PMMar 27
to pyomo-forum
Thank you for the answer, I use IIS to check lp file, but the bounds and constraints aren't what in my main file. What's the problem? 
W-W



------------------ 原始邮件 ------------------
发件人: "pyomo-forum" <pyomo...@googlegroups.com>;
发送时间: 2025年3月26日(星期三) 凌晨0:35
主题: RE: [EXTERNAL] RE: promblems in pyomo
3039595B@321A3823.EC11E667.png
D6303307@B8A17F58.EC11E667.png

Andres Ramos

unread,
Mar 28, 2025, 2:27:24 AMMar 28
to pyomo-forum
I don't understand your answer but if you want the lp file to use the same symbols you use in pyomo you must use this option
io_options={'symbolic_solver_labels': True}
when calling ModelName.write function
Regards
Andrés


De: '.' via Pyomo Forum <pyomo...@googlegroups.com>
Enviado: viernes, 28 de marzo de 2025 4:05
Para: pyomo-forum <pyomo...@googlegroups.com>
Asunto: 回复:RE: [EXTERNAL] RE: promblems in pyomo
 
3039595B@321A3823.EC11E667.png
D6303307@B8A17F58.EC11E667.png

.

unread,
Mar 31, 2025, 10:44:51 PMMar 31
to pyomo-forum
thanks! The problem can be solved, but when the gap is close to 17%, the bound and gap change at a low speed, how to solve it.(main2.py is the project)




------------------ 原始邮件 ------------------
发件人: "pyomo-forum" <arg...@gmail.com>;
发送时间: 2025年3月28日(星期五) 下午2:26
收件人: "pyomo-forum"<pyomo...@googlegroups.com>;
主题: RE: 回复:RE: [EXTERNAL] RE: promblems in pyomo
30ABDAC2@E3971F1D.1953EB67.jpg
A4904B36@85177510.1953EB67.jpg
6A9208FC@6C03DC29.1953EB67.png
main2.py
Reply all
Reply to author
Forward
0 new messages