8.6.14. PsdConstr

class PsdConstr

Represents a constraint of a semi-definite programming in the model. The index of the constraint increases from 0. If you add a PsdConstr to the model at a time, the index increases. A PsdConstr is often expressed as a PsdExpr.

Properties

index

Index position of PsdConstr

index

Index position of PsdConstr

Methods

getAttr()

Obtain the attribute value corresponding to a PsdConstr

sameAs()

Test whether the PsdConstr and another PsdConstr are the same

setAttr()

Set the attribute value corresponding to the PsdConstr

getAttr(attrname)

Obtain the attribute value corresponding to a PsdConstr.

Parameters

attrname – Attribute name

example:

m = Model()
x = m.addPsdVar(dim = 2)
c = m.addConstr(x * numpy.identity(2) == 2, name="c0")
print(c.psdcname == "c0")
print(c.getAttr(MDO.Attr.PsdCName) == "c0")

Note

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

sameAs(constr)

Test whether the PsdConstr and another PsdConstr are the same

Parameters

constr – Another PsdConstr to be tested

example:

m = Model()
x = m.addPsdVar(dim = 2)
c = m.addConstr(x * numpy.identity(2) == 2)
print(c.sameAs(m.getPsdConstrs()[0]))
setAttr(attrname, attrvalue)

Set the attribute value corresponding to the PsdConstr.

Parameters
  • attrname – The name of the attribute.

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

example:

m = Model()
x = m.addPsdVar(dim = 2)
c = m.addConstr(x * numpy.identity(2) == 2, name = "x0")
c.setAttr(MDO.Attr.PsdCName, "c0")
print(c.psdcname)
c.psdcname = "c1"
print(c.psdcname)

Note

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