TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
Awaiting user inputHi,
I get the following error;
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
I think this is because of these codes;
m.addConstr(sum(p[n,s] <= 21 for n in range (N) for s in range(S)), "jadwal")
print('constrain 1')
0
-
Hi,
I suspect the part "<= 21" should move after the for-loops:
m.addConstr(sum(p[n,s] for n in range (N) for s in range(S)) <= 21, "jadwal")
0 -
If I move the code above, the results appear
TypeError: unsupported operand type(s) for -: 'bool' and 'NoneType'
0 -
In that case, you should check what the list \(\texttt{p}\) actually contains. It seems, there are incompatible data types present.
Try this code:
for n in range(N):
for s in range(S):
print(f"{p[n,s]=}, {n=}, {s=}")1
Please sign in to leave a comment.
Comments
3 comments