Displaying expressions when adding constraints
回答済みI'm transitioning from pyomo to gurobi. I'm going through the introduction to modeling jupyter notebook and have a question regarding expressions. How do i display the expressions for constraints created using the addConstrs method?
for example the constraint 'resources':
resources = m.addConstrs((x.sum(r,'*') <= 1 for r in R), name='resource')
printing out the variable 'resources' does not show the actual constraint expressions. Any help please?
1
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi,
There is no built-in \(\texttt{print}\) function for Gurobi objects. Thus, you can only print the actual expression by rebuilding it on your own by using functions for a linear expression to get the coefficients and variables of the left-hand side and the attributes of linear constraints to get the sense and the right-hand side.
A different and the most convenient way would be to use the write() function to write an LP file and subsequently work with this LP file.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント