docplex.mp.sosvarset module¶
-
class
docplex.mp.sosvarset.
SOSVariableSet
(model, variable_sequence, sos_type, name=None)[source]¶ Bases:
docplex.mp.basic.ModelingObject
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()
, anddocplex.mp.model.Model.add_sos2()
methods in Model.-
__getitem__
(item)[source]¶ This special method enables the [] operator on special ordered sets,
Parameters: item – an integer from 0 to the number of variables -1 Returns: The variable in the set at location <item>
-
__len__
()[source]¶ This special method makes it possible to call the len() function on an SOS, returning the number of variables in the SOS.
Returns: The number of variables in the SOS.
-
__str__
()[source]¶ Redefine the standard __str__ method of Python objects to customize string conversion.
Returns: A string representation of the SOS of variables.
-
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
.
-