docplex.mp.sosvarset module

class docplex.mp.sosvarset.SOSVariableSet(model, variable_sequence, sos_type, weights=None, name=None)[source]

Bases: docplex.mp.basic.IndexableObject, docplex.mp.basic._AbstractBendersAnnotated

This class models Special Ordered Sets (SOS) of decision variables. An SOS has a type (SOS1, SOS2) and an ordered list of variables.

This class is not meant to be instantiated directly. To create an SOS, use the docplex.mp.model.Model.add_sos(), docplex.mp.model.Model.add_sos1(), and docplex.mp.model.Model.add_sos2() methods in Model.

benders_annotation

This property is used to get or set the Benders annotation of a SOS variable set. The value of the annotation must be a positive integer

iter_variables()[source]

Iterates over the variables in the SOS.

Note that the sequence of variables cannot be empty.

Returns:An iterator.
sos_type

This property returns the type of the SOS variable set.

Returns:An enumerated value of type docplex.mp.constants.SOSType.
to_string()[source]

Converts an SOS of variables to a string.

This function is used by the __str__() method

Returns:A string representation of the SOS of variables.