Skip to content

Commit

Permalink
use CG from iterative solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
migrosser committed Aug 15, 2019
1 parent 1bddd87 commit 1d81120
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
18 changes: 4 additions & 14 deletions src/ADMM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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...)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/RegularizedLeastSquares.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 2 additions & 6 deletions src/SplitBregman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1d81120

Please sign in to comment.