TypeError:object of type 'gurobipy.gurobipy.LinExpr' has no len()
回答済みI need to add some constraints into my model.
The code and formula are as follows.
for i in range(1, n - 1):
for k in range(3, n):
BASE.addConstr(
ntk3[i, k]
== min_(
quicksum(htk[t, k] for t in range(i, i + 3)),
3 - quicksum(htk[t, k] for t in range(i, i + 3)),
)
)

Where h_ik is the 0-1 variable.
Gurobi always appears this TypeError:object of type 'gurobipy.gurobipy.LinExpr' has no len()
Looking forward to your reply.
0
-
正式なコメント
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?. -
The min_() helper function takes a list of Var objects and/or constants as arguments. Both of the arguments in your example are LinExpr objects.
To resolve the issue, add auxiliary variables to the model and set them equal to the linear expressions passed as arguments to the min_() function. Then, pass the corresponding Var objects as arguments to min_() instead.
0 -
Mr. Towle
thank you for your reply. I will try again.
0
投稿コメントは受け付けていません。
コメント
3件のコメント