Skip to main content

gurobipy.GurobiError: Invalid argument to QuadExpr multiplication

Answered

Comments

2 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Aria,

    I would guess that the issue is about the \(\texttt{expr}\) object.

    You don't assign a value to it but you check for equality, you use \(\texttt{==}\) instead of \(\texttt{=}\).

    Then, the

    m.addConstr(L[t] == P[t] * expr)

    is outside of the \(\texttt{for}\)-loop.

    Instead of using an intermediate \(\texttt{expr}\) object, you could directly model

    m.addConstr(L[t] == P[t] * -1 * ll[t] + 7 * P[t] * la[t] + 0.6 * P[t])

    On a side note: The error seems to not match the snippet, because there is a \(\texttt{expr1}\) in the error which is not present in your snippet.

    Best regards, 
    Jaromił

    1
  • Aria
    First Comment
    First Question

    Hi Jaromił,

    The error messages I was encountering with previous code have been resolved.

    Thank you.

    0

Please sign in to leave a comment.