I have simulated my optimization problem. My constraints are as follows:

Let pr is a matrix n×m. Each element of pr should be >=0, also sum of each column of pr should be less than pr_max.

The status is ‘solved’ but sometimes some elements of pr are negative.

I trace my problem but I cannot understand what is wrong. I will appreciate you if advise me.

My code is as follows:

M=3;

N=3;

K=8;

landa=3.96e6;

N0=10^-9;

Bw=1;%00e6;

R_rrh_min=0;

user_per_rrh=zeros(1,M);

for m=1:M

user_per_rrh(m)=K;

end

E0=1;

pr_max=[1 1 1];

rrh_fad=rand(N,M);

alfa_old=[.5 .5 .5];

cvx_begin

variables pr(N,M)

cnr=rrh_fad./(N0*Bw);

% tr=log(1+cnr.*pr);

tr = -rel_entr(ones(N,M),1+cnr.*pr);

r_rrh=cvx(zeros(N,M));

objfunc=cvx(zeros(N,K,M));

for m=1:M

r_rrh(:,m)=((1-alfa_old(m))*tr(:,m));

end

maximize sum(sum(r_rrh))-(landa*sum(sum(pr)))

subject to

for m=1:M

for n=1:N

pr_max >= pr(n,m)>=0;

end

end

%constraint for the power of the rrh

for m=1:M

sum(pr)-pr_max(m) <=0;

end

%constraint for the rate of the rrh

for m=1:M

temp1=sum(tr,1);

R_rrh_min-temp1(:,m) <=0;

end

pr>=0;

cvx_end

Thanks.