Skip to main content

What is the difference between quadratic expression and quadratic constraint for gurobi?

Answered

Comments

2 comments

  • Mario Ruthmair
    • Gurobi Staff

    Hi Hussein,

    A quadratic constraint consists of quadratic expressions, i.e., a quadratic expression is only a term involving products of variables, not a complete constraint.

    In your first case, where you add a quadratic constraint, the resulting model will be non-convex since quadratic equality constraints are always non-convex (except for a few special cases).

    In your second case, you do NOT add any quadratic constraints to the model, you just overwrite the Gurobi variable P[i,t] with some quadratic expression, which is not added to the model.

    To check what is actually included in your model, you could export it to a file with m.write("model.lp") and open the resulting plain text file.

    Best regards,
    Mario

    1
  • Hussein Sharadga
    • Gurobi-versary
    • Investigator
    • Conversationalist

    Thank you so much! Mario Ruthmair

    You are right. In my second case, the constraint was not added to the model. 

     

    Best,

    Hussein

    0

Please sign in to leave a comment.