Skip to main content

Invalid argument to QuadExpr multiplication Error

Answered

Comments

5 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff Gurobi Staff
    This post is more than three 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 why not try our AI Gurobot?.
  • Silke Horn
    • Gurobi Staff Gurobi Staff

    Hi Ibtissam,

    In the line

    quicksum( M_3[i] * f_3[(i,j)] * o[(i,j)] for i in range(L) for j in range(R) )

    you are trying to add products of three variables. This is not supported. You can only have products of at most two, i.e., quadratic terms.

    You can make the other approach work, but you have to define mul as new variables and then make

    mul[(i,j)] = f_3[(i,j)] * o[(i,j)

    constraints in the model, i.e.,

    m.addConstrs(mul[(i,j)] == f_3[(i,j)] * o[(i,j)] for i in range(L) for j in range(R))

     

    Please note that with (all the bilinear and power constraints) the resulting model may be hard to solve and the result could have approximation/rounding errors.

    1
  • ibtissam labriji
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hello Silke, 

    Thank you for your answer, but the problem still persists.

    This is part of what my code looks like : 

    I'm aware that the problem can be complex to solve, but I'd like to see how it plays out.

    Regards, 

    Ibtissam 

    0
  • Silke Horn
    • Gurobi Staff Gurobi Staff

    Hi Ibtissam,

    Could you try without

    mul[(i,j)] = f_3[(i,j)]*o[(i,j)] ?

    Best regards,
    Silke

    1
  • ibtissam labriji
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hello Silke, 

    Indeed it is working ! 

    Thank you. 

    Best Regards, 

    Ibtissam 

     

    0

Post is closed for comments.