Skip to main content

Deal with quadratic constraints

Ongoing

Comments

2 comments

  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Lorenz,

    You can retrieve quadratic constraints with gurobipy using the Model.getQConstrs() method.  You can then query relevant attributes listed here: Quadratic Constraint Attributes

    You can control the linearization of quadratic constraints (by Gurobi) using PreQLinearize.  Is there a motivation for wanting to do the linearization yourself?

    - Riley

    0
  • Lorenz Wagner
    Investigator
    Gurobi-versary
    Conversationalist

    Hi Riley Clement thanks a lot. My guess would be something like this.

    for i in I:
        for t in range(2, len(T) + 1):
            m.addConstr(n[i, t] == n_h[i, t] - e[i, t] + b[i, t])
            m.addConstr(n_h[i, t] <= n[i, t-1] + sc[i, t])
            m.addConstr(n_h[i, t] >= (n[i, t-1] + sc[i, t])-M*r[i, t])
            m.addConstr(n_h[i, t] <= M*(1 - r[i, t]))

    Sadly i cant test it right now. Would that work?

    0

Please sign in to leave a comment.