8.7.11. GenConstr

class GenConstr

Represent a general constraint.

Properties

index

The index position of the general constraint

index

The index position of the general constraint.

Methods

getAttr()

Obtain the attribute value of a general constraint

sameAs()

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

setAttr()

Set the attribute value of general constraint

getAttr(attrname)

Obtain the attribute value of a general constraint.

Parameters

attrname – Attribute name

Note

Attributes 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 boolean result indicating whether the two general constraints are the same.

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.