SOS2
SOS2, short for Special Ordered Set of type 2, is a constraint used in mathematical optimization to model piecewise linear relationships within mixed-integer linear programming (MILP) formulations. It restricts a prescribed ordered set of candidate variables so that at most two can be nonzero, and if two are nonzero, they must be adjacent in the given order. This enforces that the solution lies on a single segment between two neighboring breakpoints, enabling accurate and compact piecewise linear approximations of nonlinear functions.
In practice, SOS2 constraints are applied to a sequence of weights or breakpoint variables that define a
SOS2 is widely implemented in optimization tools and solvers, including Gurobi, CPLEX, GLPK, and CBC, with solver-specific
Compared with SOS1, which allows at most one nonzero variable, SOS2 permits two adjacent nonzeros, enabling