CVX giving 'Solved' outcome not satisfying the constraints

Yes, I imagined that that was what you meant since I had similar problems previously so I already noticed that expressions that are related to the cvx variable may not be the correct ones after the optimisation.

I actually already have the 2.2 version, since I don’t even see the 3.0beta in the download page.

Any suggestion or some good source about how to perform a proper scaling?

Change units or whatever to try to get non-zero numbers to be within a small number of orders of magnitude of one.

Does Mosek show any warnings, such as very large or small numbers? if so, you should pay attention to that.

Perhaps if you show the Mosek output, including any warnings, @Erling or someone else form Mosek can give a better assessment.

The CVX 3.0beta link is http://cvxr.com/cvx/beta/ . It has a low profile because its use is not recommended at this point.

The Mosek output is the following:

Calling Mosek 9.1.9: 12702 variables, 828 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 (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 710: #2 (nearly) zero elements are specified in sparse col '' (12) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (13) of matrix 'A'.
MOSEK warning 710: #2 (nearly) zero elements are specified in sparse col '' (14) of matrix 'A'.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col '' (15) of matrix 'A'.
MOSEK warning 710: #4 (nearly) zero elements are specified in sparse col '' (16) of matrix 'A'.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col '' (17) of matrix 'A'.
MOSEK warning 710: #12 (nearly) zero elements are specified in sparse col '' (18) of matrix 'A'.
MOSEK warning 710: #9 (nearly) zero elements are specified in sparse col '' (19) of matrix 'A'.
MOSEK warning 710: #11 (nearly) zero elements are specified in sparse col '' (20) of matrix 'A'.
MOSEK warning 710: #20 (nearly) zero elements are specified in sparse col '' (21) of matrix 'A'.
Warning number 710 is disabled.
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 828             
  Cones                  : 237             
  Scalar variables       : 10287           
  Matrix variables       : 1               
  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 started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 2                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.02            
Lin. dep.  - number                 : 0               
Presolve terminated. Time: 0.08    
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 828             
  Cones                  : 237             
  Scalar variables       : 10287           
  Matrix variables       : 1               
  Integer variables      : 0               

Optimizer  - threads                : 4               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 827
Optimizer  - Cones                  : 237
Optimizer  - Scalar variables       : 5013              conic                  : 5012            
Optimizer  - Semi-definite variables: 1                 scalarized             : 2415            
Factor     - setup time             : 0.03              dense det. time        : 0.00            
Factor     - ML order time          : 0.00              GP order time          : 0.00            
Factor     - nonzeros before factor : 2.20e+05          after factor           : 2.28e+05        
Factor     - dense dim.             : 0                 flops                  : 2.68e+08        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   6.9e+01  4.0e+00  2.0e+00  0.00e+00   -3.043578051e+00  0.000000000e+00   1.0e+00  0.19  
Optimizer terminated. Time: 0.33    


Interior-point solution summary
  Problem status  : DUAL_INFEASIBLE
  Solution status : DUAL_INFEASIBLE_CER
  Primal.  obj: -3.0435780510e+00   nrm: 1e+00    Viol.  con: 7e+01    var: 0e+00    barvar: 0e+00    cones: 0e+00  
Optimizer summary
  Optimizer                 -                        time: 0.33    
    Interior-point          - iterations : 0         time: 0.28    
      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: Infeasible
Optimal value (cvx_optval): +Inf

The problem is the exact same as the previous one. Moreover, I forgot to say that it worked properly with SDPT3 and SeDuMi with additional constraints that I decided to remove later.

About the scaling, the variable I get at the end is a 20*66 matrix that is lower-block triangular (about 753 decision variables). The highest element after the (wrong) optimization is done with SDPT3 or SeDuMi is 32.5802, the lowest is -58.5389.

Talking about absolute values, the highest is of course 58.5389 while the lowest (non-zero) is 0.001. Is it enough to consider the problem badly scaled?

The problem is that this matrix represents a sequence of feedback control actions and I can’t predict which ones will be big or small (and therefore need to be scaled) before the optimisation is performed.

The Mosek certificate does not look very solid. It has a large violation. So it seems many solvers agree to numerically struggle on your problem. Maybe it is illposed, barely feasible/infeasible? You may also have some extremely small inputs which can affect scaling according to the Mosek warnings.

What does it mean that there is a violation?
I downloaded it from the site following the instructions using my student credentials.

Actually there isn’t a matrix A in my cvx environment. Is it a name given to a specific kind of matrix?

The infeasibility certificate is not too accurate just like the SDPT3 solution is not too accurate. As I wrote before, from the joint behavior of all solvers it seems clear that you have a nasty problem, but without the data it is not possible for us here to deduce why.

Try to solve the problem with zero objective with different solvers to see what they think of feasibility.

If you would like to continue investigating the numerical behavior of Mosek then maybe posting fully reproducible code with input data on https://groups.google.com/g/mosek would be the way to go. You can also save the Mosek task to a file send it to Mosek support. For instructions see https://docs.mosek.com/9.2/faq/faq.html#how-do-i-dump-the-problem-to-a-file-to-attach-with-my-support-question

@Michal_Adamaszek Can you please explain how the accuracy of the infeasibility certificate can be concluded by looking at the Mosek output?

The (linear) constraint violation in solution summary is 7e+1.

Hello,

Here is the outcome for the feasibility problem with the three solvers I used:

SDPT3:

Calling SDPT3 4.0: 12702 variables, 828 equality constraints
   For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------

 num. of constraints = 828
 dim. of sdp    var  = 69,   num. of sdp  blk  =  1
 dim. of socp   var  = 10285,   num. of socp blk  = 237
 dim. of linear var  =  2
*******************************************************************
   SDPT3: Infeasible path-following algorithms
*******************************************************************
 version  predcorr  gam  expon  scale_data
   HKM      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      prim-obj      dual-obj    cputime
-------------------------------------------------------------------
 0|0.000|0.000|4.8e+03|1.7e+01|7.8e+04|-1.377110e+01  0.000000e+00| 0:0:01| chol  1  1 
 1|0.871|0.518|6.2e+02|8.2e+00|1.6e+04| 5.543706e+02  0.000000e+00| 0:0:03| chol  1  1 
 2|0.508|0.313|3.0e+02|5.7e+00|1.2e+04| 1.281700e+03  0.000000e+00| 0:0:03| chol  1  1 
 3|0.477|0.434|1.6e+02|3.2e+00|6.7e+03| 1.163648e+03  0.000000e+00| 0:0:04| chol  1  1 
 4|0.349|0.496|1.0e+02|1.6e+00|3.7e+03| 1.024569e+03  0.000000e+00| 0:0:04| chol  1  1 
 5|0.623|0.507|3.9e+01|8.0e-01|1.6e+03| 6.845766e+02  0.000000e+00| 0:0:05| chol  1  1 
 6|0.652|0.511|1.4e+01|3.9e-01|6.1e+02| 3.637381e+02  0.000000e+00| 0:0:05| chol  1  1 
 7|0.787|0.736|2.9e+00|1.0e-01|1.4e+02| 1.091292e+02  0.000000e+00| 0:0:05| chol  1  1 
 8|0.488|1.000|1.5e+00|7.4e-07|6.8e+01| 5.781303e+01  0.000000e+00| 0:0:06| chol  1  1 
 9|0.985|1.000|2.2e-02|7.4e-08|1.0e+00| 8.710054e-01  0.000000e+00| 0:0:06| chol  1  1 
10|0.989|1.000|2.5e-04|4.5e-03|1.1e-02| 9.600938e-03  0.000000e+00| 0:0:07| chol  1  1 
11|0.988|1.000|2.9e-06|4.9e-05|1.3e-04| 1.144955e-04  0.000000e+00| 0:0:07| chol  1  1 
12|0.989|1.000|3.2e-08|5.8e-07|1.5e-06| 1.304675e-06  0.000000e+00| 0:0:07| chol  1  1 
13|0.475|1.000|1.7e-08|6.5e-09|8.1e-07| 6.919944e-07  0.000000e+00| 0:0:08| chol  1  1 
14|0.474|1.000|9.0e-09|3.4e-09|4.3e-07| 3.678439e-07  0.000000e+00| 0:0:08| chol  1  1 
15|0.474|1.000|4.7e-09|1.8e-09|2.3e-07| 1.955423e-07  0.000000e+00| 0:0:08| chol  1  1 
16|0.474|1.000|2.5e-09|9.5e-10|1.2e-07| 1.039518e-07  0.000000e+00| 0:0:09| chol  1  1 
17|0.474|1.000|1.3e-09|5.0e-10|6.6e-08| 5.526333e-08  0.000000e+00| 0:0:09| chol  1  1 
18|0.474|1.000|6.9e-10|2.6e-10|3.5e-08| 2.938027e-08  0.000000e+00| 0:0:09| chol  1  1 
19|0.474|1.000|3.6e-10|1.4e-10|1.9e-08| 1.562025e-08  0.000000e+00| 0:0:10| chol  1  1 
20|0.474|1.000|1.9e-10|7.3e-11|1.0e-08| 8.304876e-09  0.000000e+00| 0:0:10| chol  1  1 
21|0.474|1.000|1.0e-10|3.8e-11|5.4e-09| 4.415615e-09  0.000000e+00| 0:0:11| chol  1  1 
22|0.474|1.000|5.3e-11|2.0e-11|2.9e-09| 2.347804e-09  0.000000e+00| 0:0:11| chol *    1 
23|0.474|1.000|2.8e-11|1.1e-11|1.5e-09| 1.248375e-09  0.000000e+00| 0:0:11| chol *    1 
24|0.474|1.000|1.5e-11|5.6e-12|8.2e-10| 6.638045e-10  0.000000e+00| 0:0:12| chol *    1 
25|0.474|1.000|7.7e-12|2.9e-12|4.4e-10| 3.530169e-10  0.000000e+00| 0:0:12| chol *    1 
26|0.474|1.000|4.1e-12|1.5e-12|2.3e-10| 1.877647e-10  0.000000e+00| 0:0:12| chol *    1 
27|0.474|1.000|2.1e-12|1.0e-12|1.2e-10| 9.988342e-11  0.000000e+00| 0:0:13| chol *    1 
28|0.474|1.000|1.1e-12|1.0e-12|6.6e-11| 5.314135e-11  0.000000e+00| 0:0:13| chol *    1 
29|0.474|1.000|5.9e-13|1.0e-12|3.5e-11| 2.827677e-11  0.000000e+00| 0:0:13| chol *    1 
30|0.473|1.000|3.1e-13|1.0e-12|1.9e-11| 1.504817e-11  0.000000e+00| 0:0:14| chol *    1 
31|0.473|1.000|1.6e-13|1.0e-12|1.0e-11| 8.009272e-12  0.000000e+00| 0:0:14| chol *    1 
32|0.473|1.000|8.6e-14|1.0e-12|5.4e-12| 4.263404e-12  0.000000e+00| 0:0:15| chol *    1 
33|0.473|1.000|4.5e-14|1.0e-12|2.9e-12| 2.269723e-12  0.000000e+00| 0:0:15| chol *    1 
34|0.473|1.000|2.4e-14|1.0e-12|1.5e-12| 1.208485e-12  0.000000e+00| 0:0:15| chol *    1 
35|0.473|1.000|1.3e-14|1.0e-12|8.3e-13| 6.435174e-13  0.000000e+00| 0:0:16| chol *    1 
36|0.473|1.000|6.6e-15|1.0e-12|4.4e-13| 3.427120e-13  0.000000e+00| 0:0:16| chol *    1 
37|0.473|1.000|3.5e-15|1.0e-12|2.4e-13| 1.825354e-13  0.000000e+00| 0:0:17| chol *    1 
38|0.473|1.000|1.8e-15|1.0e-12|1.3e-13| 9.723288e-14  0.000000e+00| 0:0:17|
  lack of progress in infeas
-------------------------------------------------------------------
 number of iterations   = 38
 primal objective value =  6.43517365e-13
 dual   objective value =  0.00000000e+00
 gap := trace(XZ)       = 8.26e-13
 relative gap           = 8.26e-13
 actual relative gap    = 6.44e-13
 rel. primal infeas (scaled problem)   = 1.26e-14
 rel. dual     "        "       "      = 9.99e-13
 rel. primal infeas (unscaled problem) = 0.00e+00
 rel. dual     "        "       "      = 0.00e+00
 norm(X), norm(y), norm(Z) = 3.4e-13, 1.5e+03, 2.1e+03
 norm(A), norm(b), norm(C) = 1.4e+02, 1.0e+00, 1.9e+01
 Total CPU time (secs)  = 16.99  
 CPU time per iteration = 0.45  
 termination code       =  0
 DIMACS: 1.3e-14  0.0e+00  4.8e-12  0.0e+00  6.4e-13  8.3e-13
-------------------------------------------------------------------
 
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -6.43517e-13

SeDuMi:

Calling SeDuMi 1.3.4: 12702 variables, 828 equality constraints
   For improved efficiency, SeDuMi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.3.4 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 828, order n = 546, dim = 15049, blocks = 239
nnz(A) = 507409 + 0, nnz(ADA) = 452540, nnz(L) = 226684
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            7.87E+00 0.000
  1 :   0.00E+00 5.94E+00 0.000 0.7555 0.9000 0.9000   7.09  1  1  5.9E+01
  2 :   0.00E+00 4.87E+00 0.000 0.8185 0.9000 0.9000   0.75  1  1  6.3E+01
  3 :   0.00E+00 3.24E+00 0.000 0.6657 0.9000 0.9000   0.67  1  1  5.5E+01
  4 :   0.00E+00 1.99E+00 0.000 0.6156 0.9000 0.9000   0.66  1  1  4.0E+01
  5 :   0.00E+00 1.41E+00 0.000 0.7063 0.9000 0.9000   0.19  1  1  3.1E+01
  6 :   0.00E+00 9.42E-01 0.000 0.6694 0.9000 0.9000   0.04  1  1  2.5E+01
  7 :   0.00E+00 6.63E-01 0.000 0.7030 0.9000 0.9000   0.64  1  1  1.7E+01
  8 :   0.00E+00 4.25E-01 0.000 0.6422 0.9000 0.9000   0.37  1  1  1.3E+01
  9 :   0.00E+00 2.54E-01 0.000 0.5974 0.9000 0.9000   0.92  1  1  6.8E+00
 10 :   0.00E+00 7.31E-02 0.000 0.2876 0.9000 0.9000   1.01  1  1  1.8E+00
 11 :   0.00E+00 1.35E-02 0.000 0.1852 0.9000 0.9076   1.12  1  1  3.2E-01
 12 :   0.00E+00 9.27E-05 0.000 0.0068 0.9990 0.9990   1.02  1  1  2.2E-03
 13 :   0.00E+00 7.96E-07 0.000 0.0086 0.9990 0.9990   1.00  1  1  1.9E-05
 14 :   0.00E+00 6.83E-09 0.000 0.0086 0.9990 0.9990   1.00  1  1  1.6E-07
 15 :   0.00E+00 5.87E-11 0.000 0.0086 0.9990 0.9990   1.00  1  1  1.4E-09
 16 :   0.00E+00 1.94E-11 0.000 0.3300 0.9000 0.6299   1.00  1  1  4.7E-10
 17 :   0.00E+00 8.07E-12 0.000 0.4169 0.9225 0.9000   0.94  1  1  2.0E-10
 18 :   0.00E+00 4.54E-12 0.000 0.5622 0.9247 0.9000   0.77  1  1  1.3E-10
 19 :   0.00E+00 2.92E-12 0.044 0.6441 0.9300 0.9000   0.56  1  1  9.1E-11
 20 :   0.00E+00 2.03E-12 0.288 0.6952 0.9274 0.9000   0.34  1  1  7.4E-11
 21 :   0.00E+00 1.39E-12 0.332 0.6858 0.9416 0.9000   0.14  1  1  6.1E-11
 22 :   0.00E+00 9.36E-13 0.448 0.6717 0.9537 0.9000   0.00  1  1  5.1E-11
 23 :   0.00E+00 8.01E-13 0.499 0.8554 0.9000 0.9000  -0.06  1  1  4.8E-11
 24 :   0.00E+00 5.54E-13 0.000 0.6920 0.9000 0.9117  -0.04  1  1  4.2E-11
 25 :   0.00E+00 3.10E-13 0.000 0.5595 0.9151 0.9000  -0.08  1  1  3.2E-11
 26 :   0.00E+00 2.03E-13 0.000 0.6553 0.9000 0.9362  -0.04  1  1  2.8E-11
 27 :   0.00E+00 1.13E-13 0.000 0.5544 0.9058 0.9000  -0.07  1  1  2.0E-11
 28 :   0.00E+00 6.37E-14 0.000 0.5655 0.9000 0.9084  -0.12  1  1  1.7E-11
 29 :   0.00E+00 3.21E-14 0.000 0.5041 0.9000 0.8638  -0.15  1  1  1.3E-11
 30 :   0.00E+00 1.45E-14 0.000 0.4505 0.9000 0.9000  -0.20  1  1  9.3E-12
 31 :   0.00E+00 7.45E-15 0.000 0.5148 0.9000 0.9000  -0.23  1  1  7.6E-12
 32 :   0.00E+00 3.27E-15 0.000 0.4396 0.9000 0.9000  -0.25  1  1  5.7E-12
 33 :   0.00E+00 1.44E-15 0.000 0.4403 0.9000 0.9000  -0.26  1  1  4.4E-12
 34 :   0.00E+00 6.09E-16 0.000 0.4226 0.9000 0.9000  -0.23  1  1  3.3E-12
 35 :   0.00E+00 2.75E-16 0.000 0.4518 0.9000 0.9000  -0.25  1  1  2.6E-12
 36 :   0.00E+00 1.14E-16 0.000 0.4143 0.9000 0.9000  -0.25  1  1  1.9E-12
 37 :   0.00E+00 4.98E-17 0.000 0.4364 0.9000 0.9000  -0.27  1  1  1.5E-12
 38 :   0.00E+00 2.00E-17 0.000 0.4022 0.9000 0.9000  -0.26  1  1  1.1E-12
 39 :   0.00E+00 8.75E-18 0.000 0.4371 0.9000 0.9000  -0.29  1  1  8.6E-13
 40 :   0.00E+00 3.44E-18 0.000 0.3933 0.9000 0.9000  -0.31  1  1  6.5E-13
 41 :   0.00E+00 1.40E-18 0.000 0.4060 0.9000 0.9000  -0.34  1  1  5.1E-13
 42 :   0.00E+00 5.00E-19 0.000 0.3581 0.9000 0.9000  -0.37  1  1  3.8E-13
 43 :   0.00E+00 1.79E-19 0.000 0.3584 0.9000 0.9000  -0.43 12 13  3.0E-13
 44 :   0.00E+00 1.16E-21 0.134 0.0065 0.9900 0.0000  -0.03 14 15  2.3E-14
Run into numerical problems.

iter seconds digits       c*x               b*y
 44     20.2  -0.1  4.3177282836e-07  0.0000000000e+00
|Ax-b| =   8.5e-14, [Ay-c]_+ =   0.0E+00, |x|=  9.8e-08, |y|=  2.7e+07
No sensible solution found.

Detailed timing (sec)
   Pre          IPM          Post
4.270E-01    1.538E+01    2.001E-02    
Max-norms: ||b||=0, ||c|| = 3.660474e+00,
Cholesky |add|=0, |skip| = 304, ||L.L|| = 1199.29.
------------------------------------------------------------
Status: Failed
Optimal value (cvx_optval): NaN

Mosek:

Calling Mosek 9.1.9: 12702 variables, 828 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 (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 710: #2 (nearly) zero elements are specified in sparse col '' (12) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (13) of matrix 'A'.
MOSEK warning 710: #2 (nearly) zero elements are specified in sparse col '' (14) of matrix 'A'.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col '' (15) of matrix 'A'.
MOSEK warning 710: #4 (nearly) zero elements are specified in sparse col '' (16) of matrix 'A'.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col '' (17) of matrix 'A'.
MOSEK warning 710: #12 (nearly) zero elements are specified in sparse col '' (18) of matrix 'A'.
MOSEK warning 710: #9 (nearly) zero elements are specified in sparse col '' (19) of matrix 'A'.
MOSEK warning 710: #11 (nearly) zero elements are specified in sparse col '' (20) of matrix 'A'.
MOSEK warning 710: #20 (nearly) zero elements are specified in sparse col '' (21) of matrix 'A'.
Warning number 710 is disabled.
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 828             
  Cones                  : 237             
  Scalar variables       : 10287           
  Matrix variables       : 1               
  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 started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 2                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.01            
Lin. dep.  - number                 : 0               
Presolve terminated. Time: 0.08    
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 828             
  Cones                  : 237             
  Scalar variables       : 10287           
  Matrix variables       : 1               
  Integer variables      : 0               

Optimizer  - threads                : 4               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 827
Optimizer  - Cones                  : 237
Optimizer  - Scalar variables       : 5013              conic                  : 5012            
Optimizer  - Semi-definite variables: 1                 scalarized             : 2415            
Factor     - setup time             : 0.05              dense det. time        : 0.00            
Factor     - ML order time          : 0.02              GP order time          : 0.00            
Factor     - nonzeros before factor : 2.20e+05          after factor           : 2.28e+05        
Factor     - dense dim.             : 0                 flops                  : 2.68e+08        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   6.9e+01  4.0e+00  2.0e+00  0.00e+00   -3.043578051e+00  0.000000000e+00   1.0e+00  0.19  
Optimizer terminated. Time: 0.33    


Interior-point solution summary
  Problem status  : DUAL_INFEASIBLE
  Solution status : DUAL_INFEASIBLE_CER
  Primal.  obj: -3.0435780510e+00   nrm: 1e+00    Viol.  con: 7e+01    var: 0e+00    barvar: 0e+00    cones: 0e+00  
Optimizer summary
  Optimizer                 -                        time: 0.33    
    Interior-point          - iterations : 0         time: 0.30    
      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: Infeasible
Optimal value (cvx_optval): +Inf

Looks really weird that for the same problem I get three different outcomes from the three solvers.
It is also weird that as I said the problem was efficently solved with more constraints than these ones (even though the cost function was a bit different, but it shouldn’t affect feasibility).

If you think there’s more to investigate I’ll send the code to the Mosek forum.

Thank you in advance.

The Mosek result looks buggy. We need the problem to debug it.

Alright, then I should send the code to https://groups.google.com/g/mosek as @Michal_Adamaszek suggested, right?

The other solution I suggested is even better: You can also save the Mosek task to a file send it to Mosek support. For instructions see https://docs.mosek.com/9.2/faq/faq.html#how-do-i-dump-the-problem-to-a-file-to-attach-with-my-support-question The email is in https://www.mosek.com/support/

Thank you very much! I’ll do it hoping that it will be helpful.

Do not set “best” cvx precision. Use default precision and everything solves nicely (I’m talking about Mosek).

As discussed in some other thread I can’t find any more, highest cvx precision sets Mosek termination tolerances to 0.0, which strictly speaking should be illegal and can yield all kinds of crazy behavior.

Ok, thank you, I will remember it from now on.

The problem is that now the solution is the same given by the other solvers, and for some odd reason it violates one of the two constraints of the problem.

Hello to everyone,

I’m now pretty sure I found out where the problem is.

Basically, Inside of my cvx workspace I declare two variables:

 cvx_begin %quiet

 % Design variable declaration


variable K1(N*nu,nx);
variable Ktri(N*nu,nx,N+1);

which dimensions are not important.
I use K1 and Ktri to create a variable K and some other cvx expressions.

Now, as @Mark_L_Stone told me, I’m not guaranteed to get the right expressions after cvx, is closed, but I should compute everything back starting from K1 and Ktri.

The odd fact is that if I do it, the values I get are wrong ( just the most critical example, the value of the cost function computed with the output K1 and Ktri is lower than cvx_optval, and the initial issue (not satisfying the constraint)was just a consequence).

I notice that because adding a very small term to the cost function (of the order of 10^-100) I got the same cvx_optval but the output K1 and Ktri were such that the constraint was satisfied.

Therefore my question now becomes:

How is it possible that the output design variables are not the right ones and how can I be sure to get the right ones?

Thank you in advance.

CVX variables should have the correct values.If this does not appear to be the case, please show us the detailed information leading you to that conclusion.

Hello, here is the CVX problem and the code I run right after to compare the optimal value computed by CVX and the one obtained from the CVX variable given as output :

cvx_begin %quiet


    variable K1(N*nu,nx);
    variable Ktri(N*nu,nx,N+1);
    KK=[K1];
    for ii=1:N+1
    KK=[KK blkdiag(zeros(ii-1)*nu,eye((N-(ii-1))*nu))*Ktri(:,:,ii)];
    end
    K=KK;
  
    
%% Cost function   
% Cost function elements for compostion
    
    
    U=mu_0_aug*mu_0_aug';
    H1=AAA*U*AAA';
    V=DDD*DDD';
    Oo=EEE*Sig_0_aug*EEE';
    Z=V+Oo;
    
    n1=trace(QQQ*Z);
    n2=trace(K'*BBB'*QQQ*Z);
    n3=trace(QQQ*BBB*K*Z); 
    soft1 = trace(SSSc*H1);
    soft2 = trace(K'*BBB'*SSSc*H1);
    soft3 = trace(SSSc*BBB*K*H1);


    n4=2*trace(QQQ*((I+BBB*K)*(EEE*Sig_0_aug*AAA_errev'+DDD*DDD_errev'))); %cross covariance term


        
    tmp6=0;
        F6=BBB*K*DDD;
        for k=1:size(F6,2)
            tmp6=tmp6+quad_form(F6(:,k),QQQ);
        end
        n6=tmp6;
        
    tmp7=0;
        F7=BBB*K*EEE*(Sig_0_aug)^0.5;
        for k=1:size(F7,2)
            tmp7=tmp7+quad_form(F7(:,k),QQQ);
        end
        n7=tmp7;
        
    tmp8=0;
        F8=K*AAA*mu_0_aug;
        for k=1:size(F8,2)
            tmp8=tmp8+quad_form(F8(:,k),RRR);
        end
        n8=tmp8;

        
    tmp10=0;
       F10=K*DDD;
    for k=1:size(F10,2)
        tmp10=tmp10+quad_form(F10(:,k),RRR);
    end
        n10=tmp10;
        
tmp11=0;
        F11=K*EEE*(Sig_0_aug)^0.5;
        for k=1:size(F11,2)
            tmp11=tmp11+quad_form(F11(:,k),RRR);
        end
        n11=tmp11;

tmp_s4=0;
        Fs4=BBB*K*AAA*mu_0_aug;
        for k=1:size(Fs4,2)
            tmp_s4=tmp_s4+quad_form(Fs4(:,k),SSSc);
        end
        soft4=tmp_s4;        
%Cost function

    J=n1+n2+n3+n4+n6+n7+n8+n10+n11+soft1+soft2+soft3+soft4;


        minimize(J);
        
     subject to

     beta-alpha'*(I+BBB*K)*AAA*mu_0_aug-(norm(((Sig_op)^0.5)*(I+BBB*K)'*alpha,2)+norm((Sig_aug)^0.5*alpha,2))*failnorm <= 0;

     1-norm( (Sig_op^0.5*(I+BBB*K)'*E_N'*Sig_lim^(-0.5)) ,2)>=0;
     
    
  cvx_end 
 
  %Rebuilding of the cost function after the optimization is over

    KK=[K1];
    for ii=1:N+1
    KK=[KK blkdiag(zeros(ii-1)*nu,eye((N-(ii-1))*nu))*Ktri(:,:,ii)];
    end
    K=KK;
  


    
