Convex vs SOCP Constraint
AnsweredHello,
I am constructing a problem which includes a convex constraint:
\( l_{ij} * u_{i} \geq p_{ij}^2 + q_{i,j}^2 \)
which I coded as follows (with additional dimension \( t \) ):
Ohm_law = m.addConstrs((l_ij[i,j,t] * u_i[j,t] >= p_ij[i,j,t]**2 + q_ij[i,j,t]**2 for i,j,t in line_t), name='OhmsLaw')
The indices \( [i,j,t] \) are from a tupledict set with \( l_{ij}[i,j,t] , u_i[j,t] \geq 0 \).
With that constraint, the problem is solved in around 12 seconds.
I am looking for a way to speed up the solving time by replacing it with a SOCP constraint (if possible):
Therefore, my questions are as follows:
1. How do I code the SOCP constraint just like the figure?
2. According to how Gurobi handles the problem in general, does it really affect the computation time by changing the convex \( \rightarrow \) SOCP constraint?

Hi Panggah,
We don't have a direct API for SOC methods but you could use gurobipy.norm for this. Eg for \( \(x,y)\_2 <= z \):
x = m.addVar()
y = m.addVar()
z = m.addVar()
aux = m.addVar()
m.addConstr(aux == gp.norm([x,y],2))
m.addConstr(aux <= z)The norm constraint can use 1dim norm vars. Or alternatively:
¸m = gp.Model()
x = m.addVar()
y = m.addVar()
z = m.addVar()
m.addConstr(x**2 + y**2 <= z**2)does it really affect the computation time by changing the convex SOCP constraint
I doubt it. Gurobi is pretty good reformulating constraints to SOC under the hood, so it's possibly already doing that. But the name of the game of modelling is to try things out, even when the theory suggests it is not worth it.
 Riley
0
Please sign in to leave a comment.
Comments
1 comment