# "cvx_status--unbounded cvx_optval--+Inf"

Dear everyone,
Does cvx can’t solve two related variables simultaneously?
I thought it was the problem and then I set another variable as given one using AO algorithm.
here’s my code.

``````function [Fi_opt,flag] = Generate_ES_Fi(N, M, K, H, G,...
W_ini, Fi_ini_ES, noise_maxpower, trans_maxpower)

cvx_begin %quiet
variable Fi(2,M) complex
%variable FI(M,M,K) hermitian
variable relax_scaler_D1(M,M,K) hermitian semidefinite
variable relax_scaler_D2(M,M,K) hermitian semidefinite

expressions    LMI(M+M+1,M+M+1,K)

W=W_ini;
k=1:1:K;
u=K:-1:1;
for i=1:length(k)
if k(i)==1||u(i)==1
a(k(i))=0.5;
%%%%%  Generate LMI %%%%%
LMI(M+M+1,M+M+1,K);
LMI(:,:,k(i))=[relax_scaler_D1(:,:,k(i)), FI(:,:,k(i)), Fi(k(i),:)';...
FI(:,:,k(i))', relax_scaler_D2(:,:,k(i)) ,Fi(k(i),:)';...
Fi(k(i),:), Fi(k(i),:) ,1 ];

Ty(k(i))=trace(relax_scaler_D1(k(i)))-2*trace(Fi(k(i),:)'*Fi_ini_ES(k(i),:))+trace(Fi_ini_ES(k(i),:)'*Fi_ini_ES(k(i),:));
end
end
maximize sum(a.*POLY)

subject to
k=1:K;
u=K:-1:1;
for i=1:length(k)
if k(i)==1 || u(i)==1

%              diag(FI(:,:,u(i))+FI(:,:,k(i)))==1;
LMI(:,:,k(i)) == hermitian_semidefinite(2*M+1);
real(Ty(k(i)))<=0;
real(relax_scaler_D1(:,:,k(i)))>=0;
real(relax_scaler_D2(:,:,k(i)))>=0;
%z(k)>=noise_maxpower;
end
end
cvx_end
``````

The results turns out:

The objective function is convex,the problem might be constrains.
I tried to eliminate variables to find out but failed.
Please someone give me a guide! gratefully thanks.

I have no idea whether your code is correct, because I don’t know what optimization problem you are trying to solve. Nor is your problem reproducible, because you have nor provided input data.

Nevertheless, try following the advice in https://yalmip.github.io/debuggingunbounded .

One thing you might try to do is start with a simpler, easier to understand model, get that working correctly, and then build up to the model you really want to solve.

So cvx can’t solve two variables?
I’m a beginner of cvx toolbox, what is the meaning of the results it shows?

input data :

`````` close all;
clear all;clc;
warning('off');

%% Parameters Initialization

N          = [3,6,6,10];            % array number of BS
M          = [10,10,20,30];            % array number of STAR-RIS
K          = 2;            % number of users
SNR_dB     = 10;     % dBW
%%%%% noise
N0=10^((-174-30) / 10); %-174dBm
B=10^7; %10MHz
% noise_maxpower_original   = N0*B;            % % W
noise_maxpower_original   = 10^((-80-30) / 10);
power_max_dBm=10;
%% Simulation loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
num_loop = 10;
% for i_p     = 1 : length(rate_min_dB)
%Rate=zeros(K,length(rate_min_dB),100);
for loop = 1 : num_loop
outerflag=1;
T1=cputime;
H=H_du_all(1:N,1:K,loop)/sqrt(noise_maxpower_original);%信道归一化
G=G_ru_all(1:M,1:N,1:K,loop)/sqrt(noise_maxpower_original);
noise_maxpower=1;
%%  For different       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('  loop | N | M | iteration \n');
for i_p     = 1 : length(N)

t0=cputime;
trans_maxpower=100 ;%trans_maxpower_all(i_p);
N=N(i_p);
M=M(i_p);
%%%%%  Initialize W and fi beamforming  %%%%%
%power_max=power_max_dBm(i_p);
a=0;b=2*pi;

%%%%%  Initialize Fi for different mode(ES,MS and TS )  %%%%%
Fi_temp=(b-a).*rand(2,M(i_p)) + sqrt(-1)*(b-a).*rand(2,M(i_p));
Fi_amp=rand(2,M(i_p));
Fi_ini_ES=Fi_amp.*exp(1j*angle(Fi_temp));
Fi_ini_eES=0.5*exp(1j*angle(Fi_temp));

W_ini=randn(N(i_p),K)*sqrt(trans_maxpower/(N(i_p)*K));
W(:,:,1)=full(W_ini);
Fi1(:,:,1)=full(Fi_ini_ES);%ESmode下的Fi迭代值
Fi2(:,:,1)=full(Fi_ini_eES);%equalESmode下Fi的迭代值

%disp('Proposed algorithm')
num_iterative = 20;
for n  = 1 : num_iterative
%%%%%  Optimize W  %%%%%
[W_1,rate_inf,flag_W] = Generate_ESMS_W(N, M, K, H, G,...
W(:,:,n), Fi1(:,:,n), noise_maxpower, trans_maxpower);
%F_1,power_sub,innerflag
W(:,:,n+1)=W_1;
rate(n+1)=rate_inf;
if flag_W==0
outerflag=0;
break;
end
%%%%%  Optimize fi  %%%%%
[Fi_1,flag_Fi] = Generate_ES_Fi(N, M, K, H, G,...
W_ini, Fi1(:,:,n), noise_maxpower, trans_maxpower);
Fi1(:,:,n+1)=Fi_1;
%FiE(:,n+1)=FiE_opt;
if flag_Fi==0
outerflag=0;
break;
end
%%%%%  stop criterion  %%%%%
fprintf('   %g  |  %g  |  %g  |  %g  \n',loop, N(i_p), M(i_p), n)
if abs(rate(n+1)-rate(n))<10^(-3) %精度为10^(-3)
break;
end
SumRate(loop,t,n)=rate_inf;
end
if outerflag==0
break;
end
end
end``````

CVX can handle any number of variables, unless it or the solver it calls runs out of memory.

You need to improve the scaling of the input data so that all non-zero input data is within a small number of orders of magnitude of one. Change the units to accomplish that. Otherwise you’ll cause havoc and unreliability in the solver.

I have changed the initial value of all variables within magnitude of 1.
and It still unbounded.
but the results indicate the problem might be convergence.

iteration 33-37 didn’t change value. does it mean convergence?

The solver, Mosek, reported the problem is primal infeasible. But presumably, Mosek was provided the dual by CVX, so this corresponds to your original problem (primal) being unbounded.

Please show all the solver and CVX output. Did Mosek issue any warnings about data being large or nearly zero? If the numerics are good, and Mosek didn’t issue any warnings, then you should follow the advice in the link in my first post. Try removing the objective and see what happens. Try with the objective, but placing finite lower and upper bounds on all variables, and see which variables end up on a bound at the optimal solution.

You cut the log output off just where it would get interesting: the residuals would indicate how good the certificate is. Maybe check that and consult https://docs.mosek.com/latest/toolbox/debugging-log.html#solution-summary

The huge objective value may indicate problems with convergence. Ie. it may be that your original problem has an optimal solution but it is so far away it is practically unbounded. That’s just a guess.

Thank you so much ,Mark.
I have handled this problem by restraining initial variables.And for god’s sake,it outputs the correct answer.

*** convert ublk to linear blk

SDPT3: homogeneous self-dual path-following algorithms

## number of iterations = 23 primal objective value = -1.16231399e+03 dual objective value = -1.16231395e+03 gap := trace(XZ) = 5.60e-07 relative gap = 4.81e-10 actual relative gap = -1.73e-08 rel. primal infeas = 4.05e-10 rel. dual infeas = 7.27e-10 norm(X), norm(y), norm(Z) = 3.1e+03, 9.1e+02, 1.0e+03 norm(A), norm(b), norm© = 2.5e+03, 1.0e+03, 3.4e+02 Total CPU time (secs) = 0.37 CPU time per iteration = 0.02 termination code = 0 DIMACS: 4.1e-10 0.0e+00 7.3e-10 0.0e+00 -1.7e-08 2.4e-10

Status: Solved
Optimal value (cvx_optval): +2333.86

Calling SDPT3 4.0: 248 variables, 116 equality constraints