Why is the status is failed?

The code is as follows.

%agent number
n=4;m=24;
p=[50.59205512;50.59205512;50.59205513;50.59205512;50.59205513;50.59205512;50.59205513;53.03751921;73.03751887;84.6356794;   95.23369543;103.9481443;105.4587746;99.37056138;79.37056149;79.68212899;99.68212889;98.73646955;110;89.99999999;70; 50.00000002;50;50;20;20;20;20;20;20;20;20;20.00000161;29.85432067;41.7063046;51.45185575;53.1412254;45.14943864;25.14943873;  25.49787121;45.49787113;45.62353047;60.20000001;40.20000002;20.20000003;20;20;20;41.86220746;41.86220746;41.86220746;41.86220746; 41.86220746;41.86220746;41.86220746;41.86220746;49.9999989;49.99999996;49.99999998;49.99999999;49.99999999;49.99999999;49.99999893;  49.99999892;49.99999999;49.99999999;50;41.77999998;44.29999995;33.77999997;15;15;-38.49426259;-33.72426259;-22.9542626;-37.45426259;   -27.4542626;-35.45426259;-32.4542626;-47.15972668;40.01248062;59.99999996;59.99999998;59.99999999;59.99999999;59.99999999;31.09000085;29.72000088;59.99999999;59.99999999;60;0;0;0;-9.400000001;-25.2];
r1= -0.1 + (0.1+0.1).*rand(1,n*m);
%DG参数
a1=0.02*h;a2=0.0175*h;a3=0.0625*h;a4=0.01*h;
a=[a1;a2;a3;a4];A=diag(a);
a5=2*h;a6=1.75*h;a7=1*h;a8=0*h;
B0=[a5;a6;a7;a8];
ef=3.1604,
kr=5.68;
ac1=0.00004*h;ac2=0.00005*h;ac3=0.000024*h;
ac=[ac1;ac2;ac3];AA=diag(ac);
BB0=[ac5;ac6;ac7];
% Create and solve problem (Centralized)
cvx_begin
variable c(n*m)
expression EP(n*m)
for i=1:96 
EP(i)=c(i)*r1(i);
end
f1=(p+EP)'*A*(p+EP)+B0'*(p+EP);
f2=kr*ef*((p(1:72)+EP(1:72))'*AA*(p(1:72)+EP(1:72))+BB0'*(p(1:72)+EP(1:72)));
f=0.4*f1+0.6*f2;
minimize( f )
cvx_end

When I run the code, it shows that

Calling SDPT3 4.0: 175 variables, 77 equality constraints

num. of constraints = 77
dim. of socp var = 172, num. of socp blk = 2
dim. of free var = 3 *** convert ublk to lblk


SDPT3: Infeasible path-following algorithms


version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime

