This commit is contained in:
elvis
2023-11-30 15:24:11 +01:00
parent 5161464087
commit 65c8842e83
2 changed files with 37 additions and 37 deletions

View File

@ -307,16 +307,16 @@ function lasso(x::Union{Nothing, AbstractVecOrMat})
if isnothing(x) # informative call
v = ( 2 - 1/3 )^2 + 10/9 # optimal solution [ 1/9 , 0 ]
return (v, [0, 0])
return (v, [0., 0.], nothing)
else
v = ( 3 * x( 1 ) + 2 * x( 2 ) - 2 )^2 +
10 * ( abs( x( 1 ) ) + abs( x( 2 ) ) ) # f(x)
v = (3 * x[1] + 2 * x[2] - 2)^2 +
10 * (abs(x[1]) + abs(x[2])) # f(x)
g = zeros(2)
g[1] = 18 * x[1] + 12 * x[2] - 12 + 10 * sign( x[1] )
g[2] = 12 * x[1] + 8 * x[2] - 8 + 10 * sign( x[2] )
g[1] = 18 * x[1] + 12 * x[2] - 12 + 10 * sign(x[1])
g[2] = 12 * x[1] + 8 * x[2] - 8 + 10 * sign(x[2])
return (v, g)
return (v, g, nothing)
end
end # lasso