TypeError: 'bool' object is not iterable
回答済みI met a problem when I worked on my homework.
The constraint I want to add is below :
And my code look like this :
case.addConstrs(
(quicksum(x[j][k] for k in range(2, K + 1))
for j in range(J) == 1), 'Each job one machine'
)
The result show up :
What is the problem in my code?
p.s I'm not sure whether my question is clear enough.
0
-
When using the addConstrs method, you have to generate a list of constraints. Thus, you have to move your last \(\texttt{for}\)-loop after the \(\texttt{== 1}\) part
case.addConstrs(
(quicksum(x[j][k] for k in range(2, K + 1))
== 1 for j in range(J)), 'Each job one machine'
)Best regards,
Jaromił0
サインインしてコメントを残してください。
コメント
1件のコメント