'tupledict' object is not callable
AnsweredI run gurobi via pyhton. I encountered 'tupledict' object is not callable error. Details are given below. I made the line of code which caused error bold.
runfile('C:/gurobi1000/win64/examples/python/production_transportation.py', wdir='C:/gurobi1000/win64/examples/python')
Restricted license - for non-production use only - expires 2024-10-28
Traceback (most recent call last):
File "C:\gurobi1000\win64\examples\python\production_transportation.py", line 202, in <module>
m.addConstrs(
File "src\gurobipy\model.pxi", line 3747, in gurobipy.Model.addConstrs
File "C:\gurobi1000\win64\examples\python\production_transportation.py", line 203, in <genexpr>
(production(i,j,k)==UPH(i,j)*base_prod(i,k) for i in plants for j in prod_line for k in months),"production_assignment_to_lines" )
TypeError: 'tupledict' object is not callable
-
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 Furkan,
Please note that this is not a minimal reproducible example and the help that can be provided is only limited.
It is not clear which objects are your variables. I will assume that all 3 objects \(\texttt{production, UPH, base_prod}\) are optimization variables. As described in the documentation of tupledict
To access the members of a
tupledict, you can use standard dict indexing. For example,d[1,2]returns the value associated with tuple(1,2).Thus, your constraint should read
m.addConstrs(production[i,j,k]==UPH[i,j]*base_prod[i,k]
for i in plants for j in prod_line for k in months),
name="production_assignment_to_lines")Best regards,
Jaromił0 -
Thank you Jaromil. I will create a minimal reproducible example for future questions.
Best regards,
Furkan
0
Post is closed for comments.
Comments
3 comments