KeyError ( 0 0 0)
AnsweredHelloo,
Please, i have a littel problem, i need some help
I defined this Binary variable Z
After that i tried to introduce on it the quicksum fonction

I have this error message

Thank you,
0
-
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. -
On line 25, you assign the Var object returned by Model.addVar() to \(\texttt{Z[i, K, t]}\):
Z[i, K, t] = model.addVar(...)
You should use \(\texttt{k}\) instead of \(\texttt{K}\) here.
To simplify the code, consider using Model.addVars() to construct \(\texttt{Z}\):
Z = model.addVars(I, K, T, vtype=gp.GRB.BINARY, name="Z")
With this approach, \(\texttt{Z}\) is a tupledict object. The tupledict class includes helper methods to make model-building easier. For example, you could then use the tupledict.sum() method to simplify the creation of \(\texttt{result_3}\):
result_3 = 38 * Z.sum()
0 -
ohh I see,
Thanks a lot !
0
Post is closed for comments.
Comments
3 comments