friendlysam.opt.SOS2

class friendlysam.opt.SOS2(variables, **kwargs)

Special ordered set, type 2

An ordered set of variables, of which at most two may be nonzero. Any nonzero variables must be adjacent in order.

Add a SOS2 instance to an optimization problem just like a Constraint to enforce this condition.

Parameters:
  • variables (sequence of Variable instances) – The variables in the ordered set. Must be an ordered sequence (today list and tuple are allowed).
  • desc (str, optional) – A text describing the constraint.
  • origin (anything, optional) – Some object describing where the constraint comes from.
SOS2.desc A description of the constraint, for debugging.
SOS2.level A number indicating SOS1 (level=1) or SOS2 (level=2).
SOS2.origin The origin of the description.
SOS2.variables The ordered list of variables as a tuple.