Error in maximizing Log_det of a symmetric matrix

*Here is my code:

variables Wc(n,n) symmetric
variables Z(n,n)
for i = 1:n
for j = 1:n
if(i ~= j)
Z(i,j) == 0;
Z(i,j) >= 0;
Z(i,j) <= 1;
sum(trace(Z)) == k;
Wc == semidefinite(n);
A * Wc + Wc * A’ + V * Z * V’ == 0;

%% The Cost Function which needs to be Maximized


with A being a random stable square matrix. I get this error message:

Error using det_rootn (line 28)
Matrix input 1 expected to be symmetric (deviation: 2).
— If this number is small (<1e-6), it may simply be due to roundoff error.
This can be corrected by applying the SYM(X) function.
— Otherwise, this is likely due to a modeling error. Did you declare the
relevant matrix variables to be “symmetric” or “hermitian”?

Error in log_det (line 27)
Error in ConvexRelaxation (line 33)

The matrix Wc is declared to be symmetric. can anybody help me figure out how to solve this problem.

Didn’t you get an error message from
variables Wc(n,n) symmetric
You declared a variable Wc(n,n), and a separate variable ‘symmetric’, which is illegal due to being a reserved word in CVX. You can use either
variable Wc(n,n) symmetric
variable Wc(n,n)
because your semidefinite constraint forces W to be symmetric.

Doing this, and using made up values for A, V, and k (I don’t know what A being “stable” means, maybe Hurwitz stable, but in any event I just picked a random non-Hurwitz stable A), the CVX program executed without error, but was infeasible with the A, V, and k I used.

Thanks for your help Mark!
You were right about declaring my variables. I made it right but now, I get a different error: Here is the new Code:


variable Wc(n,n) symmetric;
variable Z(n,n) diagonal;

diag(Z) >= 0;
diag(Z) <= 1;
Wc == semidefinite(n);
sum(trace(Z)) == k;
A * Wc + Wc * A’ + V * Z * V’ == 0;



and here is the error message:

Subscript indices must either be real positive
integers or logicals.

Error in cvx_extract (line 344)
tmpv = sum(dbcA(temp,:)~=0,2)==1;

Error in cvx_solve (line 26)
[ At, cones, sgn, Q, P, exps, dualized ] =
cvx_extract( shim.config, );

Error in cvx_finish (line 57)
[ status, result, bound, iters, tol ] = cvx_solve;

Error in cvx_end (line 11)
evalin( ‘caller’, ‘cvx_finish’ );

Error in ConvexRelaxation (line 38)

I changed the attribute of variable Z to diagonal instead of writing those if statement. In either case the error message is the same. Do you have any idea what’s wrong?

I ran this with the same inputs as before, and got the same result,i.e., with those inputs, the problem is infeasible.

You may have to wait for mcg to come around to diagnose your problem. It might be a good idea to post your OS, MATLAB version and CVX version/build in case they are relevant. Are you able to successfully run other problems with your CVX configuration?

This is my first program in CXV. I used the CVX version3 (the latest version) and my OS is Windows7 and I use MATLAB2015a.