L1/2 regularized logistic regression

I was trying to do the L1/2 regularized logistic regression by the algrithm provided by Zongben Xu using CVX in MATLAB.
The code gives out “Infeasible” only after one or two steps.
Could you help me find out what happened here? How should I fix it?

load('test.mat')
lambdaR = 1;
nAccu = 6;
[rX,cX] = size(testData);
KK = 10000; % maximum # of steps
solMat = zeros(KK,cX+1);
lossFun = zeros(KK,1);
regu = zeros(KK,1);
cvx_optival_v = zeros(KK,1);
cvx_status_v =[];
betaR_k = ones(cX+1,1);
clear k
cvx_optval = 1;
cvx_optval1 = 0;
k = 1;
testData2 = [ones(rX,1) testData];
while abs(cvx_optval - cvx_optval1) > 10^(-nAccu)
cvx_optval1 = cvx_optval;
if k > KK
    break;
 end
cvx_begin
variable betaR(cX+1) % betaR_(k+1)
minimize (-testLabel'*testData2*betaR + sum(log_sum_exp([zeros(1,rX);    betaR'*testData2'])) + 0.5*lambdaR*sum(abs(betaR(2:end))./(sqrt(abs(betaR_k(2:end)))+eps)));
cvx_end
betaR_k = betaR;
solMat(k, : ) = betaR';
lossFun(k) = -testLabel'*testData2*betaR + sum(log_sum_exp([zeros(1,rX); betaR'*testData2']));
regu(k) = sum(abs(betaR(2:end))./(sqrt(abs(betaR_k(2:end)))+eps));
cvx_optival_v(k) = cvx_optval;
cvx_status_v{k} = cvx_status;
k = k + 1;
end

CVX gives out the following information,

CVX Warning:
Models involving "log_sum_exp" or other functions in the log, exp, and entropy family are solved using an experimental successive approximation method.
This method is slower and less reliable than the method CVX employs for other models. Please see the section of the user's guide entitled    
The successive approximation method
 for more details about the approach, and for instructions on how to suppress this warning message in the future.

Successive approximation method to be employed.
   SDPT3 will be called several times to refine the solution.
   Original size: 2599 variables, 400 equality constraints 200 exponentials add 1600 variables, 1000 equality constraints

Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------±--------------------------------±--------
199/200 | 6.024e+00 2.785e+00 0.000e+00 | Solved
200/200 | 4.356e-01 1.216e-02 0.000e+00 | Solved
190/199 | 3.652e-02 8.622e-05 0.000e+00 | Solved
43/103 | 2.301e-03 1.848e-07 0.000e+00 | Solved
0/ 0 | 2.358e-04 0.000e+00 0.000e+00 | Solved

Status: Solved
Optimal value (cvx_optval): +29.5253

Successive approximation method to be employed.
SDPT3 will be called several times to refine the solution.
Original size: 2599 variables, 400 equality constraints
200 exponentials add 1600 variables, 1000 equality constraints

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

The MATLAB code, data and also the reference have been included in the following link.

https://drive.google.com/drive/folders/1PUJUAojh0fcZaPjG2igsgJQuC-rNWjqJ?usp=sharing

Thank you for your time.

You should post at least the code, if not also the input data, directly on this site, not at an external location, such as google drives. That is a matter of forum security. Post all the solver and CVX output .

Thank you for your information. I will correct it ASAP.

Your output does not show a claim that the (failed) problem is infeasible. The output shoiws a failure of CVX’s successive approximation method, which can fail even for problems which are well formulated and have (finite) optimal solutions.

Use CVXQUAD


and show us the results. I do not guarantee the problem will be solved using CVXQUAD, but it might. In order to maximize your chances of success, if you have CVX professkional or academic versions, and have Gurobi or Mosek solvers available, specify one of them as cvx_solver, because they are better solvers than SeDuMi and SDPT3.

With Mosek, it gives out the following information,

RegularizedLogisticRegressionTest

Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Mosek 8.0.0.60: 5899 variables, 2500 equality constraints

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2500
Cones : 2199
Scalar variables : 5899
Matrix variables : 0
Integer variables : 0

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 300
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.03
Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 1200
Optimizer - Cones : 2200
Optimizer - Scalar variables : 5800 conic : 5600
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 : 8350 after factor : 8850
Factor - dense dim. : 0 flops : 6.88e+005
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 8.7e-001 8.0e+000 8.6e+002 0.00e+000 1.373133333e+004 0.000000000e+000 1.0e+000 0.05
1 6.0e-001 5.5e+000 5.8e+002 -4.41e-001 1.095796133e+004 -1.002337027e+003 6.9e-001 0.11
2 5.6e-001 5.1e+000 5.3e+002 -3.05e-001 1.054121644e+004 -1.195364154e+003 6.4e-001 0.11
3 2.8e-001 2.6e+000 3.0e+002 -1.82e-001 4.922921032e+003 -2.769974696e+003 3.2e-001 0.13
4 1.9e-001 1.7e+000 2.7e+002 7.74e-001 2.660359039e+003 -2.221724825e+003 2.1e-001 0.13
5 1.0e-001 9.4e-001 2.3e+002 1.05e+000 1.233056177e+003 -1.182113662e+003 1.2e-001 0.13
6 6.6e-002 6.0e-001 1.9e+002 1.22e+000 7.442690668e+002 -7.112369068e+002 7.6e-002 0.13
7 6.4e-002 5.9e-001 1.8e+002 1.10e+000 7.205562587e+002 -6.979302701e+002 7.3e-002 0.14
8 3.3e-002 3.0e-001 1.3e+002 1.17e+000 3.466250208e+002 -3.400687006e+002 3.8e-002 0.14
9 1.6e-002 1.5e-001 9.2e+001 1.12e+000 1.705030111e+002 -1.551049205e+002 1.8e-002 0.14
10 6.9e-003 6.3e-002 6.0e+001 1.05e+000 8.409433841e+001 -5.598981845e+001 7.9e-003 0.14
11 1.0e-003 9.3e-003 2.2e+001 1.02e+000 3.603169741e+001 1.551606729e+001 1.2e-003 0.16
12 3.2e-004 2.9e-003 1.2e+001 9.98e-001 3.156897647e+001 2.516400520e+001 3.6e-004 0.16
13 9.3e-005 8.5e-004 6.8e+000 9.99e-001 3.015079879e+001 2.827688987e+001 1.1e-004 0.16
14 2.6e-005 2.4e-004 3.6e+000 9.99e-001 2.971661126e+001 2.918548213e+001 3.0e-005 0.16
15 3.2e-006 2.9e-005 1.3e+000 1.00e+000 2.954893604e+001 2.948407972e+001 3.7e-006 0.16
16 9.9e-008 9.0e-007 2.2e-001 1.00e+000 2.952596342e+001 2.952396895e+001 1.1e-007 0.17
17 4.5e-009 5.1e-008 4.7e-002 1.00e+000 2.952526797e+001 2.952517667e+001 5.2e-009 0.17
18 1.2e-010 1.4e-009 7.9e-003 1.00e+000 2.952523561e+001 2.952523309e+001 1.4e-010 0.17
19 8.0e-012 1.0e-009 1.5e-003 1.00e+000 2.952523477e+001 2.952523467e+001 5.5e-012 0.17
Interior-point optimizer terminated. Time: 0.19.

Optimizer terminated. Time: 0.20

Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: 2.9525234768e+001 nrm: 5e+000 Viol. con: 1e-009 var: 5e-010 cones: 3e-011
Dual. obj: 2.9525234651e+001 nrm: 4e+001 Viol. con: 0e+000 var: 5e-009 cones: 3e-009
Optimizer summary
Optimizer - time: 0.20
Interior-point - iterations : 19 time: 0.19
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): +29.5252

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Mosek 8.0.0.60: 5899 variables, 2500 equality constraints

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4925).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4926).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4927).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4928).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4929).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4930).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4931).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4932).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4933).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4934).
Warning number 57 is disabled.
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2500
Cones : 2199
Scalar variables : 5899
Matrix variables : 0
Integer variables : 0

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 300
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.05
Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 1200
Optimizer - Cones : 2200
Optimizer - Scalar variables : 5800 conic : 5600
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 : 8350 after factor : 8850
Factor - dense dim. : 0 flops : 6.88e+005
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.0e+000 2.7e+011 2.3e+014 0.00e+000 1.567973246e+022 0.000000000e+000 1.0e+000 0.06
1 1.8e-001 4.9e+010 1.8e+013 -1.00e+000 1.560287714e+022 -1.980439559e+007 1.8e-001 0.11
2 1.6e-003 4.3e+008 1.5e+010 -1.00e+000 1.604682313e+022 -2.943260257e+009 1.6e-003 0.11
3 3.0e-006 8.3e+005 1.3e+006 -1.00e+000 1.602874087e+022 -1.505809020e+012 3.1e-006 0.11
4 5.9e-009 1.6e+003 1.1e+002 -1.00e+000 1.601892869e+022 -7.690379733e+014 6.0e-009 0.11
5 1.7e-011 4.6e+000 1.8e-002 -9.99e-001 1.318159493e+022 -2.224403141e+017 1.7e-011 0.13
6 1.6e-011 4.4e+000 1.7e-002 -6.10e-001 1.301681005e+022 -2.335253905e+017 1.6e-011 0.14
7 1.6e-011 4.4e+000 1.7e-002 -5.89e-001 1.301681005e+022 -2.335253905e+017 1.6e-011 0.16
Interior-point optimizer terminated. Time: 0.17.

