Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ author = ["Robert Baraldi <rbaraldi@uw.edu> and Dominique Orban <dominique.orban
version = "0.1.0"

[deps]
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
Expand All @@ -13,16 +12,17 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ProximalOperators = "a725b495-10eb-56fe-b38b-717eba820537"
ShiftedProximalOperators = "d4fd37fa-580c-4e43-9b30-361c21aae263"
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
TSVD = "9449cd9e-2762-5aa3-a617-5413e99d722e"

[compat]
Arpack = "0.5"
NLPModels = "0.19"
NLPModelsModifiers = "0.6"
ProximalOperators = "0.15"
RegularizedProblems = "0.1"
ShiftedProximalOperators = "0.1"
SolverCore = "0.3.0"
julia = "^1.3.0"
TSVD = "0.4"
julia = "^1.6.0"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
6 changes: 2 additions & 4 deletions src/LMTR_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ function LMTR(
JdFk = similar(Fk) # temporary storage
Jt_Fk = similar(∇fk) # temporary storage

σmax, found_σ = opnorm(Jk)
found_σ || error("operator norm computation failed")
σmax = opnorm(Jk)
νInv = (1 + θ) * σmax^2 # ‖J'J‖ = ‖J‖²

mν∇fk = -∇fk / νInv
Expand Down Expand Up @@ -217,8 +216,7 @@ function LMTR(
shift!(ψ, xk)
Jk = jac_op_residual(nls, xk)
jtprod_residual!(nls, xk, Fk, ∇fk)
σmax, found_σ = opnorm(Jk)
found_σ || error("operator norm computation failed")
σmax = opnorm(Jk)
νInv = (1 + θ) * σmax^2 # ‖J'J‖ = ‖J‖²
@. mν∇fk = -∇fk / νInv
end
Expand Down
6 changes: 2 additions & 4 deletions src/LM_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ function LM(
JdFk = similar(Fk) # temporary storage
Jt_Fk = similar(∇fk)

σmax, found_σ = opnorm(Jk)
found_σ || error("operator norm computation failed")
σmax = opnorm(Jk)
νInv = (1 + θ) * (σmax^2 + σk) # ‖J'J + σₖ I‖ = ‖J‖² + σₖ

s = zero(xk)
Expand Down Expand Up @@ -217,8 +216,7 @@ function LM(
Jk = jac_op_residual(nls, xk)
jtprod_residual!(nls, xk, Fk, ∇fk)

σmax, found_σ = opnorm(Jk)
found_σ || error("operator norm computation failed")
σmax = opnorm(Jk)
νInv = (1 + θ) * (σmax^2 + σk) # ‖J'J + σₖ I‖ = ‖J‖² + σₖ

Complex_hist[k] += 1
Expand Down
2 changes: 1 addition & 1 deletion src/RegularizedOptimization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RegularizedOptimization
using LinearAlgebra, Logging, Printf

# external dependencies
using Arpack, ProximalOperators
using ProximalOperators, TSVD

# dependencies from us
using NLPModels, NLPModelsModifiers, ShiftedProximalOperators, SolverCore
Expand Down
6 changes: 2 additions & 4 deletions src/TR_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ function TR(
quasiNewtTest = isa(f, QuasiNewtonModel)
Bk = hess_op(f, xk)

λmax, found_λ = opnorm(Bk)
found_λ || error("operator norm computation failed")
λmax = opnorm(Bk)
νInv = (1 + θ) * λmax

optimal = false
Expand Down Expand Up @@ -207,8 +206,7 @@ function TR(
push!(f, s, ∇fk - ∇fk⁻)
end
Bk = hess_op(f, xk)
λmax, found_λ = opnorm(Bk)
found_λ || error("operator norm computation failed")
λmax = opnorm(Bk)
νInv = (1 + θ) * λmax
∇fk⁻ .= ∇fk
end
Expand Down
50 changes: 2 additions & 48 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
# use Arpack to obtain largest eigenvalue in magnitude with a minimum of robustness
function LinearAlgebra.opnorm(B; kwargs...)
m, n = size(B)
opnorm_fcn = m == n ? opnorm_eig : opnorm_svd
return opnorm_fcn(B; kwargs...)
end

function opnorm_eig(B; max_attempts::Int = 3)
have_eig = false
attempt = 0
λ = zero(eltype(B))
success = false
n = size(B, 1)
nev = 1
ncv = max(20, 2 * nev + 1)
while !(have_eig || attempt > max_attempts)
attempt += 1
(d, nconv, niter, nmult, resid) =
eigs(B; nev = nev, ncv = ncv, which = :LM, ritzvec = false, check = 1)
have_eig = nconv == 1
if (have_eig)
λ = abs(d[1])
success = true
else
ncv = min(2 * ncv, n)
end
end
return λ, success
end

function opnorm_svd(J; max_attempts::Int = 3)
have_svd = false
attempt = 0
σ = zero(eltype(J))
success = false
n = min(size(J)...)
nsv = 1
ncv = 10
while !(have_svd || attempt > max_attempts)
attempt += 1
(s, nconv, niter, nmult, resid) = svds(J, nsv = nsv, ncv = ncv, ritzvec = false, check = 1)
have_svd = nconv == 1
if (have_svd)
σ = maximum(s.S)
success = true
else
ncv = min(2 * ncv, n)
end
end
return σ, success
_, s, _ = tsvd(B)
return s[1]
end