メインコンテンツへスキップ

TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

ユーザーの入力を待っています。

コメント

4件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Ronald van der Velden
    • Gurobi Staff

    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
  • Laynufar Silsilia
    • Gurobi-versary
    • First Question
    • First Comment

    If I move the code above, the results appear 

    TypeError: unsupported operand type(s) for -: 'bool' and 'NoneType'

    0
  • Matthias Miltenberger
    • Gurobi Staff

    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

投稿コメントは受け付けていません。