0|0.000|0.000|4.8e+00|6.2e+00|6.0e+02| 3.737909e-04 0.000000e+00| 0:0:00| chol 1 1
1|1.000|0.983|1.6e-06|2.0e-01|1.1e+01|-2.237574e+00 -7.241914e+00| 0:0:01| chol 1 1
2|0.736|0.465|4.4e-07|1.1e-01|1.5e+00|-1.250421e+01 -7.523942e+00| 0:0:01| chol 1 1
3|0.268|0.314|4.7e-07|7.5e-02|1.2e+00|-2.019367e+01 -1.106884e+01| 0:0:01| chol 1 1
4|0.336|0.196|3.5e-07|7.3e-02|1.8e+00|-2.878321e+01 -1.384817e+01| 0:0:01| chol 1 1
5|1.000|0.225|2.6e-07|5.7e-02|1.0e+01|-2.833784e+01 -1.864175e+01| 0:0:01| chol 1 1
6|0.131|0.424|2.1e-07|3.3e-02|2.1e+01|-3.490489e+01 -3.886343e+01| 0:0:01| chol 1 1
7|0.147|0.185|1.8e-07|3.4e-02|1.8e+01|-6.391557e+01 -4.636748e+01| 0:0:01| chol 1 1
8|0.274|0.281|1.4e-07|2.4e-02|1.7e+01|-9.522920e+01 -5.974889e+01| 0:0:01| chol 1 1
9|0.248|0.115|1.0e-07|2.8e-02|2.3e+01|-1.281692e+02 -6.762897e+01| 0:0:01| chol 1 1
10|0.460|0.356|5.4e-08|1.8e-02|2.5e+01|-1.796346e+02 -1.021846e+02| 0:0:01| chol 1 1
11|1.000|0.231|2.1e-08|1.4e-02|9.8e+01|-1.483390e+02 -1.303753e+02| 0:0:01| chol 1 1
12|0.183|0.462|1.6e-08|7.4e-03|1.1e+02|-3.106137e+02 -2.648889e+02| 0:0:01| chol 1 1
13|0.444|0.282|8.3e-09|5.3e-03|5.7e+01|-5.629420e+02 -3.211569e+02| 0:0:01| chol 1 1
14|0.581|0.147|1.3e-07|6.5e-03|2.8e+02|-5.583770e+02 -3.870074e+02| 0:0:01| chol 1 1
15|0.231|0.492|4.3e-08|3.3e-03|3.5e+02|-8.783123e+02 -8.351483e+02| 0:0:01| chol 1 1
16|0.101|0.105|5.4e-08|4.4e-03|3.5e+02|-1.383128e+03 -9.432100e+02| 0:0:01| chol 1 1
17|0.695|0.231|2.1e-06|3.4e-03|5.4e+02|-2.131353e+03 -1.162998e+03| 0:0:01| chol 1 1
18|0.656|0.310|1.9e-06|2.3e-03|5.3e+02|-3.262993e+03 -1.672340e+03| 0:0:01| chol 1 1
19|0.606|0.409|2.0e-06|1.4e-03|5.4e+02|-4.201050e+03 -2.557893e+03| 0:0:01| chol 1 1
20|0.391|0.125|5.3e-05|1.7e-03|1.1e+03|-4.727274e+03 -2.901697e+03| 0:0:01| chol 1 1
21|0.423|0.328|1.0e-05|1.1e-03|1.0e+03|-7.115011e+03 -4.207730e+03| 0:0:01| chol 1 1
22|0.583|0.343|1.7e-05|7.4e-04|1.2e+03|-9.810566e+03 -5.867038e+03| 0:0:01| chol 1 1
23|0.636|0.307|7.4e-04|5.1e-04|2.4e+03|-1.096204e+04 -7.815033e+03| 0:0:01| chol 1 1
24|0.441|0.327|1.3e-03|3.4e-04|2.7e+03|-1.442158e+04 -1.037777e+04| 0:0:01|
stop: progress is too slow

number of iterations = 24
primal objective value = -5.62942040e+02
dual objective value = -3.21156867e+02
gap := trace(XZ) = 5.68e+01
relative gap = 6.42e-02
actual relative gap = -2.73e-01
rel. primal infeas (scaled problem) = 8.35e-09
rel. dual " " " = 5.28e-03
rel. primal infeas (unscaled problem) = 0.00e+00
rel. dual " " " = 0.00e+00
norm(X), norm(y), norm(Z) = 8.5e+04, 2.5e+02, 3.5e+02
norm(A), norm(b), norm© = 1.4e+01, 2.4e+00, 3.2e+00
Total CPU time (secs) = 1.07
CPU time per iteration = 0.04
termination code = -5
DIMACS: 1.0e-08 0.0e+00 1.2e-02 0.0e+00 -2.7e-01 6.4e-02


Status: Failed
Optimal value (cvx_optval): NaN

Although the status is failed, f1 and f2 can output value, I want to know why.

You did not provide all input data, so the problem is not reproducible by forum readers. (And of course you used rand).

Perhaps the input data is poorly scaled (numbers which are many orders of magnitude from one) - that could cause the solver to fail. A different solver might help. At least try sedumi. Try Mosek if you have it available, because that is the most numerically robust solver, and it provides the best warning and diagnostic information.

You should ignore any output value of f1 and f2 as being meaningless. Even if the problem had been solved, they might not contain correct values, as discussed in Why the value of expression is not equal to the assignment? .

I think the input data have been provided. So can you figure out the missing data??

No and no. I don’t even know the dimensions of the missing data, nor am I going to try to figure them out.

Clear the workspace and re-run your code, and you will see that not all input data was provided.

Hello, I find you are right. So I reupdate the code.

%agent number
n=4;m=24;h=ones(m,1);
p=[50.59205512;50.59205512;50.59205513;50.59205512;50.59205513;50.59205512;50.59205513;53.03751921;73.03751887;84.6356794;   95.23369543;103.9481443;105.4587746;99.37056138;79.37056149;79.68212899;99.68212889;98.73646955;110;89.99999999;70; 50.00000002;50;50;20;20;20;20;20;20;20;20;20.00000161;29.85432067;41.7063046;51.45185575;53.1412254;45.14943864;25.14943873;  25.49787121;45.49787113;45.62353047;60.20000001;40.20000002;20.20000003;20;20;20;41.86220746;41.86220746;41.86220746;41.86220746; 41.86220746;41.86220746;41.86220746;41.86220746;49.9999989;49.99999996;49.99999998;49.99999999;49.99999999;49.99999999;49.99999893;  49.99999892;49.99999999;49.99999999;50;41.77999998;44.29999995;33.77999997;15;15;-38.49426259;-33.72426259;-22.9542626;-37.45426259;   -27.4542626;-35.45426259;-32.4542626;-47.15972668;40.01248062;59.99999996;59.99999998;59.99999999;59.99999999;59.99999999;31.09000085;29.72000088;59.99999999;59.99999999;60;0;0;0;-9.400000001;-25.2];
 r1= -0.1 + (0.1+0.1).*rand(1,n*m);
