linopy.model.Model.add_sos_constraints

linopy.model.Model.add_sos_constraints#

Model.add_sos_constraints(variable, sos_type, sos_dim, big_m=None)#

Add an sos1 or sos2 constraint for one dimension of a variable

The dimension values are used as SOS.

Parameters:
  • variable (Variable)

  • sos_type ({1, 2}) – Type of SOS

  • sos_dim (str) – Which dimension of variable to add SOS constraint to

  • big_m (float | None, optional) – Big-M value for SOS reformulation. Only used when reformulating SOS constraints for solvers that don’t support them natively.

    • None (default): Use variable upper bounds as Big-M

    • float: Custom Big-M value

    The reformulation uses the tighter of big_m and variable upper bound: M = min(big_m, var.upper).

    Tighter Big-M values improve LP relaxation quality and solve time.