Operations Research Asked on November 17, 2021
I have just attempted to construct my first Pyomo model.
However, I was unable to locate any documentation that shows how to view constraints, decision variables.
As my model is big, I need to see that they are created and indexed correctly from time-to-time before proceeding further.
May I ask if anyone has chanced upon such documentation or have devised any ingenious method to do so within the confines of Python or Pyomo syntax?
Thank you!
After defining your model by putting the following statement in your code (wherever you want before or after solve command) your model with all the objects has been printed:
model.pprint()
If you like to print constraints or variables individually:
model.cons1.pprint() # For entire ConstraintList
print(model.cons2[i].expr) # For only one index of ConstraintList
model.write() # To write the model into a file using .nl format
Assuming that model
is the model that you defined and cons1
and cons2
are two ConstraintsList in that model.
Answered by Oguz Toragay on November 17, 2021
1 Asked on August 19, 2021
1 Asked on August 19, 2021
1 Asked on August 19, 2021 by antarctica
2 Asked on August 19, 2021 by qinqinxiaoguai
6 Asked on March 1, 2021 by rajya
integer programming linearization nonlinear programming quadratic programming
1 Asked on March 1, 2021 by windbreeze
1 Asked on February 18, 2021 by dspinfinity
0 Asked on February 18, 2021 by yue-chao
1 Asked on February 15, 2021 by user152503
1 Asked on January 18, 2021
linear programming linearization logical constraints mixed integer programming
0 Asked on January 18, 2021 by amedeo
0 Asked on January 15, 2021 by robert-hildebrand
integer programming optimization scheduling simulated annealing solver
3 Asked on January 11, 2021 by stevgates
1 Asked on January 8, 2021 by fathese
1 Asked on December 22, 2020 by che
binary variable linear programming linearization logical constraints mixed integer programming
1 Asked on December 13, 2020 by high-gpa
3 Asked on November 28, 2020 by joffrey-l
1 Asked on September 25, 2020 by independentvariable
convex optimization convexity nonconvex programming probability distributions
Get help from others!
Recent Answers
Recent Questions
© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP