8.6.7. PsdVar

class PsdVar

Represents a positive semi-definite variable. PsdVar is a square matrix of plain variables. It implies a constraint, that is, its solution must be a positive semi-definite matrix. A PsdVar can be multiplied by the matrix to obtain a PsdExpr. For example:

x = model.addPsdVar(dim = 2, name = "x")
expr = x * numpy.identity(x.dim)

Properties

index

The index position of the psd variable

Methods

getAttr()

Obtain the attribute value of a psd variable

sameAs()

Test whether the psd variable is the same as another psd variable

setAttr()

Set the attribute value of a pds variable

getAttr(attrname)

Obtain the attribute value of a psd variable.

Parameters

attrname – Attribute name

example:

m = Model()
x = m.addPsdVar(dim = 1)
print(x.dim)
print(x.getAttr(MDO.Attr.Dim))

Note

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

sameAs(var)

Test whether the psd variable is the same as another psd variable.

Parameters

var – Another psd variable to be tested

Returns

A bool result

example:

m = Model()
x = m.addPsdVar(dim=1)
print(x.sameAs(m.getPsdVars()[0]))
setAttr(attrname, attrvalue)

Set the attribute value of a pds variable.

Parameters
  • attrname – The name of the attribute.

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

example:

m = Model()
x = m.addPsdVar(dim = 1)
x.setAttr(MDO.Attr.PsdVarName, "x0")
print(x.psdvarname == "x0")

Note

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