Deal with quadratic constraints
OngoingHello, I have the following problem. I am setting up a linear programme (or so I thought), but my model output shows something like this.
Model has xxxx quadratic constraints
Is there any way I can find out which of my constraints is causing these problems?
I have a hunch that it is this constraint here. Is there possibly a way to formulate it as a linear constraint?
for i in I:
for t in range(1,len(T)):
m.addConstr(n[i, t] == (n[i, t  1] + sc[i, t]) * (1  r[i, t])  e[i, t] + b[i, t])
\(n_{it}\) is an integer and both \(sc_{it}\) and \(r_{it}\) are binary.
Thank you for your help!

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 
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, t1] + sc[i, t])
m.addConstr(n_h[i, t] >= (n[i, t1] + 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.
Comments
2 comments