TypeError: 'TempConstr' object is not iterable (on line 3)
回答済みfor k in range(1, 2*n):
for y,z in zip(range(max(0, k-n), min(n, k)),range(min(n, k)-1, max(0, k-n)-1, -1)):
name4 = model.addConstr(quicksum(x[y,z] == 1))
0
-
The expression
x[y,z] == 1
is a constraint, in particular it's a TempConstr object. So what you are trying to do in the code snippet is to add a constraint which is a sum of constraints, which is not possible.
Maybe you mean something like
for k in range(1, 2*n):
name4 = model.addConstr(quicksum(x[y,z] for y,z in zip(range(max(0, k-n), min(n, k)),range(min(n, k)-1, max(0, k-n)-1, -1))) == 1)Note that I am only guessing here, because your code snippet is not reproducible code.
Best regards,
Jaromił0
サインインしてコメントを残してください。
コメント
1件のコメント