Optimizer terminated. Time: 0.22

Interior-point solution summary
Problem status : UNKNOWN
Solution status : UNKNOWN
Primal. obj: 1.3016810049e+022 nrm: 3e+016 Viol. con: 2e+005 var: 0e+000 cones: 2e+002
Dual. obj: -2.3352539055e+017 nrm: 1e+015 Viol. con: 0e+000 var: 2e+015 cones: 0e+000
Optimizer summary
Optimizer - time: 0.22
Interior-point - iterations : 8 time: 0.17
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

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {convex} ./ {invalid}

Error in ./ (line 19)
z = times( x, y, ‘./’ );

Error in RegularizedLogisticRegressionTest (line 30)
minimize (-testLabel’testData2betaR + sum(log_sum_exp([zeros(1,rX);
betaR’testData2’])) +
0.5
lambdaR*sum(abs(betaR(2:end))./(sqrt(abs(betaR_k(2:end)))+eps)));

With Gurobi, it gives out,

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Mosek 8.0.0.60: 5899 variables, 2500 equality constraints

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2500
Cones : 2199
Scalar variables : 5899
Matrix variables : 0
Integer variables : 0

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 300
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.05
Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 1200
Optimizer - Cones : 2200
Optimizer - Scalar variables : 5800 conic : 5600
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 : 8350 after factor : 8850
Factor - dense dim. : 0 flops : 6.88e+005
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 8.7e-001 8.0e+000 8.6e+002 0.00e+000 1.373133333e+004 0.000000000e+000 1.0e+000 0.06
1 6.0e-001 5.5e+000 5.8e+002 -4.41e-001 1.095796133e+004 -1.002337027e+003 6.9e-001 0.11
2 5.6e-001 5.1e+000 5.3e+002 -3.05e-001 1.054121644e+004 -1.195364154e+003 6.4e-001 0.11
3 2.8e-001 2.6e+000 3.0e+002 -1.82e-001 4.922921032e+003 -2.769974696e+003 3.2e-001 0.11
4 1.9e-001 1.7e+000 2.7e+002 7.74e-001 2.660359039e+003 -2.221724825e+003 2.1e-001 0.11
5 1.0e-001 9.4e-001 2.3e+002 1.05e+000 1.233056177e+003 -1.182113662e+003 1.2e-001 0.13
6 6.6e-002 6.0e-001 1.9e+002 1.22e+000 7.442690668e+002 -7.112369068e+002 7.6e-002 0.13
7 6.4e-002 5.9e-001 1.8e+002 1.10e+000 7.205562587e+002 -6.979302701e+002 7.3e-002 0.13
8 3.3e-002 3.0e-001 1.3e+002 1.17e+000 3.466250208e+002 -3.400687006e+002 3.8e-002 0.13
9 1.6e-002 1.5e-001 9.2e+001 1.12e+000 1.705030111e+002 -1.551049205e+002 1.8e-002 0.14
10 6.9e-003 6.3e-002 6.0e+001 1.05e+000 8.409433841e+001 -5.598981845e+001 7.9e-003 0.14
11 1.0e-003 9.3e-003 2.2e+001 1.02e+000 3.603169741e+001 1.551606729e+001 1.2e-003 0.14
12 3.2e-004 2.9e-003 1.2e+001 9.98e-001 3.156897647e+001 2.516400520e+001 3.6e-004 0.16
13 9.3e-005 8.5e-004 6.8e+000 9.99e-001 3.015079879e+001 2.827688987e+001 1.1e-004 0.16
14 2.6e-005 2.4e-004 3.6e+000 9.99e-001 2.971661126e+001 2.918548213e+001 3.0e-005 0.16
15 3.2e-006 2.9e-005 1.3e+000 1.00e+000 2.954893604e+001 2.948407972e+001 3.7e-006 0.17
16 9.9e-008 9.0e-007 2.2e-001 1.00e+000 2.952596342e+001 2.952396895e+001 1.1e-007 0.17
17 4.5e-009 5.1e-008 4.7e-002 1.00e+000 2.952526797e+001 2.952517667e+001 5.2e-009 0.17
18 1.2e-010 1.4e-009 7.9e-003 1.00e+000 2.952523561e+001 2.952523309e+001 1.4e-010 0.19
19 8.0e-012 1.0e-009 1.5e-003 1.00e+000 2.952523477e+001 2.952523467e+001 5.5e-012 0.19
Interior-point optimizer terminated. Time: 0.19.

