Skip to main content

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

Awaiting user input

Comments

3 comments

  • Ronald van der Velden
    Gurobi Staff 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
    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 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

Please sign in to leave a comment.