%% Cost function   
% Cost function elements for compostion
    
    
    U=mu_0_aug*mu_0_aug';
    H1=AAA*U*AAA';
    V=DDD*DDD';
    Oo=EEE*Sig_0_aug*EEE';
    Z=V+Oo;
    
    n1=trace(QQQ*Z);
    n2=trace(K'*BBB'*QQQ*Z);
    n3=trace(QQQ*BBB*K*Z); 
    soft1 = trace(SSSc*H1);
    soft2 = trace(K'*BBB'*SSSc*H1);
    soft3 = trace(SSSc*BBB*K*H1);


    n4=2*trace(QQQ*((I+BBB*K)*(EEE*Sig_0_aug*AAA_errev'+DDD*DDD_errev'))); %cross covariance term


        
    tmp6=0;
        F6=BBB*K*DDD;
        for k=1:size(F6,2)
            tmp6=tmp6+quad_form(F6(:,k),QQQ);
        end
        n6=tmp6;
        
    tmp7=0;
        F7=BBB*K*EEE*(Sig_0_aug)^0.5;
        for k=1:size(F7,2)
            tmp7=tmp7+quad_form(F7(:,k),QQQ);
        end
        n7=tmp7;
        
    tmp8=0;
        F8=K*AAA*mu_0_aug;
        for k=1:size(F8,2)
            tmp8=tmp8+quad_form(F8(:,k),RRR);
        end
        n8=tmp8;

        
    tmp10=0;
       F10=K*DDD;
    for k=1:size(F10,2)
        tmp10=tmp10+quad_form(F10(:,k),RRR);
    end
        n10=tmp10;
        