Optimizer terminated. Time: 0.23

Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: 2.9525234768e+001 nrm: 5e+000 Viol. con: 1e-009 var: 5e-010 cones: 3e-011
Dual. obj: 2.9525234651e+001 nrm: 4e+001 Viol. con: 0e+000 var: 5e-009 cones: 3e-009
Optimizer summary
Optimizer - time: 0.23
Interior-point - iterations : 19 time: 0.19
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): +29.5252

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Mosek 8.0.0.60: 5899 variables, 2500 equality constraints

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4925).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4926).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4927).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4928).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4929).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4930).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4931).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4932).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4933).
MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘’ (4934).
Warning number 57 is disabled.
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2500
Cones : 2199
Scalar variables : 5899
Matrix variables : 0
Integer variables : 0

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 300
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.03
Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 1200
Optimizer - Cones : 2200
Optimizer - Scalar variables : 5800 conic : 5600
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 : 8350 after factor : 8850
Factor - dense dim. : 0 flops : 6.88e+005
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.0e+000 2.7e+011 2.3e+014 0.00e+000 1.567973246e+022 0.000000000e+000 1.0e+000 0.05
1 1.8e-001 4.9e+010 1.8e+013 -1.00e+000 1.560287714e+022 -1.980439559e+007 1.8e-001 0.09
2 1.6e-003 4.3e+008 1.5e+010 -1.00e+000 1.604682313e+022 -2.943260257e+009 1.6e-003 0.09
3 3.0e-006 8.3e+005 1.3e+006 -1.00e+000 1.602874087e+022 -1.505809020e+012 3.1e-006 0.09
4 5.9e-009 1.6e+003 1.1e+002 -1.00e+000 1.601892869e+022 -7.690379733e+014 6.0e-009 0.09
5 1.7e-011 4.6e+000 1.8e-002 -9.99e-001 1.318159493e+022 -2.224403141e+017 1.7e-011 0.11
6 1.6e-011 4.4e+000 1.7e-002 -6.10e-001 1.301681005e+022 -2.335253905e+017 1.6e-011 0.11
7 1.6e-011 4.4e+000 1.7e-002 -5.89e-001 1.301681005e+022 -2.335253905e+017 1.6e-011 0.13
Interior-point optimizer terminated. Time: 0.14.

