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
13 changes: 7 additions & 6 deletions src/R2_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ function R2(
f::F,
∇f!::G,
h::H,
options::ROSolverOptions,
x0::AbstractVector,
) where {F <: Function, G <: Function, H}
options::ROSolverOptions{R},
x0::AbstractVector{R},
) where {F <: Function, G <: Function, H, R <: Real}
start_time = time()
elapsed_time = 0.0
ϵ = options.ϵ
neg_tol = options.neg_tol
verbose = options.verbose
maxIter = options.maxIter
maxTime = options.maxTime
Expand Down Expand Up @@ -146,13 +147,13 @@ function R2(
Complex_hist[k] += 1
mks = mk(s)
ξ = hk - mks + max(1, abs(hk)) * 10 * eps()
ξ > 0 || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)")

if sqrt(ξ) < ϵ

if (ξ < 0 && sqrt(-ξ) ≤ -neg_tol) || (ξ ≥ 0 && sqrt(ξ) ≤ ϵ)
optimal = true
continue
end

ξ > 0 || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)")
xkn .= xk .+ s
fkn = f(xkn)
hkn = h(xkn)
Expand Down
21 changes: 18 additions & 3 deletions src/input_struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export ROSolverOptions

mutable struct ROSolverOptions{R}
ϵ::R # termination criteria
neg_tol::R # tolerance when ξ < 0
Δk::R # trust region radius
verbose::Int # print every so often
maxIter::Int # maximum amount of inner iterations
Expand All @@ -17,6 +18,7 @@ mutable struct ROSolverOptions{R}

function ROSolverOptions{R}(;
ϵ::R = √eps(R),
neg_tol::R = eps(R)^(1 / 3),
Δk::R = one(R),
verbose::Int = 0,
maxIter::Int = 10000,
Expand All @@ -26,11 +28,24 @@ mutable struct ROSolverOptions{R}
η2::R = R(0.9),
α::R = 1 / eps(R),
ν::R = 1.0e-3,
γ::R = R(3.0),
γ::R = R(3),
θ::R = R(1e-3),
β::R = R(10.0),
β::R = R(10),
) where {R <: Real}
return new{R}(ϵ, Δk, verbose, maxIter, maxTime, σmin, η1, η2, α, ν, γ, θ, β)
@assert ϵ ≥ 0
@assert neg_tol ≥ 0
@assert Δk > 0
@assert verbose ≥ 0
@assert maxIter ≥ 0
@assert maxTime ≥ 0
@assert σmin ≥ 0
@assert 0 < η1 < η2 < 1
@assert α > 0
@assert ν > 0
@assert γ > 1
@assert θ > 0
@assert β ≥ 1
return new{R}(ϵ, neg_tol, Δk, verbose, maxIter, maxTime, σmin, η1, η2, α, ν, γ, θ, β)
end
end

Expand Down