tmp11=0;
        F11=K*EEE*(Sig_0_aug)^0.5;
        for k=1:size(F11,2)
            tmp11=tmp11+quad_form(F11(:,k),RRR);
        end
        n11=tmp11;

tmp_s4=0;
        Fs4=BBB*K*AAA*mu_0_aug;
        for k=1:size(Fs4,2)
            tmp_s4=tmp_s4+quad_form(Fs4(:,k),SSSc);
        end
        soft4=tmp_s4;        
%Cost function

    J=n1+n2+n3+n4+n6+n7+n8+n10+n11+soft1+soft2+soft3+soft4;

As you can see I rewrite the exact code that was internal to the CVX environment starting from the CVX variables K1 and Ktri.

The log output from CVX (using Mosek) is:

Calling Mosek 9.1.9: 12679 variables, 827 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 (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (15) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (17) of matrix 'A'.
MOSEK warning 710: #3 (nearly) zero elements are specified in sparse col '' (18) of matrix 'A'.
MOSEK warning 710: #3 (nearly) zero elements are specified in sparse col '' (20) of matrix 'A'.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col '' (21) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (22) of matrix 'A'.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col '' (23) of matrix 'A'.
MOSEK warning 710: #10 (nearly) zero elements are specified in sparse col '' (24) of matrix 'A'.
MOSEK warning 710: #4 (nearly) zero elements are specified in sparse col '' (25) of matrix 'A'.
MOSEK warning 710: #11 (nearly) zero elements are specified in sparse col '' (26) of matrix 'A'.
Warning number 710 is disabled.
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 827             
  Cones                  : 236             
  Scalar variables       : 10264           
  Matrix variables       : 1               
  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 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            : 827             
  Cones                  : 236             
  Scalar variables       : 10264           
  Matrix variables       : 1               
  Integer variables      : 0               

Optimizer  - threads                : 4               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 807
Optimizer  - Cones                  : 236
Optimizer  - Scalar variables       : 4976              conic                  : 4975            
Optimizer  - Semi-definite variables: 1                 scalarized             : 2415            
Factor     - setup time             : 0.03              dense det. time        : 0.00            
Factor     - ML order time          : 0.00              GP order time          : 0.00            
Factor     - nonzeros before factor : 2.10e+05          after factor           : 2.13e+05        
Factor     - dense dim.             : 0                 flops                  : 2.38e+08        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   6.9e+01  4.0e+00  2.0e+00  0.00e+00   -3.043578051e+00  0.000000000e+00   1.0e+00  0.19  
1   2.9e+01  1.7e+00  1.1e+00  -7.34e-01  -6.855128468e+01  -6.535390748e+01  4.2e-01  0.36  
2   1.7e+01  9.7e-01  5.7e-01  -2.55e-01  -2.171738190e+02  -2.145765599e+02  2.4e-01  0.42  
3   7.6e+00  4.5e-01  2.1e-01  1.66e-01   -4.987466018e+02  -4.972026950e+02  1.1e-01  0.50  
4   2.2e+00  1.3e-01  3.3e-02  3.56e-01   -7.670074253e+02  -7.665184783e+02  3.2e-02  0.59  
5   1.2e-01  7.1e-03  6.0e-04  7.67e-01   -9.346072680e+02  -9.345639833e+02  1.7e-03  0.67  
6   1.4e-03  8.4e-05  8.1e-07  9.87e-01   -9.449396656e+02  -9.449391249e+02  2.1e-05  0.77  
7   1.4e-05  8.1e-07  7.6e-10  1.00e+00   -9.450620293e+02  -9.450620241e+02  2.0e-07  0.84  
8   1.3e-07  7.4e-09  6.5e-13  1.00e+00   -9.450632083e+02  -9.450632082e+02  1.8e-09  0.91  
Optimizer terminated. Time: 0.98    


Interior-point solution summary
  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: -9.4506320829e+02   nrm: 1e+02    Viol.  con: 5e-07    var: 0e+00    barvar: 0e+00    cones: 0e+00  
  Dual.    obj: -9.4506320824e+02   nrm: 1e+01    Viol.  con: 0e+00    var: 8e-09    barvar: 8e-09    cones: 0e+00  
Optimizer summary
  Optimizer                 -                        time: 0.98    
    Interior-point          - iterations : 8         time: 0.91    
      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): +162.303