Optimizer terminated. Time: 0.20

Interior-point solution summary
Problem status : UNKNOWN
Solution status : UNKNOWN
Primal. obj: 1.3016810049e+022 nrm: 3e+016 Viol. con: 2e+005 var: 0e+000 cones: 2e+002
Dual. obj: -2.3352539055e+017 nrm: 1e+015 Viol. con: 0e+000 var: 2e+015 cones: 0e+000
Optimizer summary
Optimizer - time: 0.20
Interior-point - iterations : 8 time: 0.14
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

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {convex} ./ {invalid}

Error in ./ (line 19)
z = times( x, y, ‘./’ );

Error in RegularizedLogisticRegressionTest (line 30)
minimize (-testLabel’testData2betaR + sum(log_sum_exp([zeros(1,rX);
betaR’testData2’])) +
0.5
lambdaR*sum(abs(betaR(2:end))./(sqrt(abs(betaR_k(2:end)))+eps)));

Mosek provided warnings:

MOSEK warning 57: A large value of 2.3e+015 has been specified in cx for variable ‘

You should try to examine the models you are creating, at least for the 2nd and following while loop iterations (problems). Those very large values which Mosek are warning about are apparently causing great difficulty for the solver, and it doesn’t appear to solve that 2nd iteration. I think CVX exits with NaN variable values, which get fed into the next iteration, causing a n “invalid” when NaN appears in a CVX expression.

CVXQUAD introduces a lot of 2 by 2 LMIs, which CVX converts to Second Order Cone constraints before providing the problem to the solver.

I will defer to the Mosek guys to make any more detailed assessment.

The standard logistic regression with these data is OK. But when regularization terms added, it gives out NaN here and there.

I don’t have much to add. Like Mark mentioned, the large bounds should raise a red flag.

I would love if you took the time to implement your model in MOSEK Fusion to test the new native exponential cone solver (or perhaps in CVXPY, which should support the exponential cone in MOSEK). We have many examples in the documentation and in the MOSEK Cookbook on exponential cone optimization, and I am convinced that your models will be solved much faster and more reliably if you go that route. If you contact support@mosek.com, you can get a prerelease version of MOSEK 9.0, which is scheduled for beta release soon.

1 Like

Or better support@mosek.com

I may have disgressed from my question.
The first a few steps seem OK before the NaN appears.

Could you help me find out why it gives out NaN here ?

lambdaR =

 1

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Gurobi 7.52: 6499 variables, 3100 equality constraints

Gurobi optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only
Optimize a model with 3100 rows, 6499 columns and 14466 nonzeros
Model has 2199 quadratic constraints
Coefficient statistics:
Matrix range [2e-04, 8e+00]
QMatrix range [1e+00, 1e+00]
Objective range [3e-16, 1e+01]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+00]
Presolve removed 100 rows and 1900 columns
Presolve time: 0.02s
Presolved: 3000 rows, 4599 columns, 14166 nonzeros
Presolved model has 1349 second-order cone constraints
Ordering time: 0.00s

Barrier statistics:
Free vars : 601
AA’ NZ : 2.015e+04
Factor NZ : 2.745e+04 (roughly 3 MBytes of memory)
Factor Ops : 5.378e+05 (less than 1 second per iteration)
Threads : 1

              Objective                Residual

Iter Primal Dual Primal Dual Compl Time
0 1.03191050e+03 -2.32929406e-04 2.88e+00 1.98e+01 6.25e+00 0s
1 2.10346823e+04 -8.92446763e+02 5.14e-01 6.68e+00 5.55e+00 0s
2 4.60164553e+03 -5.87567123e+02 1.49e-01 4.03e+00 1.82e+00 0s
3 1.70681069e+03 -3.61257117e+02 4.83e-02 2.21e+00 8.14e-01 0s
4 5.55949643e+02 -8.21485391e+01 1.36e-02 4.33e-01 2.19e-01 0s
5 1.52971925e+02 6.77146168e+00 3.15e-03 1.86e-03 3.90e-02 0s
6 4.93622565e+01 2.56034920e+01 5.30e-04 1.68e-04 6.34e-03 0s
7 3.69656859e+01 2.81950781e+01 2.07e-04 3.01e-05 2.35e-03 0s
8 3.21301535e+01 2.88491380e+01 7.68e-05 7.93e-06 8.78e-04 0s
9 3.02285246e+01 2.92261900e+01 2.29e-05 1.17e-06 2.68e-04 0s
10 2.96166584e+01 2.94750868e+01 3.13e-06 2.59e-08 3.77e-05 0s
11 2.95295742e+01 2.95220015e+01 8.50e-08 3.38e-08 1.93e-06 0s
12 2.95254205e+01 2.95251945e+01 3.96e-09 4.76e-09 5.91e-08 0s
13 2.95252568e+01 2.95252306e+01 5.55e-10 1.39e-09 6.85e-09 0s
14 2.95252358e+01 2.95252335e+01 6.48e-10 1.79e-09 5.67e-10 0s
15 2.95252349e+01 2.95252346e+01 2.33e-10 3.54e-09 7.25e-11 0s

