Can get the value of LinExpr for dictionary type?
回答済みI used a binary variable to formulate a linear expression,and I want get the value of the linear expression and assign to a dictionary because I want to print it for check the codes. Then,I used the linear expression to formulate a quadratic expression.I want get the value of it and assign to a dictionary too.Thanks a lot !
-
正式なコメント
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?. -
Could you give us some more information about what exactly you are trying to do and what you need help with? Do you need help getting the values? (Both LinExpr and QuadExpr have a getValue method.) What are the keys of your dictionary?
0 -
I have tried to use getValue method , but I can't get the value
0 -
Which are the expressions for which you want to get the values?
Please note that you are using the variable name s twice (in the outer loop and in the loop inside quicksum) while i will be undefined. Maybe the inner loop should be over i instead?
0 -
I‘m sorry.It's my mistake.
And I want to get the value of A[s].If I print it directly,I get a expression involve parameter like this.
This expression is not my objective function.And I don't know the method that document given us how to use. So I can't get the value of the expression. Thank you for your patient.
0 -
You can call getValue on the A[s]. E.g.
for s in range(2):
print(A[s].getValue())
Note though that you first need a solution for this. I.e., you should first call optimize on your model.
0 -
I have optimized the model and used your method.But the result like this.
0 -
Could you please show a complete code sample?
0 -
Thanks a lot, I have solved it .
0
投稿コメントは受け付けていません。
コメント
9件のコメント