# How can i solve this problem caused by cvx solver?

My aim is to optimize R. However, when i want to limit R>0, there’re some wrong, which is
Disciplined convex programming error:
** Invalid constraint: {complex affine} <= {constant}**
I don’t know how to solve this problem. My code is as follows.

clc;clear;clear all;
% M0 = 20; %hole free 20 N1+N2+N2*(N1-1)
N = 100;
theta = -60:15:60;
K = length(theta);

%NESTED ARRAY
N1 = 4;
N2 = 4;
M0 = N2*(N1+1);
S_nested(1,1:N1) = 1:1:N1;
S_nested(1,N1+1:N1+N2) = N1+1:N1+1:N2*(N1+1); %N1+N2
S_nested = S_nested-1;
M = length(S_nested);

A = exp(1ipiS_nested.‘sin(thetapi/180)); %sqrt(1/M)
I = eye(M0);
S = I(S_nested+1,:); %R = SR0S.’
%S = I(S_nested+(M0+1)/2,:);

snr = 20;
s = randn(K,N);
x = As;
y = awgn(x,snr,‘measured’);
R_real = 1/N
(yy’);
z = (mysign(real(y))+1i
mysign(imag(y)))./sqrt(2); %sqrt(0.5)real(y)+1isqrt(0.5)*imag(y)
L = zeros(M0,M,M);
for i = 1:M0
for m = 1:M
for n= 1:M
if S_nested(m)-S_nested(n) == i-1 %hole-free
L(i,m,n) = 1;
end
end
end
end

cvx_solver sdpt3
cvx_begin
cvx_precision low
variable u(M0,1) complex
variable Y(M,N) complex
variable X(M,M) complex hermitian
variable Ww(M,M) complex hermitian
variable T(M,M) complex hermitian
variable FAI(M,M) complex hermitian
R = u(1)*reshape(L(1,:,:),M,M);
for i = 2:M0
R = R+u(i)*reshape(L(i,:,:),M,M)+u(i)‘reshape(L(i,:,:),M,M).’;
end
minimize trace(X)+trace(Ww)
subject to
R == semidefinite(M);
[X,eye(M);eye(M),Ww] == semidefinite(2
M);
real(z(:)).real(Y(:)) >= 0;
imag(z(:)).imag(Y(:)) >= 0;
[T,FAI;FAI,X] == semidefinite(2
M);
[eye(M),FAI;FAI,R] == semidefinite(2
M);
[eye(N),Y’;Y,T] == semidefinite(M+N);
cvx_end
obj1 = trace(X)+trace(Ww);

[E1,D1] = eig([T,FAI;FAI,X]);
[~,S1] = sort(diag(D1));
V = E1(:,S1(1:M));
[E2,D2] = eig([eye(M),FAI;FAI,R]);
[~,S2] = sort(diag(D2));
F = E2(:,S2(1:M));
[E3,D3] = eig([eye(N),Y’;Y,T]);
[~,S3] = sort(diag(D3));
G = E3(:,S3(1:M));

epsilon1 = 5e-5;
epsilon2 = 1e-7;
w = 10;
e1 = 1 ;
err = 1;
t = 1.5;
while (e1 >= epsilon1) || (err >= epsilon2)
% for k = 1:3
cvx_solver sdpt3
cvx_begin
cvx_precision low
variable u(M0,1) complex
variable Y(M,N) complex
variable X(M,M) complex hermitian
variable Ww(M,M) complex hermitian
variable T(M,M) complex hermitian
variable FAI(M,M) complex hermitian
variable e2
R = u(1)reshape(L(1,:,:),M,M);
for i = 2:M0
R = R+u(i)reshape(L(i,:,:),M,M)+u(i)'reshape(L(i,:,:),M,M).’;
end
minimize trace(X)+trace(Ww)+w
e2
subject to
R > 0;
[X,eye(M);eye(M),Ww] == semidefinite(2
M);
real(z(:)).real(Y(:)) >= 0;
imag(z(:)).imag(Y(:)) >= 0;
[T,FAI;FAI,X] == semidefinite(2
M);
[eye(M),FAI;FAI,R] == semidefinite(2
M);
[eye(N),Y’;Y,T] == semidefinite(M+N);
e2
eye(M)-V’[T,FAI;FAI,X]V == semidefinite(M);
e2
eye(M)-F’
[eye(M),FAI;FAI,R]F == semidefinite(M);
e2
eye(M)-G’*[eye(N),Y’;Y,T]*G == semidefinite(M);
e2 < e1;
cvx_end
obj2 = trace(X)+trace(Ww);
e1 = e2;

``````[E1,D1] = eig([T,FAI;FAI,X]);
[~,S1] = sort(diag(D1));
V = E1(:,S1(1:M));
[E2,D2] = eig([eye(M),FAI;FAI,R]);
[~,S2] = sort(diag(D2));
F = E2(:,S2(1:M));
[E3,D3] = eig([eye(N),Y';Y,T]);
[~,S3] = sort(diag(D3));
G = E3(:,S3(1:M));

err = abs(obj1-obj2);
obj1 = obj2;
w = t*w;
``````

end

In CVX, both sides of inequality constraints must be real http://cvxr.com/cvx/doc/dcp.html#constraints . http://cvxr.com/cvx/doc/dcp.html#constraints

The remedy to your problem depends on what you want the model to be.

If both sides of inequality constraints must be real, then how can I limit a complex hermitian toeplitz matrix to be semidefinite or definite in sdp mode?

That rule doesn’t apply to semidefinite constraints.
In sdp mode
`Matrix >= 0`
constrains the hermtitian matrix `Matrix` to be semidefinite.`

If I use Matrix >= 0 in sdp mode, it occurs error of “Disciplined convex programming error:
Invalid constraint: {complex affine} > {constant}”. But such error won’t happen when I used to do so in other sdp problem. I don’t understand what’s wrong.

Did you declare the matrix as hermitian?

If you still have a problem, show us a minimal complete reproducible problem, complete with input data, and showing error message.

You did not turn on sdp mode. Use `cvx_begin sdp` to turn it on, rather than `cvx_begin`.

1 Like

It works! Thank you for your help.