Barrier solved model in 15 iterations and 0.15 seconds
Optimal objective 2.95252349e+01

Warning: to get QCP duals, please set parameter QCPDual to 1


Status: Solved
Optimal value (cvx_optval): +29.5252

33 betaR_k = betaR;

Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Gurobi 7.52: 6499 variables, 3100 equality constraints

Gurobi optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only
Optimize a model with 3100 rows, 6499 columns and 14466 nonzeros
Model has 2199 quadratic constraints
Coefficient statistics:
Matrix range [2e-04, 8e+00]
QMatrix range [1e+00, 1e+00]
Objective range [3e-16, 2e+15]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+00]
Warning: Model contains large objective coefficients
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
Presolve removed 100 rows and 1900 columns
Presolve time: 0.04s
Presolved: 3000 rows, 4599 columns, 14166 nonzeros
Presolved model has 1349 second-order cone constraints
Ordering time: 0.00s

Barrier statistics:
Free vars : 601
AA’ NZ : 2.015e+04
Factor NZ : 2.745e+04 (roughly 3 MBytes of memory)
Factor Ops : 5.378e+05 (less than 1 second per iteration)
Threads : 1

              Objective                Residual

Iter Primal Dual Primal Dual Compl Time
0 3.01675108e+07 -2.32929406e-04 3.07e+00 4.96e+03 1.15e+04 0s
1 3.99042416e+04 -9.00007366e+05 3.36e-03 1.75e+02 3.20e+02 0s
2 3.95583531e+03 -2.26773242e+04 4.04e-05 4.97e+00 8.86e+00 0s
3 1.28578120e+03 -8.76126631e+03 4.42e-06 1.98e+00 3.22e+00 0s
4 5.75292234e+02 -3.41653370e+03 8.90e-08 7.48e-01 1.23e+00 0s
5 4.91224106e+02 -1.41769871e+03 6.59e-08 3.13e-01 5.72e-01 0s
6 1.81825724e+02 -2.40020054e+02 1.31e-08 4.68e-02 1.18e-01 0s
7 5.09913643e+01 5.15411533e+00 1.32e-09 2.74e-03 1.20e-02 0s
8 3.06866767e+01 2.42402012e+01 2.19e-10 2.44e-04 1.64e-03 0s
9 2.83382707e+01 2.56039630e+01 9.83e-11 8.63e-05 6.91e-04 0s
10 2.72413906e+01 2.61054361e+01 4.03e-11 3.41e-05 2.87e-04 0s
11 2.67068860e+01 2.63251921e+01 4.09e-11 1.19e-05 9.64e-05 0s
12 2.65526101e+01 2.64107810e+01 8.67e-11 3.79e-06 3.56e-05 0s
13 2.64766111e+01 2.64470015e+01 4.45e-10 5.99e-07 7.36e-06 0s
14 2.64563078e+01 2.64537354e+01 5.03e-11 2.31e-08 6.32e-07 0s
15 2.64541405e+01 2.64540920e+01 6.23e-11 1.86e-08 1.18e-08 0s
16 2.64541004e+01 2.64540971e+01 5.83e-10 8.55e-09 8.15e-10 0s
17 2.64540980e+01 2.64540975e+01 1.03e-09 2.24e-08 1.22e-10 0s
18 2.64540976e+01 2.64540975e+01 1.66e-08 6.72e-06 2.16e-11 0s

Barrier solved model in 18 iterations and 0.18 seconds
Optimal objective 2.64540976e+01

Warning: to get QCP duals, please set parameter QCPDual to 1


Status: Solved
Optimal value (cvx_optval): +26.4541

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Gurobi 7.52: 6499 variables, 3100 equality constraints

Gurobi optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only
Optimize a model with 3100 rows, 6499 columns and 14466 nonzeros
Model has 2199 quadratic constraints
Coefficient statistics:
Matrix range [2e-04, 8e+00]
QMatrix range [1e+00, 1e+00]
Objective range [3e-16, 2e+15]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+00]
Warning: Model contains large objective coefficients
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
Presolve removed 100 rows and 1900 columns
Presolve time: 0.04s
Presolved: 3000 rows, 4599 columns, 14166 nonzeros
Presolved model has 1349 second-order cone constraints
Ordering time: 0.00s

Barrier statistics:
Free vars : 601
AA’ NZ : 2.015e+04
Factor NZ : 2.745e+04 (roughly 3 MBytes of memory)
Factor Ops : 5.378e+05 (less than 1 second per iteration)
Threads : 1

              Objective                Residual

