# How to solve the problem in mosek?

Now I have a convex optimization problem. Furthermore, I try to solve it by mosek, where Mosek display is “Reference to non-existent field ‘sol’. How to solve this problem?
Here is my code:
clear all;
clc;
clear all;
clc;
para.Nt=4;
para.M=20;
para.UserN=3;
para.Power1=10^(0.1*(30-30));
para.Power2=0.1;
para.NoisePower1=10^(0.1*(-80-30));

theta=ones(para.M,1);
[Channel_BU,Channel_BI,Channel_IU]=Generate_Channel(para);

Channel=zeros(para.Nt,para.UserN);
for k=1:para.UserN
Channel(:,k)=(Channel_BU(:,k)’+Channel_IU(:,k)’*diag(theta)*Channel_BI)’;
Channel(:,k)=Channel(:,k)/sqrt(para.NoisePower1);
end
clear k;
[wc0,wp0]=Active_RIS_Initial_Parameter_RSMA(para,theta,Channel_BI,Channel_BU,Channel_IU);

gamma_p0=zeros(1,para.UserN);
rate_p0=zeros(1,para.UserN);
for k=1:para.UserN

``````temp1=1+norm(Channel_IU(:,k)'*diag(theta),'fro')^2;
for j=1:para.UserN
if j~=k
temp1=temp1+square_abs(Channel(:,k)'*wp0(:,j));
end
end
clear j;

temp2=square_abs(Channel(:,k)'*wp0(:,k));
gamma_p0(1,k)=temp2/temp1;

rate_p0(1,k)=log(1+gamma_p0(1,k))/log(2);
``````

end
clear k;

gamma_c0=zeros(1,para.UserN);
rate_c0=zeros(1,para.UserN);
for k=1:para.UserN

``````temp11=1+norm(Channel_IU(:,k)'*diag(theta),'fro')^2;
for j=1:para.UserN
temp11=temp11+square_abs(Channel(:,k)'*wp0(:,j));
end
clear j;

temp22=square_abs(Channel(:,k)'*wc0);
gamma_c0(1,k)=temp22/temp11;

rate_c0(1,k)=log(1+gamma_c0(1,k));
``````

end
clear k;
temp111=min(rate_c0);
c0=zeros(1,para.UserN);
for k=1:para.UserN
c0(1,k)=max([temp111/para.UserN,0]);
end
clear k;

Initial_Value=min(rate_p0+c0);
Record1=[Initial_Value];

Max_Times=10;
Flag1=1;
Flag2=1;
Counter=0;
while Flag1
Counter=Counter+1;

``````cvx_begin quiet
cvx_expert true
cvx_solver mosek
variable wp(para.Nt,para.UserN) complex
variable wc(para.Nt,1) complex
variable gamma_p(1,para.UserN)
variable gamma_c(1,para.UserN)
variable c(1,para.UserN)
variable tao1
variable a1(1,para.UserN)

tao1>=0;
for k=1:para.UserN
c(1,k)>=0;
a1(1,k)>=0;
end
clear k;

temp3=[wc];
for k=1:para.UserN
temp3=[temp3;wp(:,k)];
end
clear k;
norm(temp3,'fro')<=sqrt(para.Power1);

temp4=para.NoisePower1*norm(theta,'fro')^2+square_pos(norm(diag(theta)*Channel_BI*wc,2));
for k=1:para.UserN
temp4=temp4+square_pos(norm(diag(theta)*Channel_BI*wp(:,k),2));
end
clear k;
temp4<=para.Power2;

%% 约束(1C-1)
for k=1:para.UserN
gamma_c(1,k)>=power(2,sum(c,2))-1;
end
clear k;

%% 约束(1C-B-1)
for k=1:para.UserN

temp5=1+norm(Channel_IU(:,k)'*diag(theta),'fro')^2;
for i=1:para.UserN
temp5=temp5+square_abs(Channel(:,k)'*wp(:,i));
end
clear i;

(2*real(wc0'*Channel(:,k)*Channel(:,k)'*wc))/(gamma_c0(1,k))-...
(square_abs(Channel(:,k)'*wc0)/(gamma_c0(1,k))^2)*...
gamma_c(1,k)>=temp5;
end
clear k;

%% 约束(2D-1)
for k=1:para.UserN
c(1,k)+a1(1,k)>=tao1;
gamma_p(1,k)>=power(2,a1(1,k))-1;
end
clear k;

%% 约束(2-d-2-1)
for k=1:para.UserN

temp6=1+norm(Channel_IU(:,k)'*diag(theta),'fro')^2;
for i=1:para.UserN
if i~=k
temp6=temp6+square_abs(Channel(:,k)'*wp(:,i));
end
end
clear i;

(2*real(wp0(:,k)'*Channel(:,k)*Channel(:,k)'*wp(:,k)))/(gamma_p0(1,k))-...
(square_abs(Channel(:,k)'*wp0(:,k))/(gamma_p0(1,k))^2)*...
gamma_p(1,k)>=temp6;
end
clear k;

maximize(tao1)
cvx_end

if cvx_status(1)=='S'  ||  cvx_status(3)=='a'
Updated_wp=wp;
Updated_wc=wc;
Updated_gammap=gamma_p;
Updated_gammac=gamma_c;
Updated_Value=tao1;
else
Flag2=0;
break;
end

Record1=[Record1,Updated_Value];

if Counter>=Max_Times
Flag1=0;
Final_wp=Updated_wp;
Final_wc=Updated_wc;
Final_gammap=Updated_gammap;
Final_gammac=Updated_gammac;
else
wc0=Updated_wc;
wp0=Updated_wp;
gamma_c0=Updated_gammac;
gamma_p0=Updated_gammap;
Initial_Value=Updated_Value;
end
``````

end

function [Channel_BU,Channel_BI,Channel_IU]=Generate_Channel(para)

x_BS=0;
y_BS=0;

x_RIS=30;
y_RIS=10;

x_User=zeros(1,para.UserN);
y_User=zeros(1,para.UserN);
r=5;
for k=1:para.UserN
x_User(1,k)=35+2randr;
y_User(1,k)=-5+2randr;
end
clear k;

d_BI=sqrt((x_BS-x_RIS)^2+(y_BS-y_RIS)^2);

d_BU=zeros(1,para.UserN);
d_IU=zeros(1,para.UserN);
for k=1:para.UserN
d_BU(1,k)=sqrt((x_BS-x_User(1,k))^2+(y_BS-y_User(1,k))^2);
d_IU(1,k)=sqrt((x_RIS-x_User(1,k))^2+(y_RIS-y_User(1,k))^2);
end
clear k;
PL_BI=sqrt(1e-3d_BI^(-2));
PL_BU=zeros(1,para.UserN);
PL_IU=zeros(1,para.UserN);
for k=1:para.UserN
PL_BU(1,k)=10^(-3)
(d_BU(1,k))^(-4);
PL_BU(1,k)=sqrt(PL_BU(1,k));

``````PL_IU(1,k)=10^(-3)*(d_IU(1,k))^(-4);
PL_IU(1,k)=sqrt(PL_IU(1,k));
``````

end
clear k;
Channel_BI=(randn(para.M,para.Nt)+1irandn(para.M,para.Nt))/sqrt(2);
Channel_BI=PL_BI
Channel_BI;

Channel_BU=zeros(para.Nt,para.UserN);
Channel_IU=zeros(para.M,para.UserN);
for k=1:para.UserN
Channel_BU(:,k)=(randn(para.Nt,1)+1i*randn(para.Nt,1))/sqrt(2);
Channel_BU(:,k)=PL_BU(1,k)*Channel_BU(:,k);

``````Channel_IU(:,k)=(randn(para.M,1)+1i*randn(para.M,1))/sqrt(2);
Channel_IU(:,k)=PL_BU(1,k)*Channel_IU(:,k);
``````

end
clear k;
end

function [wc,wp]=Active_RIS_Initial_Parameter_RSMA(para,theta0,Channel_BI,Channel_BU,Channel_IU)

Noise_Power=10^(0.1*(-90-30));

Channel_U=zeros(para.Nt,para.UserN);
for k=1:para.UserN
Channel_U(:,k)=(Channel_IU(:,k)’*diag(theta0)*Channel_BI+Channel_BU(:,k)’)’;
Channel_U(:,k)=Channel_U(:,k)/sqrt(Noise_Power);
end
clear k;

gamma_p=0.001;
gamma_c=0.001;
cvx_begin quiet
cvx_solver mosek %sdpt3
cvx_expert true
variable wc(para.Nt,1) complex
variable wp(para.Nt,para.UserN) complex
variable ss1(1,para.UserN)
variable ss2(1,para.UserN)

for k=1:para.UserN
0<=ss1(1,k)<=100;
0<=ss2(1,k)<=100;
end
clear k;

for k=1:para.UserN
end
clear k;
temp1<=para.Power1;

temp2=para.NoisePower1*norm(theta0,2)^2+…
for k=1:para.UserN
end
clear k;
temp2<=para.Power2;

for k=1:para.UserN
imag(Channel_U(:,k)’*wp(:,k))==0;

``````temp3=[sqrt((para.NoisePower1/Noise_Power)*norm(Channel_IU(:,k)'*diag(theta0),2)^2)];
for j=1:para.UserN
if j~=k
temp3=[temp3,Channel_U(:,k)'*wp(:,j)];
end
end
clear j;
real(Channel_U(:,k)'*wp(:,k))/sqrt(2^(gamma_p)-1)+ss1(1,k)>=norm(temp3,'fro');
``````

end
clear k;

for k=1:para.UserN
imag(Channel_U(:,k)’*wc)==0;

``````temp4=[sqrt((para.NoisePower1/Noise_Power)*norm(Channel_IU(:,k)'*diag(theta0),2)^2)];
for j=1:para.UserN
``````

% if j~=k
temp4=[temp4,Channel_U(:,k)’*wp(:,j)];
% end
end
clear j;
real(Channel_U(:,k)’*wc)/sqrt(2^(gamma_c)-1)+ss2(1,k)>=norm(temp4,‘fro’);
end
clear k;

minimize(sum(ss1,2)+sum(ss2,2))
cvx_end
end

What is the output from
`mosekdiag`

Does it end with

Test linear solve: Success
mosekopt works OK. You can use MOSEK in MATLAB.

If so, maybe the MAYLAB session or the CVX installation are corrupted. Try a new MATLAB session. Try reinstalling CVX (make sure you are using CVX 2.2, not CVX 3.0beta)… Try rebooting the computer. Try a different solver.

Thank you very much. Sometimes, Mosek display is “Reference to non-existent field ‘sol’, not always. When i use other solver, i.e, SDPT3, this error is not occured.

See

and