8.6.10. SOS¶
- class SOS¶
Represent a Special Ordered Set (SOS) constraint.
Properties
The index position of the SOS constraint
- index¶
The index position of the SOS constraint.
Methods
Obtain the attribute value of SOS constraint
Test whether the SOS constraint is the same as another SOS constraint
Set the attribute value of SOS constraint
- getAttr(attrname)¶
Obtain the attribute value of SOS constraint.
- Parameters
attrname – Attribute name
Note
Attribute can also be read and written directly through object attributes, in this case, the attribute name is case-insensitive
- sameAs(sos)¶
Test whether the SOS constraint is the same as another SOS constraint.
- Parameters
sos – Another SOS constraint to be tested
- Returns
A bool result
example:
m = Model() x = m.addVar() y = m.addVar() sos = m.addSOS(MDO.SOS_TYPE1, [x, y]) print(sos.sameAs(m.getSOSs()[0]))
- setAttr(attrname, attrvalue)¶
Set the attribute value of SOS constraint.
- Parameters
attrname – The name of the attribute.
attrvalue – The value of the attribute to be set.
Note
Attribute can also be read and written directly through object attributes, in this case, the attribute name is case-insensitive