%DG参数
a1=0.02*h;a2=0.0175*h;a3=0.0625*h;a4=0.01*h;
a=[a1;a2;a3;a4];A=diag(a);
a5=2*h;a6=1.75*h;a7=1*h;a8=0*h;
B0=[a5;a6;a7;a8];
ef=3.1604,
kr=5.68;
ac1=0.00004*h;ac2=0.00005*h;ac3=0.000024*h;ac5=0.2*h;ac6=0.3*h;ac7=0.12*h;
ac=[ac1;ac2;ac3];AA=diag(ac);
BB0=[ac5;ac6;ac7];
% Create and solve problem (Centralized)
cvx_begin
variable c(n*m)
expression EP(n*m)
for i=1:96 
EP(i)=c(i)*r1(i);
end
f1=(p+EP)'*A*(p+EP)+B0'*(p+EP);
f2=kr*ef*((p(1:72)+EP(1:72))'*AA*(p(1:72)+EP(1:72))+BB0'*(p(1:72)+EP(1:72)));
f=0.4*f1+0.6*f2;
minimize( f )
cvx_end

I ran it with two different rand number draws; (starting in new MATLAB session) For each draw, mosek was Inaccurate/solved, sedumi was Solved, sdpt3 was failed. With the first random number draw, mosek optimal objective = -18656.3, sedumi was -19190.5 . These optimal objective values are quite large in magnitude, which perhaps is contributing to the numerical difficulty. Perhaps rescaling the problem to make the optimal objective value ,much smaller in magnitude might help.

Here is the mosek output. I am a little surprised, because mosek reports status unknown, inknown, but CVX reported Inaccurate/solved instead of failed, as it seems to on other mosek unknown, unknown. Final primal objective is not very close to dual objective, and PRSTATUS is not that close to 1

MOSEK Version 9.3.16 (Build date: 2022-3-2 13:37:03)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 79              
  Cones                  : 2               
  Scalar variables       : 177             
  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 started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 2                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - number                 : 0               
Presolve terminated. Time: 0.08    
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 79              
  Cones                  : 2               
  Scalar variables       : 177             
  Matrix variables       : 0               
  Integer variables      : 0               

