8.6.9. QConstr

class QConstr

Represents a quadratic constraint in the model. Quadratic constraints are usually expressed as a quadratic expression.

Properties

index

The index of the quadratic constraint

index

The index of the quadratic constraint.

Methods

getAttr()

Obtain the attribute value associated with the quadratic constraint

sameAs()

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

setAttr()

Set the attribute value associated with the quadratic constraint

getAttr(attrname)

Obtain the attribute value associated with the quadratic constraint.

Parameters

attrname – Attribute name

example:

m = Model()
x = m.addVar()
qc = m.addConstr(2 * x * x <= 1)
print(qc.qcrhs)
print(qc.getAttr(MDO.Attr.QCRHS))

Note

Attribute can also be read and written directly through object attributes, in this case, the attribute name is case-insensitive

sameAs(qconstr)

Test whether the quadratic constraint is the same as another quadratic constraint.

Parameters

qconstr – Another quadratic constraint to be tested.

setAttr(attrname, attrvalue)

Set the attribute value associated with the quadratic constraint.

Parameters
  • attrname – The name of the attribute.

  • attrvalue – The value of the attribute to be set.

example:

m = Model()
x = m.addVar()
qc = m.addConstr(2 * x * x <= 1)
qc.qcrhs = 2.0
qc.setAttr(MDO.Attr.QCRHS, 2.0)

Note

Attribute can also be read and written directly through object attributes, in this case, the attribute name is case-insensitive