Why is it that the optimization variables obtained by the CVX solver are the same as the feasible solutions as input to CVX, but the intermediate variables are not the same as the constants found using a similar method?Normally, the values that have been optimized by the CVX solver should be better, but the values I get are weird. Is there a problem with the function I’m using? Or is there something in the internal optimization process of CVX that is different from what I thought? The specific procedures and outputs are as follows:
function [O_theta,O_value] = BAlgorithm(hAU,hSU,HAS,hAE,hSE,hDTIU,HDTS,hDTEU,hDTDR,hSDR,hADR,…
wt,vt,pt,taut,thetat_,U_I,U_E,M,K,sigmaK2,N,eta,ET,RT,rho)
h_Bditheta = 1izeros(U_I,M);
g_kditheta = 1izeros(U_I,K);
psi_tidi = zeros(U_I,1);
for i = 1:U_I
h_Bditheta(i,: ) = hAU(i,:)+thetat_*diag(hSU(i,:))*HAS;
g_kditheta(i,: ) = hDTIU(i,:)+thetat_*diag(hSU(i,:))*HDTS;
wt_temp = wt;
wt_temp(:,i) = [];
psi_tidi(i) = sum(abs(h_Bditheta(i,:)*wt_temp).^2)+(abs(g_kditheta(i,:)).^2)*pt+sigmaK2;
end
hw = diag(h_Bditheta*wt);
h_Bdithetawdi = abs(hw).^2;
temp_di = h_Bdithetawdi./psi_tidi;
a_tauidi = log(1+temp_di);
b_tauidi = temp_di./(1+temp_di);
h_Bejtheta = 1i*zeros(U_E,M);
g_kejtheta = 1i*zeros(U_E,K);
for i = 1:U_E
h_Bejtheta(i,:) = hAE(i,:)+thetat_*diag(hSE(i,:))*HAS;
g_kejtheta(i,:) = hDTEU(i,:)+thetat_*diag(hSE(i,:))*HDTS;
end
g_lktheta = 1i*zeros(K,K);
g_Bktheta = 1i*zeros(K,M);
psi_tik = zeros(K,1);
psi_tek = zeros(K,1);
for i = 1:K
g_lktheta(i,:) = hDTDR(i,:)+thetat_*diag(hSDR(i,:))*HDTS;
g_Bktheta(i,:) = hADR(i,:)+thetat_*diag(hSDR(i,:))*HAS;
g_temp = g_lktheta(i,:);
g_temp(i) = [];
p_temp = pt;
p_temp(i) = [];
psi_tik(i) = (abs(g_temp).^2)*p_temp+sum(abs(g_Bktheta(i,:)*wt).^2)+sigmaK2;
psi_tek(i) = (abs(g_temp).^2)*p_temp+sum(abs(g_Bktheta(i,:)*vt).^2)+sigmaK2;
end
h_ktheta = diag(g_lktheta);
temp_tauik = ((abs(h_ktheta).^2).*pt)./psi_tik;
a_tauik = log(1+temp_tauik);
b_tauik = temp_tauik./(1+temp_tauik);
temp_tauek = ((abs(h_ktheta).^2).*pt)./psi_tek;
a_tauek = log(1+temp_tauek);
b_tauek = temp_tauek./(1+temp_tauek);
cvx_begin
variable theta(1,N) complex
expression h_Bditheta_v(U_I,M);
expression g_kditheta_v(U_I,K);
expression psi_tidi_v(U_I,1);
for i = 1:U_I
h_Bditheta_v(i,:) = hAU(i,:)+theta*diag(hSU(i,:))*HAS;
g_kditheta_v(i,:) = hDTIU(i,:)+theta*diag(hSU(i,:))*HDTS;
wt_temp = wt;
wt_temp(:,i) = [];
psi_tidi_v(i) = sum(pow_abs(h_Bditheta_v(i,:)*wt_temp,2))+pow_abs(g_kditheta_v(i,:),2)*pt+sigmaK2;
end
Rtauidi_v = a_tauidi+b_tauidi.*(2*ones(U_I,1)-h_Bdithetawdi.*inv_pos(2*real(diag(h_Bditheta_v*wt).*conj(hw))-...
h_Bdithetawdi)-psi_tidi_v./psi_tidi);
Omega_theta_v = 1/N-1*inv_pos(sum(2*real(conj(thetat_).*theta)-abs(thetat_).^2));
maximize(min((1/taut(1))*Rtauidi_v)+eta*Omega_theta_v)
subject to
max(pow_abs(theta,2)) <= 1;
expression h_Bejtheta_v(U_E,M);
expression g_kejtheta_v(U_E,K);
for i = 1:U_E
h_Bejtheta_v(i,:) = hAE(i,:)+theta*diag(hSE(i,:))*HAS;
g_kejtheta_v(i,:) = hDTEU(i,:)+theta*diag(hSE(i,:))*HDTS;
end
Etaueej_v = sum(2*real((h_Bejtheta_v*vt).*conj(h_Bejtheta*vt))-abs(h_Bejtheta*vt).^2,2)+...
(2*real(g_kejtheta_v.*conj(g_kejtheta))-abs(g_kejtheta).^2)*pt;
min(Etaueej_v) >= ET*taut(2)/rho;
expression g_lktheta_v(K,K);
expression g_Bktheta_v(K,M);
expression psi_tik_v(K,1);
expression psi_tek_v(K,1);
for i = 1:K
g_lktheta_v(i,:) = hDTDR(i,:)+theta*diag(hSDR(i,:))*HDTS;
g_Bktheta_v(i,:) = hADR(i,:)+theta*diag(hSDR(i,:))*HAS;
g_temp_v = g_lktheta_v(i,:);
g_temp_v(i) = [];
p_temp = pt;
p_temp(i) = [];
psi_tik_v(i) = pow_abs(g_temp_v,2)*p_temp+sum(pow_abs(g_Bktheta_v(i,:)*wt,2))+sigmaK2;
psi_tek_v(i) = pow_abs(g_temp_v,2)*p_temp+sum(pow_abs(g_Bktheta_v(i,:)*vt,2))+sigmaK2;
end
h_ktheta_v = diag(g_lktheta_v);
Rtauik_v = a_tauik+b_tauik.*(2*ones(K,1)-(abs(h_ktheta).^2).*inv_pos(2*real(h_ktheta_v.*conj(h_ktheta))-...
(abs(h_ktheta).^2))-psi_tik_v./psi_tik);
Rtauek_v = a_tauek+b_tauek.*(2*ones(K,1)-(abs(h_ktheta).^2).*inv_pos(2*real(h_ktheta_v.*conj(h_ktheta))-...
(abs(h_ktheta).^2))-psi_tek_v./psi_tek);
min((1/taut(1))*Rtauik_v+(1/taut(2))*Rtauek_v) >= RT;
cvx_end
psi_tidi_v
psi_tidi
O_theta = theta;
O_value = min((1/taut(1))*Rtauidi_v);
end
可行解所对应的目标函数值:+0.24719,
优化变量所对应的目标函数值:-3.43866e+07,