简体   繁体   中英

Block matrix with optimization variables in CVXPY

I want to build a block matrix that has the form

Q = [[A, B], [C, D]]

where each of the blocks A,B,C,D are the following matrices:

  • A is simply 2x2 identity matrix
  • B is the embdedding of a 2x1 vector b=(b_1,b_2) in the diagonal of the identity B = diag(b_1, b_2)
  • C is the transpose of B
  • D is the 2x2 identity myltiplied by some constant d , D = d*A

My optimization problem is min d such that Q >> 0 , that is PSD condition. I need help with this problem.

Confusions:

  1. I know how to make a 2x2 identity matrix using Numpy np.eye(2) . I am not sure if it makes sense to use it within my matrix Q .
  2. Furthemore, for b I define b = cvxpy.Variable((2,1)) . Then, I can also define its transpose as b_t = bT but how do I make this as a matrix B and C given there is no outer product? That is, I need to embed the elements of the vector in the diagonal of the matrix.
  3. Since d is the variable I minimize over I need to define it as d = cvxpy.Variable(1) . But then I cannot simply multiply it to the identity matrix in order to have diag(t,t) which I call T = t*np.eye(2) .

In general I cannot figure out if I need to first define the block matrix Q as Q = cvxpy.Variable((4,4)) or Q = cvxpy.Parameter((4,4)) and then having all terms from above use cvxpy.bmat to give it the precise form.

Any help appreciated.

You might get a better answer at other than a programming site. However in this case it's straightforword.

Since swapping two rows and (the same) two columns can be done by

M -> Q'*M*Q

where Q is a permutation matrix (and hence orthogonal), such a transformed matrix will be PSD iff the original is PSD.

If we write

M = ( 1  0  b1 0 )
    ( 0  1  0  b2)
    ( b1 0  d  0 )
    ( 0  b2 0  d )

and swap the middle two rows and columns we get

M = ( 1  b1 0 0  )
    ( b1 d  0 0  )
    ( 0  0  1 b2 )
    ( 0  0  b2 d )

And this matrix will be PSD iff the two blocks on the diagonal are PSD, iff

d > max( b1*b1, b2*b2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM