Help! I need help!

hello, here is my code for Joint Cache Placement and Cooperative Multicast Beamforming in Integrated Satellite-Terrestrial Networks, I wonder why my code always end up nothing.
my version of cvx:2.2
When code goes to the next loop, it apears something like this:
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {positive constant}
temp=temp*inv_pos(x_nt0(n,tt));
QQ截图20230316201650

code:

%% Initial Parameter
N=14;           %users
F=30;          %Content
B=7;            %BSs
%Frequency
f0=2*10^9;      %center frequency
fb=10*10^6;     %subcarrier bandwidth
%Power
Pbmax_dBm=43;   Psmax_dBm=46;
%Antennas
Mb=2;Ms=4;      Gb_dBi=10;Gs_dBi=25;
n0=-174;        %-174dBm/Hz
xb=0.1;         %fraction cache capacity
mf=125*10^6;    %125MBytes
beta=0.005;     %trade-off parameter
T=20;          %transmission frames
types=4;            %preference types
lambda=1;       lambda_max=100; 
n0B=-104;           %dB
tt=1;            %t'=1
P_bmax=[10^(Pbmax_dBm/10),10^(Psmax_dBm/10),10^(Psmax_dBm/10),10^(Psmax_dBm/10),10^(Psmax_dBm/10),10^(Psmax_dBm/10),10^(Psmax_dBm/10),10^(Psmax_dBm/10)]';
%user_request Kt={ Knt }
F_t=UserRequest(types);
%formed group Gf,t
Group_num=zeros(T,1);
for t=1:T
    Group_num(t)=length(unique(F_t(:,t)));
end
Group_ft=zeros(N,F,T);
for t=1:T
    for f=1:N
        i=1;
        for n=1:N
            if(F_t(n,t)==F_t(f,t))
                Group_ft(i,F_t(f,t),t)=n;
                i=i+1;
            end
        end
    end
end

h_NBT=100*rand(N,B*Mb,T)+1i*rand(N,B*Mb,T);
g_NT=100*rand(N,Ms,T)+1i*rand(N,Ms,T);
h_NT=zeros(N,B*Mb,T)+1i*zeros(N,B*Mb,T);
h_NT=h_NBT;

d_NT=zeros(N,Ms+B*Mb,T)+1i*zeros(N,Ms+B*Mb,T);
d_NT=[g_NT,h_NT];
S_b=zeros(Ms+B*Mb,Ms+B*Mb,B+1);
for a=1:Ms
    for b=1:Ms
        S_b(a,b,1)=1;
    end
end
for b=2:B+1
    for a=Ms+(b-2)*Mb+1:Ms+(b-1)*Mb
        for c=Ms+(b-2)*Mb+1:Ms+(b-1)*Mb
            S_b(a,c,b)=1;
        end
    end
end

%% Algorithm 1
result=zeros(20,1);
%sigmaA<=sigma
sumA_flag=0;
while(sumA_flag==0)
A=0.1*rand(F,B+1);
sumA_flag=1;
    for b=1:B+1
        temp=sum(A(:,b));
        if(temp>F*0.1)
            sumA_flag=0;
        end
    end
end

c_t0=rand(F,B+1);
c_t0=double((c_t0>=0.01));
lambda=1;
mu=4;
lambda_max=100;
beta=0.005;
j_ft0=100*rand(F,Ms+B*Mb);
x_nt0=rand(N,1)+eps;

for index=1:8
    cvx_begin 
        variable c_t(F,B+1)
        variable j_ft(F,Ms+B*Mb) complex
        variable q_fbt(F,B+1)
        variable gama(F,1)
        variable x_nt(N,1)
        expression Power_Ball(B+1,1)
        expression Constraint_15(F,B+1)
        expression jS_ftb(F,B+1)
        expression djN(N,F)
        expression Constraint_17b(N,tt)
        calcu=0;
        for f=1:F
            if(sum(Group_ft(:,f,tt)~=0))
                calcu=calcu+f0*log(1+gama(f))/log(2);
            end 
        end
        for b=1:B+1
            for f=1:F 
                if(sum(Group_ft(:,f,tt)~=0))
                    calcu=calcu-beta*(c_t(f,b)*(1-A(f,b))*mf);
                end 
            end
        end
        for b=1:B+1
            for f=1:F
                if(sum(Group_ft(:,f,tt)~=0))
                    calcu=calcu-lambda*q_fbt(f,b);
                end 
            end
        end
        minimize -calcu
        subject to
          %constraint 11
          for b=1:B+1
              Power_Ball(b,tt)=0;
          end
        for b=1:B+1
            for f=1:F
               if(sum(Group_ft(:,f,tt)~=0))
                    Power_Ball(b,tt)=Power_Ball(b,tt)+pow_pos(norm(j_ft(f,:)*S_b(:,:,b),2),2);
                end       
            end
        end
        for b=1:B+1
            Power_Ball(b)<=P_bmax(b)
        end
         % constraint 15
            for b=1:B+1
                for f=1:N
                    Constraint_15(F_t(f,tt),b)=c_t(F_t(f,tt),b)^2-c_t(F_t(f,tt),b);
                    Constraint_15(F_t(f,tt),b)<=0
                end
            end
%             %constraint 16
                for b=1:B+1
                    for f=1:N
                        jS_ftb(F_t(f,tt),b)=norm(j_ft(F_t(f,tt),:)*S_b(:,:,b),2);
                        jS_ftb(F_t(f,tt),b)<=c_t(F_t(f,tt),b)*sqrt(P_bmax(b))
                    end
                end
            %constraint 17b          
                for n=1:N
                    for f=1:N
                        djN(n,F_t(f,tt))=norm(d_NT(n,:,tt)*j_ft(F_t(f,t),:)',2);
                    end
                    for f=1:N
                        for i2=1:F 
                            if(sum(Group_ft(:,i2,tt)~=0))
                                flag=0;
                                for i3=1:N
                                    if(Group_ft(i3,i2,tt)==f)
                                    flag=1;
                                    end
                                end
                                if(flag==0)
                                    Constraint_17b(n,tt)=Constraint_17b(n,tt)+djN(n,F_t(f,tt));
                                end
                            end
                        end
                    end
                    Constraint_17b(n,tt)=Constraint_17b(n,tt)+10^(n0B/10);
                    Constraint_17b(n,tt)<=x_nt(n)
                end
            %constraint 19
            for b=1:B+1
                for f=1:N
                    q_fbt(F_t(f,tt),b)>=0
                end
            end
            %constraint 20
                for b=1:B+1
                    for f=1:N
                        temp=0;
                        temp=c_t(F_t(f,tt),b)-(c_t0(F_t(f,tt),b)^2+2*(c_t0(F_t(f,tt),b))^2*(c_t(F_t(f,tt),b)-c_t0(F_t(f,tt),b)));
                        temp<=q_fbt(F_t(f,tt),b)
                    end
                end
            %constraint 21
            for n=1:N
                for f=1:F
                    temp=0;
                   if(sum(Group_ft(:,f,tt)~=0))
%                    2*real((d_NT(n,:,tt)'*d_NT(n,:,tt)*j_ft0(f,:)')'*j_ft(f,:)')*inv_pos(x_nt0(n,tt))-pow_pos(norm(d_NT(n,:,tt)*j_ft0(f,:)',2),2)*inv_pos(pow_pos((x_nt0(n,tt)),2))*x_nt(n,tt)>=gama(f,tt) 
%                     2*real((d_NT(n,:,tt)'*d_NT(n,:,tt)*j_ft0(f,:)')'*j_ft(f,:)')/x_nt0(n,tt)-pow_pos(norm(d_NT(n,:,tt)*j_ft0(f,:)',2),2)/pow_pos((x_nt0(n,tt)),2)*x_nt(n,tt)>=gama(f,tt)
                  temp=2*real((d_NT(n,:,tt)'*d_NT(n,:,tt)*j_ft0(f,:)')'*j_ft(f,:)');
                  temp=temp*inv_pos(x_nt0(n,tt));
                  temp1=pow_pos(norm(d_NT(n,:,tt)*j_ft0(f,:)',2),2);
                  temp1=temp1*inv_pos(pow_pos((x_nt0(n,tt)),2))*x_nt(n,tt);
                  temp-temp1>=gama(f,tt)
                   end       
                end
            end         
    cvx_end
    c_t0=double((c_t>=0.01));
    j_ft0=j_ft;
    x_nt0=x_nt+eps;
    lambda=min(mu*lambda,lambda_max);
    result(index)=calcu;
end

code UserRequest.m

function [outputArg1] = UserRequest(typesNum)
F=30;
N=14;
T=20;
K_t=zeros(N,T);
for t=1:T
pf=zeros(typesNum,F);
types=1+rand(typesNum,1);
j=1:F;
pj=j.^(-types);
typesrank=zeros(typesNum,F);
for i=1:typesNum
typesrank(i,:)=randperm(F);
end
for i=1:typesNum
pj(i,:)=pj(i,:)./sum(pj(i,:));
end

for i=1:typesNum
pf(i,1)=pj(i,1);
for k=2:F
pf(i,k)=pj(i,k)+pf(i,k-1);
end
end
User_need=randi(typesNum,N,1);
Kt=rand(N,1);
Ktneed=zeros(N,1);
for i=1:N
if(Kt(i)<pf(User_need(i),1))
Ktneed(i)=1;
continue;
end
for k=2:F
if(Kt(i)>pf(User_need(i),k-1)&&Kt(i)<pf(User_need(i),k))
Ktneed(i)=k;
break;
end
end
end
%disp(Ktneed);
Kt=zeros(N,1);
for i=1:N
Kt(i,1)=typesrank(User_need(i),Ktneed(i));
end
%disp(Ktfinal);
K_t(:,t)=Kt;
end
outputArg1 = K_t;
end

What is the value of x_nt0(? is that input data? if so, there is no reason to use pow_pos or inv_pos. Nevertheless, I don’t understand that error message.

Just prior to the error message, type temp at the command line. What does it show?

Thank you for replying my question!
The x_nt is the variable I want to solve, but I’m not so sure about if the x_nt need to be initialized as the figure Algorithm 1 shows, so i set the x_nt0 to make this algorithm 1 runs.
And if i use ‘/’,or’^2’,instead of pow_pos and inv_pos, it will turn out error like:
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {positive constant}
temp=temp*inv_pos(x_nt0(n,tt));

But even if i inv_pos,pow_pos, the error still turn out.
I saw someone said that is because the x_nt0 is close to zero.
So every loop when i update the x_nt0,i add 0.1 to x_nt0.
It will makes the error disappear but still unbounded.

And I try to note the whole Constraint 21,it shows just status unbounded and optimal value is +inf.
So maybe it seems that previous Constraints is ok?

By the way, i use the mosek, if i use SDPT3, the status may show failed.

You will have a better chance of getting useful help if you show a complete reproducible problem, with all input data, and show all solver and CVX output for both Mosek and SDPT3.

I am not familiar with Algorithm 1, but this forum is full of people using numerically unstable iterative algorithms, which instead of converging to the desired solution of the problem, result in subproblems (i,e. CVX problem instances) which are unbounded, infeasible, or horribly scaled numerically resulting in solver failure, any of which causes the algorithm to fail.

Thank you for replying me again!

I’m sorry about my negligence for not putting the code UserRequest.m.
Now I have updated the code with previous code. So you can try to run this code.

In SDPT3, using the code on the top
the first loop will turn out like:

Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------±--------------------------------±--------
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed

Status: Failed
Optimal value (cvx_optval): NaN

and the second loop will appear error:

Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {positive constant}
temp=temp*inv_pos(x_nt0(n,tt));

In Mosek. The first loop is

Problem status : PRIMAL_INFEASIBLE
Solution status : PRIMAL_INFEASIBLE_CER
Status: Unbounded
Optimal value (cvx_optval): -Inf

the second loop is the same as the SDPT3.
So I think maybe something wrong with x_nt0;

This Algorithm 1 is from “Joint Cache Placement and Cooperative Multicast Beamforming in Integrated Satellite-Terrestrial Networks” in IEEE, this paper this problem is NP-hard, the goal is to solve it in polynomial time. So i wonder if it is a key to my error.

It’s my honor to receive your help. I’m new in cvx.And I’m crazy about this result.

Use Mosek instead of SDPT3 for this problem.

You should show ALL the Mosek output.

Once one iteration has failed, the optimal variable values will be NaN, which if they become input data in the next iteration, will result in a CVX error message. CXV needs input values to be numbers, not NaN. How would you optimize NaN*x^2-5*x? Of course CVX can’t deal with that.

if the first iteration is unbounded, follow the advice at https://yalmip.github.io/debuggingunbounded .

I mistake the Mosek output.
Here it is. And i will spend sometime on your advice website.

Calling Mosek 9.1.9: 2612 variables, 1388 equality constraints
For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 62: The A matrix contains a large value of -1.5e+10 in constraint ‘’ (504) at variable ‘’ (767).
MOSEK warning 62: The A matrix contains a large value of -1.7e+10 in constraint ‘’ (504) at variable ‘’ (768).
MOSEK warning 62: The A matrix contains a large value of -1.0e+10 in constraint ‘’ (504) at variable ‘’ (770).
MOSEK warning 62: The A matrix contains a large value of -2.0e+10 in constraint ‘’ (504) at variable ‘’ (771).
MOSEK warning 62: The A matrix contains a large value of -1.1e+10 in constraint ‘’ (504) at variable ‘’ (772).
MOSEK warning 62: The A matrix contains a large value of -1.1e+10 in constraint ‘’ (504) at variable ‘’ (773).
MOSEK warning 62: The A matrix contains a large value of -1.8e+10 in constraint ‘’ (504) at variable ‘’ (774).
MOSEK warning 62: The A matrix contains a large value of -1.1e+10 in constraint ‘’ (504) at variable ‘’ (775).
MOSEK warning 62: The A matrix contains a large value of -1.9e+10 in constraint ‘’ (505) at variable ‘’ (776).
MOSEK warning 62: The A matrix contains a large value of -2.0e+10 in constraint ‘’ (505) at variable ‘’ (777).
Warning number 62 is disabled.
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1370).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1370).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1372).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1372).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1374).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1374).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1376).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1376).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1378).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1378).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1380).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1380).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1382).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1382).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1384).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1384).
MOSEK warning 52: A numerically large lower bound value -2.9e+09 is specified for constraint ‘’ (1386).
MOSEK warning 53: A numerically large upper bound value -2.9e+09 is specified for constraint ‘’ (1386).
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1388
Cones : 573
Scalar variables : 2612
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries : 1 time : 0.00
Lin. dep. - tries : 1 time : 0.02
Lin. dep. - number : 88
Presolve terminated. Time: 0.05
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1388
Cones : 573
Scalar variables : 2612
Matrix variables : 0
Integer variables : 0

Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 759
Optimizer - Cones : 503
Optimizer - Scalar variables : 1788 conic : 1509
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.01 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 1.88e+04 after factor : 4.83e+04
Factor - dense dim. : 0 flops : 5.74e+06
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 2.9e+09 5.6e+04 2.1e+10 0.00e+00 2.988190931e+05 -2.090729997e+10 1.0e+00 0.08
1 6.5e+08 1.3e+04 9.9e+09 -1.00e+00 1.544936362e+06 -2.090594716e+10 2.2e-01 0.17
2 4.4e+07 8.6e+02 2.6e+09 -1.00e+00 2.341500214e+07 -2.088395589e+10 1.5e-02 0.19
3 1.4e+07 2.8e+02 1.5e+09 -1.00e+00 7.147406496e+07 -2.083589576e+10 5.0e-03 0.19
4 3.2e+06 6.2e+01 7.0e+08 -1.00e+00 3.224263592e+08 -2.058494136e+10 1.1e-03 0.19
5 1.2e+05 2.4e+00 1.4e+08 -1.00e+00 8.531260156e+09 -1.237605990e+10 4.2e-05 0.20
6 2.5e+04 4.9e-01 6.2e+07 -1.00e+00 4.037315874e+10 1.946601820e+10 8.7e-06 0.20
Optimizer terminated. Time: 0.27

Interior-point solution summary
Problem status : PRIMAL_INFEASIBLE
Solution status : PRIMAL_INFEASIBLE_CER
Dual. obj: 1.6997490744e+05 nrm: 2e+00 Viol. con: 0e+00 var: 7e-06 cones: 0e+00
Optimizer summary
Optimizer - time: 0.27
Interior-point - iterations : 6 time: 0.22
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00


Status: Unbounded
Optimal value (cvx_optval): -Inf

I have read the advices, but the variables in the algorithm are so much. How can I find which one may be unbounded. And I don’t know what does the ALL Mosek results indicate?

Look at the values of all the input data in the objective function and constraints (note that values in the objective function you enter might be transformed by CVX into being in constraints provided to Mosek). Mosek warns about large magnitude values. You should try to change the units in your problem so that all input data is within a small number of orders of magnitude of one, certainly not e09 or e10.Then hopefully Mosek will issue no warnings, and then see what CVX reports the status as.

I don’t know whether this is the first optimization problem you ever tried to solve, but it is a complicated problem. You might be better off getting experience with simpler problems, and then trying more complicated problems once you know what you are doing on the simpler problems.

I change my input data within a small number of orders.
But mosek tells me a new errror.
I don’t understand what does the error mean.

MOSEK warning 62: The A matrix contains a large value of -8.9e+16 in constraint ‘’ (742) at variable ‘’ (613).
MOSEK warning 62: The A matrix contains a large value of -2.9e+17 in constraint ‘’ (742) at variable ‘’ (616).
MOSEK warning 62: The A matrix contains a large value of -9.6e+16 in constraint ‘’ (742) at variable ‘’ (617).
MOSEK warning 62: The A matrix contains a large value of -4.2e+17 in constraint ‘’ (742) at variable ‘’ (618).
MOSEK warning 62: The A matrix contains a large value of -4.3e+17 in constraint ‘’ (742) at variable ‘’ (619).
MOSEK warning 62: The A matrix contains a large value of -2.0e+18 in constraint ‘’ (743) at variable ‘’ (621).
MOSEK warning 62: The A matrix contains a large value of 1.1e+10 in constraint ‘’ (121) at variable ‘’ (624).
MOSEK warning 62: The A matrix contains a large value of -1.9e+19 in constraint ‘’ (743) at variable ‘’ (624).
MOSEK warning 62: The A matrix contains a large value of -1.9e+17 in constraint ‘’ (743) at variable ‘’ (625).
MOSEK warning 62: The A matrix contains a large value of 2.1e+10 in constraint ‘’ (21) at variable ‘’ (626).
Warning number 62 is disabled.
Mosek error: MSK_RES_ERR_HUGE_AIJ (A numerically huge value is specified for an element in A.)

Status: Error
Optimal value (cvx_optval): NaN

cite the ‘sol’ that’s not exist.

error cvx_mosek

error cvxprob/solve (line 429)
[ x, status, tprec, iters, y ] = shim.solve( At, b, c, cones, quiet, prec, solv.settings,
eargs{:} );

error cvx_end (line 88)
solve( prob );

error Algorithm1 (line 202)
cvx_end

Mosek refuses inputs above 1e+20. Anyway, the warnings should already tell you the model is completely broken, never mind the error. You cannot reasonably expect any solver to solve a problem with inputs of order 1e+15.

I make the input smaller than before.
But it turns out this error:

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1224
Cones : 413
Scalar variables : 1974
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries : 1 time : 0.00
Lin. dep. - tries : 1 time : 0.00
Lin. dep. - number : 150
Presolve terminated. Time: 0.03
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1224
Cones : 413
Scalar variables : 1974
Matrix variables : 0
Integer variables : 0

Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 661
Optimizer - Cones : 403
Optimizer - Scalar variables : 1419 conic : 1209
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.00 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 1.39e+04 after factor : 3.68e+04
Factor - dense dim. : 0 flops : 3.93e+06
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.4e+04 5.6e+01 1.0e+05 0.00e+00 4.580781881e+02 -1.045364999e+05 1.0e+00 0.06
1 3.6e+03 1.4e+01 5.2e+04 -1.00e+00 2.093635075e+03 -1.028839620e+05 2.5e-01 0.17
2 9.1e+02 3.5e+00 2.6e+04 -1.00e+00 1.052678873e+04 -9.439896446e+04 6.3e-02 0.19
3 1.7e+02 6.4e-01 1.1e+04 -9.99e-01 6.203017903e+04 -4.255415450e+04 1.1e-02 0.20
4 5.0e+01 1.9e-01 6.1e+03 -9.88e-01 2.022259200e+05 1.002386845e+05 3.5e-03 0.20
5 2.3e+01 8.8e-02 3.9e+03 -9.22e-01 3.792329136e+05 2.838718161e+05 1.6e-03 0.20
6 1.3e+01 5.1e-02 2.7e+03 -7.66e-01 5.213251006e+05 4.330757328e+05 9.2e-04 0.22
7 3.9e+00 1.5e-02 1.0e+03 -6.86e-01 9.296056164e+05 8.723499713e+05 2.7e-04 0.22
8 1.4e+00 5.3e-03 2.6e+02 2.67e-01 1.028227236e+06 1.002585033e+06 9.4e-05 0.22
9 8.1e-01 3.1e-03 1.7e+02 1.76e-01 1.139420127e+06 1.116420767e+06 5.6e-05 0.23
10 4.4e-01 1.7e-03 7.2e+01 5.34e-01 1.165401944e+06 1.151703372e+06 3.0e-05 0.23
11 2.3e-01 8.9e-04 3.3e+01 4.59e-01 1.204277257e+06 1.195468773e+06 1.6e-05 0.23
12 1.6e-01 6.3e-04 2.1e+01 5.06e-01 1.221367279e+06 1.214537052e+06 1.1e-05 0.25
13 7.5e-02 2.9e-04 8.6e+00 3.89e-01 1.258645946e+06 1.254547451e+06 5.2e-06 0.25
14 4.5e-02 1.7e-04 5.1e+00 2.60e-01 1.281498584e+06 1.278334847e+06 3.1e-06 0.25
15 3.4e-02 1.3e-04 3.6e+00 3.44e-01 1.295894247e+06 1.293318583e+06 2.3e-06 0.27
16 1.4e-02 5.4e-05 1.4e+00 2.17e-01 1.335118506e+06 1.333593265e+06 9.8e-07 0.27
17 3.4e-03 1.3e-05 3.5e-01 2.11e-01 1.399300866e+06 1.398724149e+06 2.4e-07 0.27
18 1.4e-03 5.4e-06 1.5e-01 9.94e-02 1.452827688e+06 1.452509334e+06 9.8e-08 0.27
19 7.7e-04 3.0e-06 7.6e-02 2.20e-01 1.470276533e+06 1.470085995e+06 5.3e-08 0.28
20 4.8e-04 1.9e-06 4.4e-02 3.04e-01 1.488529870e+06 1.488404273e+06 3.4e-08 0.28
21 1.5e-04 5.9e-07 1.3e-02 1.80e-01 1.533881573e+06 1.533881229e+06 1.1e-08 0.28
22 6.1e-05 2.3e-07 5.9e-03 8.13e-02 1.587823646e+06 1.587899690e+06 4.2e-09 0.30
23 1.9e-05 7.4e-08 1.6e-03 2.57e-01 1.632735545e+06 1.632813115e+06 1.3e-09 0.30
24 1.1e-05 4.3e-08 1.1e-03 -4.51e-02 1.669132773e+06 1.669275552e+06 7.7e-10 0.30
25 3.0e-06 1.1e-08 2.5e-04 1.18e-01 1.727935766e+06 1.728051897e+06 2.0e-10 0.31
26 8.9e-07 3.4e-09 9.6e-05 -5.49e-02 1.809487883e+06 1.809692416e+06 6.2e-11 0.31
27 2.6e-07 1.0e-09 2.1e-05 3.57e-01 1.850034813e+06 1.850147491e+06 1.8e-11 0.31
28 8.3e-08 3.2e-10 9.0e-06 3.73e-02 1.927757027e+06 1.927971775e+06 5.8e-12 0.33
29 3.4e-08 1.3e-10 2.9e-06 3.58e-01 1.961287166e+06 1.961425889e+06 2.3e-12 0.33
30 1.1e-08 4.3e-11 8.5e-07 3.20e-01 2.008867253e+06 2.008975152e+06 7.7e-13 0.34
31 4.6e-09 1.8e-11 5.3e-07 -7.42e-02 2.076899785e+06 2.077153722e+06 3.2e-13 0.34
32 2.0e-09 7.8e-12 1.9e-07 2.60e-01 2.109230809e+06 2.109403414e+06 1.4e-13 0.34
33 5.0e-10 1.9e-12 3.8e-08 2.92e-01 2.167932951e+06 2.168042309e+06 3.5e-14 0.36
34 1.1e-10 6.9e-13 1.1e-08 5.16e-02 2.257592294e+06 2.257769816e+06 7.7e-15 0.36
35 4.1e-11 7.9e-13 3.2e-09 3.39e-01 2.295147826e+06 2.295265793e+06 2.8e-15 0.36
36 3.3e-11 5.5e-13 2.3e-09 -5.47e-02 2.347439892e+06 2.347677063e+06 1.4e-15 0.38
37 1.8e-11 4.3e-13 1.4e-09 2.01e-01 2.364062680e+06 2.364262766e+06 9.4e-16 0.38
38 7.3e-12 6.3e-13 3.6e-10 2.33e-01 2.412292437e+06 2.412423652e+06 3.0e-16 0.39
39 6.0e-12 6.3e-13 2.3e-10 2.32e-01 2.432566956e+06 2.432688563e+06 1.9e-16 0.39
40 6.0e-12 6.3e-13 2.3e-10 2.01e-01 2.432583430e+06 2.432705032e+06 1.9e-16 0.41
41 3.8e-12 6.1e-13 1.4e-10 2.01e-01 2.453585094e+06 2.453700419e+06 1.2e-16 0.41
42 3.5e-12 5.3e-13 1.4e-10 1.73e-01 2.455805392e+06 2.455920282e+06 1.2e-16 0.42
43 3.5e-12 5.4e-13 1.3e-10 1.71e-01 2.458035985e+06 2.458150436e+06 1.1e-16 0.42
44 3.3e-12 4.4e-13 1.2e-10 1.69e-01 2.462640674e+06 2.462754213e+06 1.0e-16 0.44
45 2.6e-12 6.0e-13 7.2e-11 1.65e-01 2.484906923e+06 2.485016018e+06 6.4e-17 0.44
46 7.2e-13 3.0e-13 1.7e-11 1.48e-01 2.547380598e+06 2.547480197e+06 1.6e-17 0.45
47 7.2e-13 2.9e-13 1.7e-11 -1.20e-01 2.547496192e+06 2.547595945e+06 1.6e-17 0.47
48 7.1e-13 2.9e-13 1.7e-11 -1.20e-01 2.547503443e+06 2.547603205e+06 1.6e-17 0.47
49 7.1e-13 2.9e-13 1.7e-11 -1.20e-01 2.547619753e+06 2.547719669e+06 1.6e-17 0.48
50 6.9e-13 2.6e-13 1.6e-11 -1.20e-01 2.551660035e+06 2.551765249e+06 1.5e-17 0.50
51 6.7e-13 2.4e-13 1.6e-11 -1.17e-01 2.553894024e+06 2.554001562e+06 1.4e-17 0.50
52 6.3e-13 1.8e-13 1.3e-11 -1.15e-01 2.564400321e+06 2.564517599e+06 1.1e-17 0.52
53 5.8e-13 1.5e-13 1.2e-11 -1.00e-01 2.569741417e+06 2.569861659e+06 1.0e-17 0.53
54 5.8e-13 1.5e-13 1.2e-11 -9.19e-02 2.569818742e+06 2.569939018e+06 1.0e-17 0.55
55 5.8e-13 1.5e-13 1.2e-11 -9.18e-02 2.569818742e+06 2.569939018e+06 1.0e-17 0.56
56 5.8e-13 1.5e-13 1.2e-11 -7.10e-02 2.569838311e+06 2.569958593e+06 1.0e-17 0.56
57 5.8e-13 1.5e-13 1.2e-11 -7.09e-02 2.569840756e+06 2.569961040e+06 1.0e-17 0.59
58 5.8e-13 1.5e-13 1.2e-11 -7.09e-02 2.569843202e+06 2.569963486e+06 1.0e-17 0.59
59 5.8e-13 1.5e-13 1.2e-11 -7.09e-02 2.569848093e+06 2.569968379e+06 1.0e-17 0.61
60 5.8e-13 1.5e-13 1.2e-11 -7.09e-02 2.569850539e+06 2.569970825e+06 1.0e-17 0.63
Optimizer terminated. Time: 0.69

Interior-point solution summary
Problem status : ILL_POSED
Solution status : PRIMAL_ILLPOSED_CER
Dual. obj: 5.8195277957e-04 nrm: 5e+01 Viol. con: 0e+00 var: 2e-10 cones: 0e+00
Optimizer summary
Optimizer - time: 0.69
Interior-point - iterations : 61 time: 0.64
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00


Status: Failed
Optimal value (cvx_optval): NaN

I adjust some variable, mosek works in the first loop!
But i wonder why, i claim the variable x_nt nonnegative.
After mosek solve it, x_nt appears to be negative.
I wonder why?

What is the negative value? Solvers only guarantee to satisfy constraints to within a feasibility tolerance.

At the cvx_begin, I annouce the variable x_nt(N,1) nonnegative
at the cvx_end,x_nt turn out to be about -1e-12.
I think it is tolerant. But if x_nt is negative, I can’t use inv_pos in the next loop

-1e-12 is essentially zero. If you are using CVX in multiple iterations, then sometimes you have to yourself sanitize the data. Sorry.

I.e
after cvx_end
x = max(x,0);

or

instead of declaring nonnegative, use the constraint x >= 1e-6. Then the optimal value after cvx_end should be nonnegative.

Thank you!
I will try it later

I have also encountered unbounded after multiple iterations leading to cvx errors, please ask how to handle logarithms and if there is a guidance document