Iter Primal Dual Primal Dual Compl Time
0 1.22672522e+13 -2.32929406e-04 3.07e+00 2.01e+09 4.66e+09 0s
1 1.46875123e+10 -3.64844414e+11 3.36e-03 7.30e+07 1.30e+08 0s
2 1.69482448e+07 -4.18129606e+08 3.70e-06 8.16e+04 1.48e+05 0s
3 1.10458176e+05 -4.75712632e+05 4.14e-09 9.27e+01 1.90e+02 0s
4 7.77828721e+03 -3.32768179e+04 1.59e-10 6.30e+00 1.30e+01 0s
5 1.05059866e+03 -9.25073945e+03 1.13e-10 1.90e+00 3.22e+00 0s
6 5.61022650e+02 -3.65813823e+03 2.64e-10 7.42e-01 1.29e+00 0s
7 3.42794619e+02 -1.17605916e+03 3.40e-10 2.46e-01 4.52e-01 0s
8 1.22015645e+02 -7.18947611e+01 1.31e-10 2.01e-02 5.34e-02 0s
9 4.18670431e+01 1.33759299e+01 3.45e-11 2.62e-03 7.69e-03 0s
10 3.00747191e+01 2.30240473e+01 4.04e-11 1.40e-03 1.81e-03 0s
11 2.74728648e+01 2.41341903e+01 2.07e-11 1.22e-04 8.46e-04 0s
12 2.60897173e+01 2.45178024e+01 1.04e-11 3.05e-04 3.97e-04 0s
13 2.51149706e+01 2.47913696e+01 2.06e-12 4.27e-04 8.08e-05 0s
14 2.48883051e+01 2.48536229e+01 2.30e-12 6.41e-04 8.60e-06 0s
15 2.48631450e+01 2.48594473e+01 2.03e-11 7.32e-04 9.23e-07 0s
16 2.48607260e+01 2.48605846e+01 1.55e-10 8.54e-04 3.45e-08 0s
17 2.48606141e+01 2.48606016e+01 3.88e-09 9.16e-04 3.05e-09 0s
18 2.48606035e+01 2.48606028e+01 3.73e-10 3.45e+10 1.63e-10 0s
19 2.48606067e+01 2.48606028e+01 7.23e-08 3.06e+13 3.35e-09 0s
20 2.48608615e+01 2.48606028e+01 1.21e-07 2.84e+13 1.74e-07 0s
21 2.48621294e+01 2.48606028e+01 1.43e-07 2.77e+13 4.66e-07 0s
22 2.48788597e+01 2.48606028e+01 1.21e-07 2.75e+13 9.51e-07 0s
23 2.54943573e+01 2.48606028e+01 1.63e-07 2.74e+13 4.98e-06 0s
24 4.38115224e+01 2.48606028e+01 1.78e-07 2.74e+13 6.75e-05 0s
25 1.85213789e+02 2.48606028e+01 2.81e-07 2.74e+13 3.09e-04 0s
26 4.57576920e+06 2.48606028e+01 4.20e-04 2.74e+13 4.75e+00 0s
27 1.69945066e+08 2.48606027e+01 1.11e-03 2.74e+13 9.68e+01 0s
28 5.17200147e+08 2.48606025e+01 1.14e-03 2.74e+13 1.62e+02 0s
29 6.72163892e+10 2.48606024e+01 1.09e-03 2.74e+13 1.16e+04 0s
30 1.32417785e+11 2.48606001e+01 1.09e-03 2.73e+13 1.26e+04 0s
31 1.18962504e+13 2.48605993e+01 1.09e-03 2.73e+13 6.20e+05 0s
32 2.94455042e+13 2.48605879e+01 1.09e-03 2.72e+13 8.44e+05 0s
33 1.49820472e+15 2.48605832e+01 1.09e-03 2.71e+13 2.36e+07 0s
34 4.93178428e+15 2.48605435e+01 1.09e-03 2.66e+13 4.28e+07 0s
35 1.45140120e+17 2.48605219e+01 1.09e-03 2.63e+13 6.92e+08 0s
36 6.68881092e+17 2.48604155e+01 1.09e-03 2.56e+13 1.76e+09 0s
37 1.15642490e+19 2.48603342e+01 1.09e-03 2.51e+13 1.67e+10 0s
38 8.29452506e+19 2.48600998e+01 1.09e-03 2.43e+13 6.58e+10 0s

Barrier performed 38 iterations in 0.41 seconds
Sub-optimal termination - objective 2.48607260e+01

Warning: to get QCP duals, please set parameter QCPDual to 1


Status: Inaccurate/Solved
Optimal value (cvx_optval): +24.8607

=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3

Calling Gurobi 7.52: 6499 variables, 3100 equality constraints

Gurobi optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only
Optimize a model with 3100 rows, 6499 columns and 14466 nonzeros
Model has 2199 quadratic constraints
Coefficient statistics:
Matrix range [2e-04, 8e+00]
QMatrix range [1e+00, 1e+00]
Objective range [3e-16, 2e+15]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+00]
Warning: Model contains large objective coefficients
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
Presolve removed 100 rows and 1900 columns
Presolve time: 0.04s
Presolved: 3000 rows, 4599 columns, 14166 nonzeros
Presolved model has 1349 second-order cone constraints
Ordering time: 0.00s

Barrier statistics:
Free vars : 601
AA’ NZ : 2.015e+04
Factor NZ : 2.745e+04 (roughly 3 MBytes of memory)
Factor Ops : 5.378e+05 (less than 1 second per iteration)
Threads : 1

              Objective                Residual

