8.6.9. SOS

class SOS

Represent a Special Ordered Set (SOS) constraint.

Properties

index

The index position of the SOS constraint

Methods

getAttr()

Obtain the attribute value of SOS constraint

sameAs()

Test whether the SOS constraint is the same as another SOS constraint

setAttr()

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