8.7.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
The index position of the PSD variable
- index¶
The index position of the PSD variable.
Methods
Obtain the attribute value of a PSD variable
Test whether the PSD variable is the same as another PSD variable
Set the attribute value of a PSD 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
Attributes 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 PSD 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
Attributes can also be read and written directly through object attributes; in this case, the attribute name is case-insensitive.