How to solve a convex optimization problem with the solution state of 'Failed' using cvx


cvx_begin quiet
    variable V(N+1,N+1) hermitian
    variable q
    variable phi
    expression sum_trace_BV
    expression sum_trace_RV
    
    sum_trace_BV = 0;
    for k = 1:K
        sum_trace_BV = sum_trace_BV + real(trace(B(:,:,sic_order(k))*V));
    end
    
    maximize q
    subject to
    %constrain14e
        Gamma_k <= q;
        %约束20  Tr(R_k_K*V) + |h_k_K|^2 <= ... <= Tr(R_k_1*V) + |h_k_1|^2 k in K
        for k = 1 : K
            for j = 1 : K - 1
                real(trace(R(:,:,(k-1)*K+j)*V))+norm(h_k_j((k-1)*K+j))^2 >= ...
                    real(trace(R(:,:,(k-1)*K+j+1)*V))+norm(h_k_j((k-1)*K+j+1))^2;
            end
        end
        %Constraint 21
        sum_trace_BV + real(trace(V*I_hat))*sigmar2 <= Pr_max;
        
        for k = 1 : K
            2 * Yk(sic_order(k)) * phi ...
            >= Yk(sic_order(k))^2 * (real(trace(D(:,:,sic_order(k))*V)) + nk2(sic_order(k))) + q;
            phi^2 <= real(trace(R(:,:,(k-1)*K+k)*V)) + norm(h_k_j((k-1)*K+k))^2;
        end
        V == hermitian_semidefinite(N+1);
cvx_end

The above is my CVX code, in which some variables involved such as R, F, B, etc. are constants and have been calculated externally, but this problem cannot be solved using sdpt3 solver, and the state is ‘solved’ using sedumi solver but the numerical value is not correct. Please help to solve it

