From 1d81120688b6fde620cee98fc8efb2056076aa16 Mon Sep 17 00:00:00 2001 From: migrosser Date: Thu, 15 Aug 2019 13:19:02 +0000 Subject: [PATCH] use CG from iterative solvers --- src/ADMM.jl | 18 ++++-------------- src/RegularizedLeastSquares.jl | 2 +- src/SplitBregman.jl | 8 ++------ 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/ADMM.jl b/src/ADMM.jl index 07cbeacd..6325356f 100644 --- a/src/ADMM.jl +++ b/src/ADMM.jl @@ -85,7 +85,7 @@ function admm(A, b::Vector, reg::Regularization , iterationsInner::Int64=10 , absTol::Float64=1.e-8 , relTol::Float64=1.e-6 - , tolInner::Float64=1.e-3 + , tolInner::Float64=1.e-5 , adaptRho::Bool=false , solverInfo = nothing , kargs...) @@ -118,12 +118,7 @@ function admm(A, b::Vector, reg::Regularization # 1. solve arg min_x 1/2|| Ax-b ||² + ρ/2 ||x+u-z||² # <=> (A'A+ρ)*x = A'b+ρ(z-u) xᵒˡᵈ[:] = x[:] - # cg!(x,A'*A+ρ*opEye(length(x)),β+ρ*(z-u),Pl=precon,maxiter=iterationsInner,tol=tolInner) - if isa(precon, Identity) - x[:] = cg(A'*A+ρ*opEye(length(x)),x,β+ρ*(z-u),iterations=iterationsInner,relTol=tolInner,solverInfo=solverInfo,storeIterations=true) - else - x[:] = cg(A'*A+ρ*opEye(length(x)),x,β+ρ*(z-u),precon,iterations=iterationsInner,relTol=tolInner,solverInfo=solverInfo,storeIterations=true) - end + cg!(x,A'*A+ρ*opEye(length(x)),β+ρ*(z-u),Pl=precon,maxiter=iterationsInner,tol=tolInner) # 2. update z using the proximal map of 1/ρ*g(x) zᵒˡᵈ[:] = z @@ -171,7 +166,7 @@ function fadmm(A, b::Vector, reg::Regularization , iterationsInner::Int64=10 , absTol::Float64=1.e-8 , relTol::Float64=1.e-6 - , tolInner::Float64=1.e-3 + , tolInner::Float64=1.e-5 , adaptRho::Bool=false , solverInfo = nothing , kargs...) @@ -210,12 +205,7 @@ function fadmm(A, b::Vector, reg::Regularization # 1. solve arg min_x 1/2|| Ax-b ||² + ρ/2 ||x+û-ẑ||² # <=> (A'A+ρ)*x = A'b+ρ(z-u) xᵒˡᵈ[:] = x[:] - # cg!(x,A'*A+ρ*opEye(length(x)),β+ρ*(ẑ-û),Pl=precon,maxiter=iterationsInner,tol=tolInner) - if isa(precon, Identity) - x[:] = cg(A'*A+ρ*opEye(length(x)),x,β+ρ*(z-u),iterations=iterationsInner,relTol=tolInner,solverInfo=solverInfo) - else - x[:] = cg(A'*A+ρ*opEye(length(x)),x,β+ρ*(z-u),precon,iterations=iterationsInner,relTol=tolInner,solverInfo=solverInfo) - end + cg!(x,A'*A+ρ*opEye(length(x)),β+ρ*(ẑ-û),Pl=precon,maxiter=iterationsInner,tol=tolInner) # 2. update z using the proximal map of 1/ρ*g(x) zᵒˡᵈ[:] = z diff --git a/src/RegularizedLeastSquares.jl b/src/RegularizedLeastSquares.jl index 73b296f6..08c69bea 100644 --- a/src/RegularizedLeastSquares.jl +++ b/src/RegularizedLeastSquares.jl @@ -36,7 +36,7 @@ include("Utils.jl") include("Kaczmarz.jl") include("DAX.jl") include("CGNR.jl") -include("CG.jl") +# include("CG.jl") include("Direct.jl") include("FusedLasso.jl") include("FISTA.jl") diff --git a/src/SplitBregman.jl b/src/SplitBregman.jl index 865ce04f..82166a21 100644 --- a/src/SplitBregman.jl +++ b/src/SplitBregman.jl @@ -84,7 +84,7 @@ function splitBregman(A, y::Vector, reg::Vector{Regularization} , iterationsCG::Int64=10 , absTol::Float64=1.e-8 , relTol::Float64=1.e-6 - , tolInner::Float64=1.e-3 + , tolInner::Float64=1.e-6 , solverInfo = nothing , kargs...) @@ -117,11 +117,7 @@ function splitBregman(A, y::Vector, reg::Vector{Regularization} for k = 1:iterationsInner # update u analytically β[:] .= β_yj .+ λ*(w-bw) .+ ρ*(v-bv) - if isa(precon, Identity) - u[:] = cg(op,u,β,iterations=iterationsCG,relTol=tolInner,solverInfo=solverInfo,storeIterations=true) - else - u[:] = cg(op,u,β,precon,iterations=iterationsCG,relTol=tolInner,solverInfo=solverInfo,storeIterations=true) - end + cg!(u,op,β,Pl=precon,maxiter=iterationsCG,tol=tolInner) # proximal map for L1 regularization wᵒˡᵈ[:] .= w