Dear expert
The Matlab CVX code is as follows:
N = 8 ;
K= 3 ;
cvx_begin
variables U(N,N,K) hermitian_semidefinite
maximize (objective function)
subject to
for k = 1:K
U(:,:,k) = hermitian_semidefinite(N) ;
end
other constraints
cvx_end
My problem is as follows:
If I declare that the variable U is a semidefinite Hermitian matrix when creating it, such as ‘variables U(N,N,K) hermitian_semidefinite’, do I need to add constraint condition ‘U(:,:,k) = hermitian_semidefinite(N) ;’ under ‘subject to’ ?
No.
variables U(N,N,K) hermitian semidefinite
constrains each slice, variables U(:,:,k)
for each k to be hermitian semidefinite
Per the CVX Users’ Guide, you should be specifying variables hermitian semidefinite
, not variables hermitian_semidefinite
. The underscore is only used when on the right-hand side of ==
.
Also note that you need
U(:,:,k) == hermitian_semidefinite(N) ;
not
U(:,:,k) = hermitian_semidefinite(N) ;
It may be faster to use variables U(N,N,K) hermitian_semidefinite
than for loop, because for loop is avoided.
Thank you!
I just realized that there was a mistake in the code sample for the question.
Do you mean I should only use ‘variables U(N,N,K) hermitian semidefinite’, and remove the constraint ‘U(:,:,k) == hermitian_semidefinite(N)’ ?
That is what I mean.
Except I discovered yet another error. you need to use variable
, not variables
when declaring properties of a variable.
Please re-read the CVX Users’ Guide, because you are making lots of little mistakes.
Just to be clear, your original statement
variables U(N,N,K) hermitian_semidefinite
actually declares two variables:
U(N,N,K)
and
hermitian_semidefinite
The first of those is an array with no special properties, and the second is s scalar. Of course, that is not what you wanted.