where you can see that cvx_optval =162.303, while the variable J that is computed later is equal to 117.9348.

If I slightly change one matrix inside the problem before the optimization (Sig_op, which elements are of the order of 10^(-2)), adding to it a matrix that I think is negligible (its biggest element is of the order of 10^(-98) ) and I run the same code, I get the same cvx_optval =162.303, but I get also J=162.3030 as it should be.

Did you send the data to Mosek that they suggested?

I warned you before about the Mosek warnings. Perhaps those near zero elements are causing numerical inaccuracy and sensitivity.

I didn’t verify your reconstruction of the optimal objective value is correct, but I’m guessing so. Unless there is a bug somewhere, it appears that numerical difficulties due to “bad” input data is to blame for your observed discrepancy.

The Mosek solution summary says

Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: -9.4506320829e+02 nrm: 1e+02 Viol. con: 5e-07 var: 0e+00 barvar: 0e+00 cones: 0e+00
Dual. obj: -9.4506320824e+02 nrm: 1e+01 Viol. con: 0e+00 var: 8e-09 barvar: 8e-09 cones: 0e+00

that means Mosek solves the problem accurately. I am 99.99% sure the problem is not with Mosek.

Your problem or Cvx is culprit.

Btw how come 10^(-98) pops up in your argument i.e.

(its biggest element is of the order of 10^(-98) )

? You are aware

1+epsilon=1

on a computer for |epsilon|<=1.0e-16. So mentioning 10^(-98) seems very strange, In my numerical analysis course I learned using 10^(-98) was most likely a very bad idea.