Closed nantonel closed 4 years ago
I have an update. I finally used JuMP
by directly specifying the conic formulation of the LASSO that can be found in this paper.
The following script can be added to the one above:
println(" \n \n \n solving JuMP \n \n \n")
using JuMP
A = hcat([[zeros(i);h;zeros(m-1-i)] for i = 0:m-1]...) # Full Matrix
M = Model(solver = SCSSolver())
@variables M begin
x[1:m]
t[1:m]
w
end
@objective(M,Min,0.5*w+lambda*ones(m)'*t)
@constraint(M, soc, norm( [1-w;2*(A*x-y)] ) <= 1+w)
@constraint(M, x .<= t)
@constraint(M, -t .<= x)
solve(M)
xJuMP = getvalue(x)
norm(xcvxpy-xJuMP)
to verify that the very same iterations are performed by SCS
using either cvxpy
or JuMP
. This doesn't happen in Convex.jl
.
I think this confirms my previous guess: it seems Convex.jl
converts the LASSO to the wrong conic formulation.
If I update the code to run on Julia 1.1 and the Convex.jl 0.12.0 (gist), then with the current release of SCS, Convex warns me that there was an "UnknownError" and I can see from the SCS logs it reached the maximum number of iterations, just as in your first post. If I increase the iterations a lot, to 500,000, then it does solve the problem and obtains the same solution as cvxpy with SCS and with Convex.jl + Mosek.
Does that really mean Convex is converting the problem to the wrong conic formulation, as opposed to some correct but inefficient formulation? The first seems much worse to me, although I agree the second is worth looking into as well.
Running the gist on Julia 1.3, Convex 0.13.2 and SCS.jl v0.6.6, I find SCS, Mosek, and cvxpy all give the same answer, and that SCS doesn't need extra iterations etc (the default parameters suffice).
Hi all,
I was testing a simple LASSO problem with
Convex.jl
. I also wanted to see the difference between cvxpy.This is the script I've worked with:
I'm using the very same version of
SCS
(the iterative version has been updated very recently on the master ofSCS.jl
) andConvex.jl
master as well.this is the REPL out for
Convex
withSCS
Convex.jl
+Mosek.jl
Optimizer started. Presolve started. Linear dependency checker started. Linear dependency checker terminated. Eliminator - tries : 0 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 : 135
Cones : 2
Scalar variables : 136
Matrix variables : 0
Integer variables : 0
Optimizer - threads : 4
Optimizer - solved problem : the dual
Optimizer - Constraints : 22 Optimizer - Cones : 2 Optimizer - Scalar variables : 133 conic : 113
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 : 88 after factor : 88
Factor - dense dim. : 0 flops : 1.15e+04
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 2.9e+00 1.0e+00 1.5e+00 0.00e+00 0.000000000e+00 -2.000000000e+00 1.0e+00 0.00
1 4.1e-01 1.4e-01 9.2e-02 -8.75e-01 3.890825350e+00 2.064259366e+01 1.4e-01 0.00
2 9.3e-02 3.3e-02 1.4e-02 -6.96e-01 1.882791814e+01 6.375251688e+01 3.3e-02 0.00
3 2.2e-02 7.6e-03 5.3e-03 1.99e-02 4.514846416e+01 6.260221610e+01 7.6e-03 0.00
4 4.2e-03 1.5e-03 4.9e-03 1.07e+00 5.175112177e+01 5.236274995e+01 1.5e-03 0.00
5 1.8e-03 6.3e-04 6.2e-03 2.58e+00 4.967753607e+01 4.973378283e+01 6.3e-04 0.00
6 7.3e-04 2.6e-04 3.5e-03 3.77e+00 4.893193157e+01 4.897447398e+01 2.6e-04 0.00
7 9.7e-05 3.4e-05 1.4e-03 1.25e+00 4.889900446e+01 4.890362117e+01 3.4e-05 0.00
8 1.5e-05 5.4e-06 5.9e-04 1.03e+00 4.889769587e+01 4.889833210e+01 5.4e-06 0.00
9 6.0e-07 2.1e-07 1.4e-04 1.00e+00 4.889833806e+01 4.889835487e+01 2.1e-07 0.00
10 4.1e-10 4.7e-11 4.0e-06 1.00e+00 4.889832083e+01 4.889832084e+01 4.7e-11 0.00
Optimizer terminated. Time: 0.00
Interior-point solution summary Problem status : PRIMAL_AND_DUAL_FEASIBLE Solution status : OPTIMAL Primal. obj: 4.8898320835e+01 nrm: 1e+02 Viol. con: 2e-16 var: 0e+00 cones: 1e-09
Dual. obj: 4.8898320837e+01 nrm: 2e+01 Viol. con: 0e+00 var: 2e-10 cones: 0e+00