TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
ユーザーの入力を待っています。Hi,
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
-
正式なコメント
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,
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
投稿コメントは受け付けていません。
コメント
4件のコメント