Iter Primal Dual Primal Dual Compl Time
0 1.01097710e+17 -2.32929406e-04 3.07e+00 1.66e+13 3.66e+13 0s
1 8.45779933e+14 -2.98656249e+15 2.41e-02 7.10e+11 1.25e+12 0s
2 8.00564662e+12 -3.49369089e+13 2.21e-04 7.30e+09 1.34e+10 0s
3 5.99406927e+10 -2.56784061e+11 1.62e-06 5.37e+07 9.89e+07 0s
4 6.90132878e+08 -2.40280978e+09 1.52e-08 5.02e+05 9.56e+05 0s
5 1.84737069e+06 -6.38325038e+06 4.03e-11 1.33e+03 2.54e+03 0s
6 7.70881756e+03 -2.28949595e+04 2.85e-13 9.00e+00 9.27e+00 0s
7 1.20554052e+03 -9.65465639e+03 1.41e-11 2.25e+00 3.30e+00 0s
8 5.43238328e+02 -4.00586845e+03 7.33e-11 2.00e+00 1.36e+00 0s
9 4.58936738e+02 -2.06794990e+03 5.35e-11 1.23e+13 7.46e-01 0s
10 2.09809483e+02 -2.00078648e+02 1.04e-11 1.85e+14 1.14e-01 0s
11 7.17021645e+01 3.77893798e+00 1.12e-11 3.18e+14 1.70e-02 0s
12 3.41955676e+01 2.20435900e+01 1.70e-11 5.66e+14 2.73e-03 0s
13 1.07964604e+04 2.26195200e+01 1.14e-11 1.17e+19 1.29e+03 0s
14 1.07576355e+04 2.22982459e+01 3.35e-11 1.17e+19 1.29e+03 0s
15 1.07727329e+04 2.05726771e+01 4.69e-11 1.17e+19 1.29e+03 0s
16 1.08220141e+04 1.56798087e+01 1.57e-10 1.17e+19 1.29e+03 0s
17 1.08877547e+04 -1.51215256e-01 2.57e-10 1.17e+19 1.29e+03 0s
18 1.10099408e+04 -2.56860870e+01 3.60e-10 1.17e+19 1.29e+03 0s
19 1.12972170e+04 -6.53383297e+01 3.60e-10 1.16e+19 1.28e+03 0s
20 2.91061541e+04 -6.54272998e+01 3.42e-10 1.16e+19 1.13e+03 0s
21 2.95252209e+07 -6.54324982e+01 2.43e-10 1.15e+19 9.80e+02 0s
22 2.59953059e+09 -6.55939240e+01 2.32e-10 1.15e+19 3.84e+03 0s
23 8.42141693e+11 -6.56462722e+01 2.24e-10 1.15e+19 5.17e+05 0s
24 2.79406211e+12 -1.61944458e+02 2.35e-10 1.15e+19 9.42e+05 0s
25 2.07768324e+13 -2.16985997e+02 2.46e-10 1.15e+19 3.85e+06 0s
26 1.27076575e+14 -2.85837821e+02 2.50e-10 1.15e+19 1.30e+07 0s
27 1.36698699e+15 -3.56428683e+02 2.46e-10 1.15e+19 7.66e+07 0s
28 6.48760442e+15 -4.84549061e+02 2.49e-10 1.15e+19 2.00e+08 0s
29 7.84744495e+16 -5.86068006e+02 2.22e-10 1.15e+19 1.33e+09 0s
30 3.53297467e+17 -7.92368596e+02 2.24e-10 1.15e+19 3.30e+09 0s
31 4.17623092e+18 -9.47203335e+02 2.36e-10 1.15e+19 2.14e+10 0s
32 1.94083314e+19 -1.25344687e+03 2.31e-10 1.15e+19 5.48e+10 0s
33 2.17192210e+20 -1.49052440e+03 2.31e-10 1.15e+19 3.37e+11 0s
34 1.05895697e+21 -1.93335921e+03 2.43e-10 1.15e+19 9.04e+11 0s
35 1.12803268e+22 -2.29284701e+03 2.36e-10 1.15e+19 5.29e+12 0s
36 5.72787043e+22 -2.93115173e+03 2.42e-10 1.15e+19 1.48e+13 0s
37 4.45286845e+19 -1.85962714e-02 2.00e+03 1.32e+15 4.77e+14 0s
38 4.38391136e+19 -7.63815829e+16 1.98e+03 1.04e+15 3.30e+16 0s
39 2.21274477e+18 -3.18436640e+17 1.69e+02 2.64e+13 1.15e+16 0s
40 2.56102477e+16 -2.34511177e+17 1.34e+01 2.68e+12 6.86e+14 0s
41 2.62087668e+15 -1.52524301e+16 4.09e-03 1.76e+10 5.01e+12 0s
42 8.55657542e+12 -4.96208988e+13 1.38e-05 5.74e+07 1.63e+10 0s
43 1.20708259e+10 -7.08891145e+10 1.61e-05 8.93e+04 2.31e+07 0s
44 6.72026101e+08 -5.25022398e+09 4.53e-06 6.64e+03 1.60e+06 0s
45 8.54720967e+07 -2.85509752e+09 8.16e-06 3.62e+03 7.36e+05 0s
46 7.49181745e+06 -1.54521776e+09 3.18e-06 1.97e+03 3.80e+05 0s
47 7.31697279e+06 -9.21955783e+08 2.33e-06 1.18e+03 2.27e+05 0s
48 6.26960744e+06 -6.92031615e+08 2.35e-06 8.92e+02 1.71e+05 0s
49 5.72723670e+06 -3.16018556e+08 1.71e-06 4.14e+02 7.88e+04 0s
50 2.42611765e+06 -1.77615530e+08 2.91e-06 2.39e+02 4.41e+04 0s
51 3.19016585e+05 -2.78871251e+05 2.35e-06 1.74e+01 1.43e+02 0s
52 4.03336100e+04 -9.35364179e+03 2.97e-07 4.73e+00 1.22e+01 0s
53 5.92566537e+03 -1.08969027e+03 4.31e-08 5.38e+00 1.71e+00 0s
54 9.91473755e+02 -1.54875099e+02 7.36e-09 6.04e+00 2.80e-01 0s
55 2.31824592e+02 -4.60931101e+01 1.68e-09 5.99e+00 6.79e-02 0s
56 6.21721160e+01 1.25524533e+01 3.25e-10 1.35e+14 1.16e-02 1s
57 4.12906389e+01 1.90893786e+01 1.51e-10 2.70e+14 4.84e-03 1s
58 3.32296949e+01 2.08293770e+01 8.40e-11 3.56e+14 2.61e-03 1s
59 2.93535387e+01 2.22253011e+01 8.85e-11 2.85e+14 1.40e-03 1s
60 2.87238337e+01 2.31392451e+01 8.32e-11 4.60e+17 3.21e-03 1s
61 3.97706949e+01 2.31392451e+01 8.32e-11 2.75e+19 3.21e-03 1s
62 6.88556364e+01 2.31392456e+01 2.36e-08 1.77e+19 3.71e-03 1s
63 7.01495855e+01 2.31392456e+01 2.36e-08 3.26e+19 3.71e-03 1s
64 8.14545787e+01 2.31392458e+01 2.27e-08 2.35e+19 3.20e-03 1s
65 8.19162358e+01 2.31392458e+01 2.27e-08 6.52e+19 3.20e-03 1s
66 1.57562032e+02 2.31392458e+01 2.26e-08 2.36e+19 3.15e-03 1s
67 1.57635316e+02 2.31392458e+01 2.26e-08 2.36e+19 3.15e-03 1s
68 3.72750639e+02 2.31392458e+01 2.26e-08 2.37e+19 2.88e-03 1s
69 3.72762489e+02 2.31392458e+01 2.26e-08 2.37e+19 2.88e-03 1s
70 3.97404539e+02 2.31392463e+01 2.26e-08 3.24e+19 2.85e-03 1s
71 3.97478519e+02 2.31392463e+01 2.26e-08 3.24e+19 2.85e-03 1s
72 4.18118663e+02 2.31392542e+01 2.30e-08 2.74e+20 3.45e-03 1s
73 4.19433937e+02 2.31392542e+01 2.30e-08 8.67e+20 3.45e-03 1s
74 4.21560753e+02 2.31392748e+01 2.31e-08 6.81e+22 8.01e-03 1s
75 4.28049899e+02 2.31392748e+01 2.31e-08 1.18e+24 8.01e-03 1s
76 2.84816501e+04 2.31392748e+01 2.31e-08 1.20e+23 1.57e+00 1s
77 2.84822044e+04 2.31392748e+01 2.31e-08 1.44e+23 1.57e+00 1s
78 2.84822044e+04 2.31392748e+01 2.31e-08 1.44e+23 1.57e+00 1s