Optimizer  - threads                : 8               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 74
Optimizer  - Cones                  : 2
Optimizer  - Scalar variables       : 149               conic                  : 149             
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 : 2774              after factor           : 2775            
Factor     - dense dim.             : 0                 flops                  : 1.49e+05        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   0.0e+00  1.0e+00  1.0e+00  0.00e+00   3.901663256e-05   0.000000000e+00   1.0e+00  0.11  
1   2.2e-16  1.3e-01  1.6e-01  -4.44e-02  -2.741121610e+00  -1.690229249e+00  1.3e-01  0.28  
2   9.2e-16  2.1e-02  3.4e-02  -2.63e-01  -7.223598934e+00  -4.656208355e+00  2.1e-02  0.30  
3   9.2e-16  2.2e-03  6.2e-03  -3.91e-01  -1.973884942e+01  -1.159160378e+01  2.2e-03  0.30  
4   2.5e-15  4.1e-04  1.7e-03  -2.91e-01  -3.945633323e+01  -2.194704735e+01  4.1e-04  0.31  
5   2.2e-15  1.1e-04  4.3e-04  5.65e-02   -5.398589407e+01  -3.772207216e+01  1.1e-04  0.31  
6   7.8e-15  1.4e-05  1.1e-04  -3.98e-01  -1.327469674e+02  -7.685088014e+01  1.4e-05  0.33  
7   1.8e-15  4.3e-06  2.8e-05  2.30e-01   -1.632663005e+02  -1.220658715e+02  4.3e-06  0.33  
8   1.7e-14  9.7e-07  9.0e-06  -2.83e-01  -2.811296233e+02  -1.944140778e+02  9.7e-07  0.33  
9   1.4e-15  1.4e-07  1.8e-06  -3.37e-01  -5.394691510e+02  -3.671868506e+02  1.4e-07  0.34  
10  1.1e-14  3.2e-08  5.4e-07  -2.93e-01  -8.773649758e+02  -5.908124986e+02  3.2e-08  0.34  
11  2.3e-15  6.1e-09  1.4e-07  -3.00e-01  -1.499106406e+03  -1.008723639e+03  6.1e-09  0.36  
12  6.0e-14  1.1e-09  3.3e-08  -2.78e-01  -2.533846419e+03  -1.705431438e+03  1.1e-09  0.36  
13  1.0e-14  2.0e-10  8.3e-09  -3.28e-01  -4.640773511e+03  -2.924055372e+03  2.0e-10  0.37  
14  2.8e-15  5.0e-11  2.4e-09  -1.81e-01  -6.954133075e+03  -4.651250082e+03  5.0e-11  0.37  
15  8.1e-16  1.4e-11  7.7e-10  -2.06e-01  -1.017073583e+04  -6.918441876e+03  1.4e-11  0.39  
16  3.4e-16  3.5e-12  2.3e-10  -2.13e-01  -1.469630157e+04  -1.028792826e+04  3.5e-12  0.39  
17  1.6e-16  7.9e-13  5.6e-11  -1.02e-01  -2.026659364e+04  -1.531413303e+04  7.9e-13  0.41  
18  2.9e-16  2.2e-13  1.4e-11  4.62e-02   -2.454537866e+04  -2.023966140e+04  2.2e-13  0.41  
19  1.9e-16  1.4e-13  8.8e-12  4.45e-02   -2.624871410e+04  -2.195645828e+04  1.4e-13  0.42  
20  2.9e-16  1.1e-13  7.0e-12  1.32e-01   -2.690853552e+04  -2.280943984e+04  1.1e-13  0.44  
21  6.4e-17  2.3e-14  1.3e-12  1.77e-01   -3.057157187e+04  -2.789556691e+04  2.4e-14  0.44  
22  6.4e-17  2.3e-14  1.3e-12  6.51e-01   -3.057157187e+04  -2.789556691e+04  2.4e-14  0.45  
23  1.7e-16  2.2e-14  1.2e-12  6.51e-01   -3.058804252e+04  -2.796549931e+04  2.3e-14  0.45  
24  9.2e-17  1.3e-14  6.0e-13  6.54e-01   -3.087472104e+04  -2.915091627e+04  1.4e-14  0.45  
25  1.2e-16  1.3e-14  5.3e-13  7.28e-01   -3.087872291e+04  -2.916407447e+04  1.4e-14  0.47  
26  1.2e-16  1.3e-14  5.3e-13  7.29e-01   -3.087872291e+04  -2.916407447e+04  1.4e-14  0.48  
27  4.5e-17  1.0e-14  4.3e-13  7.29e-01   -3.101042498e+04  -2.959691012e+04  1.1e-14  0.48  
28  8.2e-17  1.0e-14  4.1e-13  7.69e-01   -3.101754145e+04  -2.961998854e+04  1.1e-14  0.50  
29  1.1e-16  8.0e-15  2.7e-13  7.71e-01   -3.113350736e+04  -2.999583411e+04  8.7e-15  0.50  
30  1.1e-16  8.0e-15  2.7e-13  8.09e-01   -3.113350736e+04  -2.999583411e+04  8.7e-15  0.52  
31  1.1e-16  8.0e-15  2.7e-13  8.09e-01   -3.113350736e+04  -2.999583411e+04  8.7e-15  0.52  
Optimizer terminated. Time: 0.62    


Interior-point solution summary
  Problem status  : UNKNOWN
  Solution status : UNKNOWN
  Primal.  obj: -3.1133507364e+04   nrm: 5e+08    Viol.  con: 6e-08    var: 0e+00    cones: 0e+00  
  Dual.    obj: -2.9995834111e+04   nrm: 3e+04    Viol.  con: 0e+00    var: 9e-07    cones: 0e+00  
Optimizer summary
  Optimizer                 -                        time: 0.62    
    Interior-point          - iterations : 32        time: 0.53    
      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: Inaccurate/Solved
Optimal value (cvx_optval): -18656.3

So how to change the problem should I according to your experience?

I don’t know. I have no idea what your model is trying to do, nor am I going to try to figure that out. You can pay attention to the units used in your program, and consider whether changing the units might result in smaller magnitude objective value. Presumably, you understand your problem better than i do

OK. I note that you say the optimal objective values are quite large in magnitude, which cause what influence? Is your meaning that magnitude can’t exceed the range of [-1e-4, 1e+4]?

I don’t have the magic solution to make everything in your problem wonderful. The units used in your problem can affect the objective value, so think about changing them.

Ok, thank you very much.

Looking at the log output it looks like your problem is ill-posed. Maybe it has nonzero duality gap, maybe the optimal solution has to be infinite or something else. Impossible to say.

I can see the norm of the primal solution is large.

A random ill-posed problem is

min 1/x, x>=0.

Note the optimal solution is x=inifinity.

Thank you, I will check the problem carefully.