8.6.11. GenConstr¶
- class GenConstr¶
Represent a general constraint.
Properties
The index position of the general constraint
- index¶
The index position of the general constraint.
Methods
Obtain the attribute value of general constraint
Test whether the general constraint is the same as another general constraint
Set the attribute value of general constraint
- getAttr(attrname)¶
Obtain the attribute value of general 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(genconstr)¶
Test whether the general constraint is the same as another general constraint.
- Parameters
genconstr – Another general constraint to be tested
- Returns
A bool result
example:
m = Model() b = m.addVar(vtype='B') x = m.addVar() y = m.addVar() gc = m.addGenConstrIndicator(b, True, x + y <= 3) print(gc.sameAs(m.getGenConstrs()[0]))
- setAttr(attrname, attrvalue)¶
Set the attribute value of general 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