Barrier performed 78 iterations in 0.73 seconds
Numerical trouble encountered


Status: Failed
Optimal value (cvx_optval): NaN

On the last problem instance, Gurobi reported “Numerical trouble encountered”, so the solution to the optimization problem wasn’t found. hence, CVX provided status “Failed”, CVX will produce NaN values if the solver fails to solve the problem - that is what happened in this case.

Mosek warned you about very large input numbers. So did Gurobi, which told you:

Coefficient statistics:
Matrix range [2e-04, 8e+00]
QMatrix range [1e+00, 1e+00]
Objective range [3e-16, 2e+15]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+00]
Warning: Model contains large objective coefficients
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.

Gurboi was warning you about the same 2e-15 values that Mosek warned you about. Aside from improving the model formulation, you could try (when using gurobi as cvx_solver), as the above Gurobi output also suggested, setting NumericFocus to 3
http://www.gurobi.com/documentation/7.5/refman/numericfocus.html

NumericFocus

Numerical focus

Type: int
Default value: 0
Minimum value: 0
Maximum value: 3

The NumericFocus parameter controls the degree to which the code attempts to detect and manage numerical issues. The default setting (0) makes an automatic choice, with a slight preference for speed. Settings 1-3 increasingly shift the focus towards being more careful in numerical computations. With higher values, the code will spend more time checking the numerical accuracy of intermediate results, and it will employ more expensive techniques in order to avoid potential numerical issues.

For examples of how to query or modify parameter values from our different APIs, refer to our Parameter Examples.

This can be done using cvx_solver_settings http://cvxr.com/cvx/doc/solver.html#advanced-solver-settings. I believe it would be
cvx_solver_settings('NumericFocus',3)