Returning dictionary as result of a function
AnsweredI created a mathematical model inside a function and solved it with Gurobi. I want to use the variable values and objective value obtained in the solution by passing them into another function.
So I want to get a dictionary with "return command" as the result of the function. When I try to do this, I get this error: <gurobi.Var *Awaiting Model Update*
1) How can I solve this problem?
2) Can I also get the result of more than one dictionary function with the "return command"?
Example:
(A_ik[i,k]=dicitonary)
def solve(...)
...
...
return A_ik
-
Official comment
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi,
You can solve the problem after formulating it via calling model.optimize().
I suggest you take a look a look at the Python examples to quickly see how to retrieve variable values and objective function vals: mip1.py.
Full list of Python examples.
Cheers,
David0
Post is closed for comments.
Comments
2 comments