Skip to main content

Convex vs SOCP Constraint



1 comment

  • Riley Clement
    Gurobi Staff Gurobi Staff

    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 1-dim 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



Please sign in to leave a comment.