Code:
h = randn(N,1) + 1i*randn(N,1);
cvx_begin
variable U(N,N,K)
Ui = U(:,:,1);
phi = h' * Ui * h;
D = h * phi * h';
cvx_end
Error information:
Disciplined convex programming error:
Cannot perform the operation: {complex affine} .* {convex}
Error line:D = h * phi * h’;
I don’t know why you are getting that error. Here is what I get using CVX 2.2 (note I removed the semicolons so that CVX displays what each expression is).
N = 4; K = 3;
h = randn(N,1) + 1i*randn(N,1);
cvx_begin
variable U(N,N,K)
Ui = U(:,:,1)
phi = h' * Ui * h
D = h * phi * h'
Output:
Ui =
cvx real affine expression (4x4 matrix)
phi =
cvx complex affine expression (scalar)
D =
cvx complex affine expression (4x4 matrix)
Are you using CVX 3.0beta? If so, do not, because it is riddled with bugs which almost certainly will never be fixed. . Use CVX 2.2.
cvx_version
shows the CVX version.
Or maybe that is not really the statement sequence you ran when you got the error message? Try a new MATLAB session and enter only those statements, and see what happens.
Thanks for your suggestions!
However, the condition for variable U is missing in the previous code.
The code is as follows:
h = randn(N,1) + 1i*randn(N,1);
cvx_begin
variable U(N,N,K) hermitian semidefinite
Ui = U(:,:,1);
phi = h’ * Ui * h;
D = h * phi * h’;
cvx_end
Error information:
Disciplined convex programming error:
Cannot perform the operation: {complex affine} .* {convex}
Error line:D = h * phi * h’;
My output from that is
Ui =
cvx mixed real affine/complex affine expression (4x4 matrix)
phi =
cvx real affine expression (scalar)
D =
cvx complex affine expression (4x4 matrix)
The only difference from the previous output is for Ui
.
It would seem that something is screwed up with your MATLAB installation. Please show the output from cvx_version
. Perhaps you should remove all CVX directories (folders) from the MATLAB path, and then install CVX 2.2 in a new MATLAB session. Then try your program again.
Thank you for your suggestions. I will try to use the proposed method.
The code is as follows:
h = randn(N,1) + 1i*randn(N,1);
cvx_begin
variable U(N,N,K) hermitian semidefinite
Ui = U(:,:,1);
phi1 = h’ * Ui * h;
phi2 = pow_p(phi1,-1);
D = h * phi2 * h’;
cvx_end
Error information:
Disciplined convex programming error:
Cannot perform the operation: {complex affine} .* {convex}
Error line:D = h * phi2 * h’;
Moderator’s note: I have moved this into your existing thread on this matter
D
violates CVX rules. CVX can’t handle {imaginary}*{convex)
or {imaginary}*{concave)
because those are neither concave or complex.
If h
were real, CVX would accept D
.
With h
complex, CVX would accept real(RHS of D
if it is rearranged to D = real(h * h') * phi2
I don’t know what you intend to do with D
. So it is possible that the D
as is in your program, but never explicitly formed, might still be compatible with a DCP-compliant convex optimization problem. But that would require not forming D
, and proceeding directly to the way in which it is used, and seeing whether a DCP-compliant formulation can be created.
Your first step is to prove that your problem is a convex optimization problem. If not, CVX is not the right tool for it.
Thanks for your suggestions! I will check it.
Note that I am not suggesting you use real(h * h') * phi2
. I stated that CVX would accept it. That doesn’t mean that is the correct thing to do for your intended application, which I have no idea what it is, so I can’t say whether it is a “correct” thing to do.