1

For example, I declare a vector variable x = cvxpy.Variable(5). I want to enforce a constraint on such symmetric matrix,

[
[x[0], 0, 0, x[1]],
[0 , x[2], 0, 0],
[0 , 0, x[3], 0],
[ x[1], 0, 0, x[4] ]
]

to be semi-positive definite.

I know that in MatLAB, I can declare an expression holder, like "expression A(5,5)", then assign each element in A, then use "A==semidefinite(5)" when declaring the constraint. How should I do it in python with cvxpy?

Zhong Guo
  • 11
  • 2

1 Answers1

0

You can declare a symmatrix matrix directly:

A=cvxpy.Variable((5,5), symmetric=True)

and then enforce the zeros and the relevant places. It's equal to define a vector first (as you did) and then build a matrix from that.

To add a constraint of semi-positive definite: constraints = [X >> 0]

See more details in the documentation

Roim
  • 2,986
  • 2
  • 10
  • 25