Hello, I have been working on an optimization problem which is related to Langrangian Duality methodand for its first step i need to adopt the optimization problem in CVX. I typed the code but the result seems to be pretty odd. I actually need the vector of lamda i’s as my output which i can replace in my problem. BUt i seem to be getting a final value only.

My CVX Matlab Code:

m = 32;

n= 50;

h= (randn(n,1)+1j*randn(n,1))*sqrt(0.5);

Q=h’*h;

cvx_begin

variable lamda(n,1) nonnegative

maximize(sum(lamda))

subject to

for j=1:n

eye(n)-sum(lamda*Q) >=0

end

cvx_end

`>= 0`

specifies semidefinite constraint only when in sdp mode, which your program is not in. Therefore, you have been specifying element-wise nonnegativity.

So either use

`cvx_begin sdp`

or

`== semidefinite(n)`

If the problem is solved to optimality, `lamda`

will be an n by 1 vector of the argmax.

Hi,

Actually I am looking for lamda to be a vector as an output not a single value. How can I get the lambda as a vector instead ?

CVX reports the optimal objective value as `cvx_optval`

, and the optimal argument value as `lamda, `

which is a vector because the declared variable `lamda`

is a vector. if you want something else, I don’t understand what that is.

Hi,

I want to mazimize the sum of lamda_i’s for all Q_i matrix. Q_1 is a matrix, Q_2 is a matrix and so on. In my code i have not been able to get Q_i. I only have one Q , when i print the result. I want to implement the optimization problem above whose picture I have attached earlier and the latest code is attached here.

Why did you use an unnecessary for-loop? If there’s only one Q, then there must be only one lamda, according to your first picture. But you wrote lamda(1,n) instead of lamda.

Actually, My optimization problem is :

Your difficulty is with MATLAB, not CVX.

```
Q = NaN(n,n,n);
for k = 1:n
Q(:,:,k) = <fill this in>
end
```

Then the CVX code:

```
Sum_lamdaQ = 0;
for k=1:n
Sum_lamdqaQ = Sum_lamndaQ + lamda(k)*Q(:,:,k);
end
eye(n) - Sum_lamdaQ >= 0
```