# The opimal solution can't satisfy constraints

this is my code,I don’t know why the the opimal solution can’t satisfy constraints

``````clc;
clear;
K=2;
Nt=3;
Nr=1;

h_11=sqrt(0.5)*(randn(Nt,Nr)+i*randn(Nt,Nr));  h_12=sqrt(0.5)*(randn(Nt,Nr)+i*randn(Nt,Nr)); h_21=sqrt(0.5)*(randn(Nt,Nr)+i*randn(Nt,Nr));
h_11=h_11/sqrt(norm(h_11)^2);                  h_12=h_12/sqrt(norm(h_12)^2);                 h_21=h_21/sqrt(norm(h_21)^2);
h_22=sqrt(0.5)*(randn(Nt,Nr)+i*randn(Nt,Nr));   g1=sqrt(0.5)*(randn(Nt,Nr)+i*randn(Nt,Nr)); g2=sqrt(0.5)*(randn(Nt,Nr)+i*randn(Nt,Nr));
h_22=h_22/sqrt(norm(h_22)^2);                   g1=g1/sqrt(norm(g1)^2);                      g2=g2/sqrt(norm(g2)^2);
I_th_db=-10;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%干扰门限
I_th=10^(I_th_db/10);
u1=2;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%加权因子
u2=1;
P=2;
SNR_db=5;
SNR=10^(SNR_db/10);
sigmma=1/SNR;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%噪声
r_12=0.01*sigmma;
r_21=0.01*sigmma;
epsilong=0.001;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CSI error bounds between the SBS and the SU
psi=0.01;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%psi   主用户信道误差
alpha=0.0001;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%迭代步长
belta=0.0001;
miu=0.0001;

elta=0.1;
tau=0.01;
q_12=0.01;
q_21=0.01;

t=0;
eps=1e-4;
tol=10;
while (tol>eps)
t=t+1;
cvx_begin
variable V1(3,3) hermitian
variables lammda_1 lammda_2 ommiga_1
maximize (trace(h_11*h_11'*V1))
subject to
[(-elta)*V1+lammda_1*eye(3),(-elta)*V1'*g1;(-elta)*g1'*V1,(-elta)*g1'*V1*g1+ommiga_1-lammda_1*psi]==hermitian_semidefinite(4);
theta_1=q_21;
h_1=q_21*h_21;
b_1=q_21*h_21'*V1*h_21-1+tau*trace(V1)+ommiga_1;
[theta_1*V1+lammda_2*eye(3),V1'*h_1;h_1'*V1,b_1-lammda_2*epsilong]==hermitian_semidefinite(4);
0<=ommiga_1<=1;
lammda_1>=0;
lammda_2>=0;
V1==hermitian_semidefinite(3);
cvx_end
[UR_1,SR_1,VR_1]=svd(V1);
v1=UR_1(:,1);
c_1=v1'*h_11*h_11'*v1;
p_1=max(u1/log(2)-(r_12+sigmma)/real(c_1),0);
w1=sqrt(p_1)*v1;
A_1=norm(w1)^2;
cvx_begin sdp quiet
variable V2(3,3) hermitian
variables lammda_3 lammda_4 ommiga_2
maximize (trace(h_22*h_22'*V2))
subject to
[(-elta)*V2+lammda_3*eye(3),(-elta)*V2'*g2;(-elta)*g2'*V2,(-elta)*g2'*V2*g2+ommiga_2-lammda_3*psi]==hermitian_semidefinite(4);

theta_2=q_12;
h_2=q_12*h_12;

b_2=q_12*h_12'*V2*h_12-1+tau*trace(V2)+ommiga_2;
[theta_2*V2+lammda_4*eye(3),V2'*h_2;h_2'*V2,b_2-lammda_4*epsilong]==hermitian_semidefinite(4);
0<=ommiga_2<=1;

lammda_3>=0;
lammda_4>=0;
V2==hermitian_semidefinite(3);
cvx_end
[UR_2,SR_2,VR_2]=svd(V2);
v2=UR_2(:,1);
c_2=v2'*h_22*h_22'*v2;
p_2=max(u2/log(2)-(r_21+sigmma)/real(c_2),0);
w2=sqrt(p_2)*v2
A_2=norm(w2)^2;
elta=max(elta+alpha*(I_th-(p_1*ommiga_1+p_2*ommiga_2)/elta),0);
q_12=max(q_12+belta*(r_12-norm(h_12'*w2)^2-epsilong*norm(w2)^2),0);
q_21=max(q_21+belta*(r_21-norm(h_21'*w1)^2-epsilong*norm(w1)^2),0);
tau=max(tau+miu*(P-norm(w1)^2-norm(w2)^2),0);
f(t+1)=tau;
tol=abs(f(t+1)-f(t));
end
``````

the optimal beamforming can’t meet the power constraint

I seriously doubt any of us would be able to debug this. All I would suggest is to check scaling. If you have extremely small values, for instance, that can confuse the solvers.