You have not provided a reproducible problem or shown solver output, so we can’t tell you what the difficulty is. Bad numerical scaling (very large or small magnitude input data,l is a common reason for numerical difficulties or failure of the solver. if you have Mosek available, try that, and pay attention to any warning messages it provides.

You have not shown us the sedumi output, nor told us why or in what way the solution is not correct.

If you remove quiet, you can see the solver output.

Thank you for your reply. In fact, I tried to use mosek solver, but when I used moske and mosek_2, different results appeared. Below I will show you the output of mosek and mosek_2 and the values of some variables, in addition, I will add the quadratic transformation method used at specific places in the code. If you can help me solve the problem, I would really appreciate it

this is the output of mosek solver:

Calling Mosek 9.1.9: 1123 variables, 28 equality constraints
------------------------------------------------------------

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

Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 28              
  Cones                  : 4               
  Scalar variables       : 34              
  Matrix variables       : 1               
  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                 : 0               
Presolve terminated. Time: 0.00    
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 28              
  Cones                  : 4               
  Scalar variables       : 34              
  Matrix variables       : 1               
  Integer variables      : 0               

Optimizer  - threads                : 4               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 18
Optimizer  - Cones                  : 2
Optimizer  - Scalar variables       : 24                conic                  : 6               
Optimizer  - Semi-definite variables: 1                 scalarized             : 2211            
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 : 160               after factor           : 160             
Factor     - dense dim.             : 0                 flops                  : 2.69e+06        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   1.7e+06  8.2e+03  2.0e+00  0.00e+00   0.000000000e+00   -1.000000000e+00  1.0e+00  0.00  
1   1.7e+05  8.3e+02  6.4e-01  -1.00e+00  5.060409750e+03   5.068293690e+03   1.0e-01  0.00  
2   1.8e+02  8.7e-01  1.9e-02  -1.00e+00  4.925488759e+03   1.310369979e+04   1.1e-04  0.01  
3   2.1e+00  1.0e-02  5.4e-04  -7.42e-01  3.870913162e+02   4.483220303e+04   1.3e-06  0.01  
4   2.4e-01  1.2e-03  2.1e-05  9.14e-01   3.584226900e+01   5.118304885e+03   1.4e-07  0.01  
5   2.9e-02  1.4e-04  8.5e-07  9.92e-01   3.589266744e+00   6.088829168e+02   1.7e-08  0.01  
6   3.7e-03  1.8e-05  1.0e-08  1.02e+00   -3.603268037e+00  1.955024721e+00   2.2e-09  0.01  
7   2.5e-03  1.2e-05  6.3e-09  9.55e-01   -4.067829734e+01  -3.627502585e+01  1.5e-09  0.03  
8   1.0e-03  4.9e-06  2.1e-09  7.73e-01   -1.346764621e+02  -1.315480332e+02  6.0e-10  0.03  
9   6.8e-04  3.3e-06  1.5e-09  4.74e-02   -1.734563224e+02  -1.697745089e+02  4.0e-10  0.03  
10  2.7e-04  1.3e-06  5.0e-10  1.77e-01   -3.314876368e+01  -3.069630450e+01  1.6e-10  0.03  
11  9.5e-05  4.6e-07  1.2e-10  5.39e-01   -3.500499781e+00  -2.380599839e+00  5.6e-11  0.03  
12  3.0e-05  1.5e-07  5.8e-11  2.50e-01   -2.600981489e+01  -2.338483630e+01  1.8e-11  0.05  
13  6.9e-06  3.4e-08  2.2e-11  -3.44e-01  -1.720148302e+01  -9.911380088e+00  4.1e-12  0.05  
14  1.9e-06  9.2e-09  1.1e-11  -8.31e-01  -1.329153501e+01  9.185973720e+00   1.1e-12  0.05  
15  1.1e-06  5.4e-09  7.8e-12  -9.61e-01  -1.114964021e+01  2.488479693e+01   6.5e-13  0.05  
16  2.7e-07  1.3e-09  3.5e-12  -9.53e-01  -6.258278421e+00  1.110461667e+02   1.6e-13  0.06  
17  1.6e-07  8.7e-10  2.7e-12  -1.00e+00  -5.452602723e+00  2.070676909e+02   9.2e-14  0.06  
18  3.3e-08  8.7e-10  1.1e-12  -9.37e-01  -3.169346162e+00  7.881373882e+02   2.1e-14  0.06  
19  1.6e-08  1.1e-09  8.1e-13  -1.01e+00  -2.725936444e+00  1.723862155e+03   9.9e-15  0.06  
20  3.8e-09  1.3e-09  3.6e-13  -9.43e-01  -1.645842739e+00  6.328600490e+03   2.4e-15  0.08  
21  2.0e-09  1.2e-09  2.8e-13  -1.06e+00  -1.510965283e+00  1.339731049e+04   1.2e-15  0.08  
22  3.8e-10  8.8e-10  1.1e-13  -9.41e-01  -8.520112976e-01  5.813416930e+04   2.5e-16  0.08  
23  1.7e-10  8.1e-10  7.8e-14  -1.04e+00  -7.902473830e-01  1.470563951e+05   1.1e-16  0.08  
24  3.5e-11  5.9e-10  3.3e-14  -9.56e-01  -5.434638588e-01  6.142784201e+05   2.4e-17  0.09  
25  1.7e-11  5.1e-10  2.4e-14  -1.06e+00  -5.321861354e-01  1.473747160e+06   1.1e-17  0.09  
26  3.2e-12  4.8e-10  9.3e-15  -9.45e-01  -3.911951064e-01  6.397772122e+06   2.3e-18  0.09  
27  1.4e-12  5.1e-10  5.3e-15  -1.05e+00  -4.013284528e-01  1.621081164e+07   9.9e-19  0.11  
28  3.0e-13  2.9e-10  7.5e-15  -9.53e-01  -3.324427610e-01  6.733354646e+07   2.2e-19  0.11  
29  1.4e-13  2.7e-10  2.0e-15  -1.06e+00  -3.496320140e-01  1.635858201e+08   9.8e-20  0.11  
30  2.8e-14  2.5e-10  1.1e-14  -9.48e-01  -3.037955876e-01  6.772050696e+08   2.2e-20  0.11  
31  1.3e-14  2.3e-10  1.2e-14  -1.05e+00  -3.233117993e-01  1.663586024e+09   9.5e-21  0.13  
32  2.9e-15  1.7e-10  2.0e-14  -9.54e-01  -2.954312266e-01  6.554031183e+09   2.2e-21  0.13  
33  1.3e-15  1.5e-10  3.0e-14  -1.05e+00  -3.137176544e-01  1.533782468e+10   1.0e-21  0.13  
34  3.0e-16  1.2e-10  8.4e-16  -9.53e-01  -2.897618027e-01  6.141269625e+10   2.4e-22  0.14  
35  1.4e-16  1.1e-10  3.7e-14  -1.05e+00  -3.077824608e-01  1.413401621e+11   1.1e-22  0.14  
36  3.0e-17  1.1e-10  1.6e-14  -9.63e-01  -2.885732610e-01  5.914557150e+11   2.5e-23  0.14  
37  1.5e-17  5.6e-11  2.8e-15  -1.05e+00  -3.037407584e-01  1.253794403e+12   1.2e-23  0.16  
38  3.0e-18  1.1e-11  0.0e+00  -9.86e-01  -2.910299433e-01  5.829368236e+12   2.6e-24  0.16  
39  3.0e-18  1.1e-11  2.5e-14  -1.02e+00  -2.910311226e-01  5.830081690e+12   2.6e-24  0.19  
40  3.0e-18  1.1e-11  2.7e-14  -1.02e+00  -2.910500222e-01  5.841521342e+12   2.6e-24  0.20  
41  3.0e-18  1.1e-11  2.7e-14  -1.02e+00  -2.910500222e-01  5.841521342e+12   2.6e-24  0.22  
42  3.0e-18  1.1e-11  2.7e-14  -1.01e+00  -2.910500222e-01  5.841521342e+12   2.6e-24  0.25  
Optimizer terminated. Time: 0.27    


Interior-point solution summary
  Problem status  : ILL_POSED
  Solution status : PRIMAL_ILLPOSED_CER
  Dual.    obj: 3.8869477436e-06    nrm: 4e+05    Viol.  con: 0e+00    var: 1e-11    barvar: 2e-24    cones: 0e+00  
Optimizer summary
  Optimizer                 -                        time: 0.27    
    Interior-point          - iterations : 43        time: 0.27    
      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

And this is output of moesk-2:

Calling Mosek_2 9.1.9: 1123 variables, 28 equality constraints
------------------------------------------------------------

MOSEK Version 10.2.7 (Build date: 2024-11-4 10:29:18)
Copyright (c) MOSEK ApS, Denmark WWW: mosek.com
Platform: Windows/64-X86

Problem
  Name                   :                 
  Objective sense        : minimize        
  Type                   : CONIC (conic optimization problem)
  Constraints            : 28              
  Affine conic cons.     : 0               
  Disjunctive cons.      : 0               
  Cones                  : 4               
  Scalar variables       : 34              
  Matrix variables       : 1 (scalarized: 2211)
  Integer variables      : 0               

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 1
Eliminator terminated.
Eliminator - tries                  : 1                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - primal attempts        : 1                 successes              : 1               
Lin. dep.  - dual attempts          : 0                 successes              : 0               
Lin. dep.  - primal deps.           : 0                 dual deps.             : 0               
Presolve terminated. Time: 0.00    
Optimizer  - threads                : 4               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 19              
Optimizer  - Cones                  : 2               
Optimizer  - Scalar variables       : 25                conic                  : 6               
Optimizer  - Semi-definite variables: 1                 scalarized             : 2211            
Factor     - setup time             : 0.00            
Factor     - dense det. time        : 0.00              GP order time          : 0.00            
Factor     - nonzeros before factor : 178               after factor           : 178             
Factor     - dense dim.             : 0                 flops                  : 2.63e+06        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   3.4e+06  8.2e+03  2.0e+00  0.00e+00   0.000000000e+00   -1.000000000e+00  1.0e+00  0.00  
1   5.2e+05  1.3e+03  7.8e-01  -1.00e+00  1.602328378e+03   1.606838568e+03   1.5e-01  0.00  
2   3.9e+03  9.4e+00  6.8e-02  -1.00e+00  2.573639071e+03   3.436989634e+03   1.2e-03  0.00  
3   3.6e+00  8.7e-03  8.4e-04  -9.91e-01  2.582872597e+02   1.554783039e+05   1.1e-06  0.00  
4   3.8e-01  9.4e-04  3.2e-05  7.55e-01   1.383409041e+01   1.892595705e+04   1.1e-07  0.02  
5   6.4e-02  1.6e-04  2.2e-06  9.71e-01   1.038340625e+00   3.153049714e+03   1.9e-08  0.02  
6   1.4e-02  3.4e-05  1.7e-07  1.02e+00   -9.295606856e+00  4.229677843e+02   4.1e-09  0.02  
7   1.8e-03  4.4e-06  7.9e-09  1.01e+00   -1.502270470e+01  3.899149496e+01   5.4e-10  0.02  
8   8.2e-04  2.0e-06  2.5e-09  9.45e-01   -3.292074708e+01  -7.594505156e+00  2.5e-10  0.02  
9   1.8e-04  4.3e-07  1.8e-10  9.45e-01   -1.519927340e+00  1.391811166e+00   5.2e-11  0.02  
10  5.8e-05  1.4e-07  3.3e-11  1.05e+00   -2.070005757e+00  -1.143014055e+00  1.7e-11  0.03  
11  6.6e-06  1.6e-08  1.2e-12  1.01e+00   -3.162243763e+00  -3.070646275e+00  2.0e-12  0.03  
12  1.3e-06  3.3e-09  8.8e-14  1.08e+00   -3.192193211e+00  -3.179963206e+00  4.0e-13  0.03  
13  4.3e-07  1.0e-09  8.2e-15  1.42e+00   -3.287840921e+00  -3.286814463e+00  1.3e-13  0.03  
14  2.3e-07  4.0e-09  3.2e-15  1.85e+00   -3.326035106e+00  -3.325507855e+00  6.9e-14  0.03  
15  1.3e-07  1.7e-09  1.4e-15  1.25e+00   -3.337062852e+00  -3.336721184e+00  3.7e-14  0.03  
16  4.2e-08  8.7e-09  2.5e-16  5.49e-01   -3.353087911e+00  -3.352983687e+00  1.2e-14  0.03  
17  1.1e-08  6.9e-09  3.4e-17  1.05e+00   -3.357351896e+00  -3.357324413e+00  3.3e-15  0.05  
18  3.6e-09  4.5e-08  6.7e-18  1.04e+00   -3.358372942e+00  -3.358363391e+00  1.1e-15  0.05  
19  2.4e-09  2.1e-07  3.7e-18  9.28e-01   -3.358555868e+00  -3.358548849e+00  7.1e-16  0.05  
20  6.6e-10  2.4e-07  5.3e-19  1.04e+00   -3.358842623e+00  -3.358840760e+00  2.0e-16  0.05  
21  3.8e-10  1.4e-07  2.7e-19  8.77e-01   -3.358890764e+00  -3.358889422e+00  1.1e-16  0.05  
22  1.1e-10  3.3e-07  4.3e-20  9.88e-01   -3.358946959e+00  -3.358946545e+00  3.4e-17  0.05  
23  6.3e-11  1.9e-07  2.1e-20  8.10e-01   -3.358958329e+00  -3.358958021e+00  1.9e-17  0.06  
24  2.3e-11  7.7e-08  4.6e-21  9.84e-01   -3.358970846e+00  -3.358970733e+00  6.8e-18  0.06  
25  1.4e-11  4.8e-08  2.7e-21  6.49e-01   -3.358973443e+00  -3.358973337e+00  4.2e-18  0.06  
26  4.7e-12  7.5e-08  5.2e-22  9.95e-01   -3.358978216e+00  -3.358978180e+00  1.4e-18  0.06  
Optimizer terminated. Time: 0.06    


Interior-point solution summary
  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: -3.3589782155e+00   nrm: 4e+06    Viol.  con: 2e-09    var: 8e-08    barvar: 0e+00    cones: 0e+00  
  Dual.    obj: -3.3589894814e+00   nrm: 1e+10    Viol.  con: 0e+00    var: 1e-05    barvar: 2e-13    cones: 6e-16  
Optimizer summary
  Optimizer                 -                        time: 0.06    
    Interior-point          - iterations : 26        time: 0.06    
      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: Solved
Optimal value (cvx_optval): +3.50898

When I substituted the variable V solved by mosek_2 into my objective function expression, some unexpected results appeared, such as the SINR calculated to be negative.

Finally,there are values of some variables :


Thank you again for your reply.

Your Mosek_2 is actually Mosek 10.2.7, which is much more recent than Mosek 9.1.9 which was used in the first solve. Perhaps that newer version of Mosek is more numerically robust and able to overcome difficulties that the older version couldn’t.

In any event, I have no idea what you did to arrive at your negative SINR. The objective in the program you show is the variable q. Therefore, there is no computing required to determine the objective function. So apparently you did something else, to evaluate something which I don’t know what it is. As to why this SINR, whatever it is and however you calculated it, is negative, I have no idea. Perhaps there is either a tolerance issue (constraints can be violated by up to a feasibility tolerance, and are still considered to be satisfied by the solver and CVX), or your model or calculations are deficient for the purpose for which you are trying to use them. This forum has readers knowledgeable in how CVX works, and how the solvers it calls work (most especially Mosek), but they are not subject matter experts in your application area or research problem; therefore the responsibility for producing an optimization model suited for your purpose is up to you.

You can use the optimal value of V as you wish. The same with variables q and phi. In order to be guaranteed to be correct, all expressions have to be recomputed after cvx_end, starting from the optimal variable values.

I see thatsigmar2, having value 1e-10 is used in your program. It might be indicative of bad numerical scaling, as i suggested might be a possibility in my first post. That might be contributing to numerical difficulties, either in the solver solving the problem, or perhaps in your post-processing of the solution. You should try to get all non-zero input data to be within a small number of orders of magnitude of 1. Change units of variables and data if necessary to do this. The value of phi is also rather small, although perhaps it is just the case that its optimal value is actually zero.

Anyway, thank you for your advice in your busy schedule. I will carefully check my model and the numerical problems. Thank you again