Skip to main content

Does Model.addGenConstrPWL() (Gurobi 9.0+) use SOS2?

Answered

Comments

2 comments

  • Maliheh Aramon
    • Gurobi Staff

    Hi Yuhan, 

    Does the Model.addGenConstrPWL() function internally rely on and automatically generate the standard SOS2 formulation (i.e., the "lambda" formulation with a $\lambda_i \in \text{SOS2}$ constraint)?

    Yes, it does. To approximate the function \(y = f(x)\), the Gurobi Optimizer uses the following set of constraints, where \((x_i, y_i)\) represents the \(i\)-th break point.
    \[ \begin{align} x = \sum_i \lambda_i x_i & \notag \\ y = \sum_i \lambda_i y_i & \notag \\ \sum_i \lambda_i = 1 & \notag \\ \lambda_i \geq 0 ~~\text{and}~~ \text{SOS2} & \notag \end{align} \]

    The first two constraints define the \(x\)- and the \(y\)- coordinates of the piecewise linear function. The third constraint ensures that \((x, y)\) is a convex combination of the breakpoint values. The SOS2 constraint ensures that the only two adjacent \(\lambda_i\) variables can be positive, which enforces that the solution lies on a single segment of the piecewise-linear function. 

    If the function \(f(x)\) is convex, the SOS2 constraints are redundant. 

    Best regards,

    Maliheh
     

    0
  • Yuhan Tang
    • Gurobi-versary
    • First Question
    • First Comment

    Thank you so much, Maliheh!

    0

Please sign in to leave a comment.