Error in satisfying constraints

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.

What is the largest magnitude negative element of pr you ever get? It is possible for pr elements to be slightly negative, such as -1e-9, due to solver tolerance. I ran the problem *(using CVXQUAD instead of CVX’s successive approximation method), and always got optimal pr element values of about 1e-7.

Note that you can simplify your code a little but by eliminating unnecessary for loops. For instance, you can use pr_max >= pr>=0 instead of the double for loop. Other for loops can also be eliminated by using MATLAB’s vectorized abilities.

I would like to appreciate you for kind reply. The minus result was at the range of -1e-9, that by changing the domain of pr, it is modified.
Best regards

That is feasible within solver tolerance. If you can not allow pr to be negative at all, then use the constraint pr >= small_number , where small_number might be something around 1e-6 or 1e-7 .

Thanks again for your reply.