Error using logdet: A should be a square matrix of double or single class

Hello. I am trying to solve an optimization problem to maximize the following w.r.t ‘F’ while the rest of the terms in the expression are ‘rand’ initializations

logdet(eye(Ns) + HsSF*F’*S’*Hs’) + trace_inv(S)

I’ve rewritten the logdet expression as logdet(inv(Hs’Hs) + SF*F’*S’) <=> logdet(inv(H_s) + S_f),

where H_s = Hs’Hs, S_f = SF*F’*S’.

I am using CVX to solve the problem and since F is a variable declared in the CVX, I have that error from the title. Please help me find a solution to the problem and where I am wrong with it. Here is the code:

Nt        =      16;  
Ns       =      8;  

H         =      rand(Ns,Nt); 
P         =      0.1;    
S         =      kron([1 0], eye(Ns));   
H_s     =      (H*S')'*H*S';    % H_s = Hs'*Hs = S*H'*H*S'

cvx_begin 

variable S_f(Ns,Ns)  % S_f = S*F*F'*S'  => Sf = S*F = chol(S_f) => F =inv(S'*S)*S'*Sf 

Gmax  = logdet(inv(H_s) + S_f) +  trace_inv( S_f );  

minimize( -Gmax)
subject to
    norm((trace(S_f)-P),2) <= 1e-5;

cvx_end

The error is because you should be using log_det , not logdet;.

You need to declare S_f to be symmetric for trace_inv to work properly.

However, once you make those corrections, you are still in trouble, because you are adding log_det, which is concave, to trace_inv, which is convex.

I haven’t tried to dissect your reformulations for correctness. I will leave it to you to determine whether the actual problem of interest is a convex optimization problem.

1 Like

Thank you for your help. The log_det is concave but I am actually using -log_det for minimisation (which is convex, right?). Perhaps it wasn’t clear.

Either way, the second term ‘trace_inv(S_f)’ should actually have been ‘1/trace_inv(S_f)’, which apprantly is not an operation that cvx can perform?

cvx_begin

variable S_f(Ns,Ns) % S_f = SFF’S’ => Sf = SF = chol(S_f) => F =inv(S’*S)*S’*Sf

minimize(-log_det(inv(H_s) + S_f)-1/trace_inv( S_f ));
subject to
norm((trace(S_f)-P),2) <= 1e-5;
cvx_end

For a diagonal positive definite matrix X, 1/trace_inv(X) is the harmonic mean (other than factor of n), of the diagonal elements of X,. The harmonic mean s concave (previous version of this post misstated it as being convex), and is DCP-representable, as shown in section 3.2.7 Harmonic mean of https://docs.mosek.com/modeling-cookbook/cqo.html . So the link shows how to model it in CVX.

Edit: I have corrected this post from the original version.

1 Like

Thanks for your response. So what I have now in the form is 1/trace_inv(S_f) is not concave and that is why CVX cannot perform the operation? Could you please suggest a reformulation for this expression?

Appreciate your help!

Previous version of this post rendered irrelevant by the correction to my preceding post in this thread.

Edit: I have corrected this post.

1 Like