Skip to content
Closed
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
15 changes: 9 additions & 6 deletions src/R2_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ function R2(
f::F,
∇f!::G,
h::H,
options::ROSolverOptions,
x0::AbstractVector,
) where {F <: Function, G <: Function, H}
options::ROSolverOptions{R},
x0::AbstractVector{R},
neg_tol::R = -eps(R)^(1/3) ,
) where {F <: Function, G <: Function, H, R <: Real}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good now, thank you! Now that I think about it, we should put neg_tol in the options. Then it would be available to the other solvers.

start_time = time()
elapsed_time = 0.0
ϵ = options.ϵ
Expand All @@ -83,6 +84,7 @@ function R2(
η2 = options.η2
ν = options.ν
γ = options.γ
neg_tol < 0 || error("neg_tol must be negative")

if verbose == 0
ptf = Inf
Expand Down Expand Up @@ -146,13 +148,14 @@ 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 neg_tol <= ξ <= ϵ^2
optimal = true
ξ = abs(ξ)
continue
end

ξ > 0 || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)")
xkn .= xk .+ s
fkn = f(xkn)
hkn = h(xkn)
Expand Down