From c561d8bdc73d7362743d34f9096e77d6673d9442 Mon Sep 17 00:00:00 2001 From: MohamedLaghdafHABIBOULLAH <81633807+MohamedLaghdafHABIBOULLAH@users.noreply.github.com> Date: Tue, 2 Aug 2022 01:57:07 -0400 Subject: [PATCH 1/3] Update R2_alg.jl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To take into account the case where ξ is small and negative. --- src/R2_alg.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/R2_alg.jl b/src/R2_alg.jl index 91c54543..99364e95 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -71,7 +71,8 @@ function R2( h::H, options::ROSolverOptions, x0::AbstractVector, -) where {F <: Function, G <: Function, H} + T::R, +) where {F <: Function, G <: Function, H, R <: Real} start_time = time() elapsed_time = 0.0 ϵ = options.ϵ @@ -146,9 +147,9 @@ 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 ξ = $(ξ)") + ξ > T || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)") - if sqrt(ξ) < ϵ + if sqrt(abs(T)) <= sqrt(abs(ξ)) < ϵ optimal = true continue end @@ -165,7 +166,7 @@ function R2( if (verbose > 0) && (k % ptf == 0) #! format: off - @info @sprintf "%6d %8.1e %8.1e %7.1e %8.1e %7.1e %7.1e %7.1e %1s" k fk hk sqrt(ξ) ρk σk norm(xk) norm(s) σ_stat + @info @sprintf "%6d %8.1e %8.1e %7.1e %8.1e %7.1e %7.1e %7.1e %1s" k fk hk sqrt(abs(ξ)) ρk σk norm(xk) norm(s) σ_stat #! format: on end @@ -197,7 +198,7 @@ function R2( @info @sprintf "%6d %8.1e %8.1e" k fk hk elseif optimal #! format: off - @info @sprintf "%6d %8.1e %8.1e %7.1e %8s %7.1e %7.1e %7.1e" k fk hk sqrt(ξ) "" σk norm(xk) norm(s) + @info @sprintf "%6d %8.1e %8.1e %7.1e %8s %7.1e %7.1e %7.1e" k fk hk sqrt(abs(ξ)) "" σk norm(xk) norm(s) #! format: on @info "R2: terminating with √ξ = $(sqrt(ξ))" end From c79049f3ae710d9f88ee1f55967735a9bba29471 Mon Sep 17 00:00:00 2001 From: MohamedLaghdafHABIBOULLAH <81633807+MohamedLaghdafHABIBOULLAH@users.noreply.github.com> Date: Thu, 4 Aug 2022 03:00:22 -0400 Subject: [PATCH 2/3] Update R2_alg.jl --- src/R2_alg.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/R2_alg.jl b/src/R2_alg.jl index 99364e95..cc5da1d9 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -53,7 +53,7 @@ function R2(nlp::AbstractNLPModel, args...; kwargs...) nlp, solution = xk, objective = outdict[:fk] + outdict[:hk], - dual_feas = sqrt(outdict[:ξ]), + dual_feas = sqrt(abs(outdict[:ξ])), iter = k, elapsed_time = outdict[:elapsed_time], solver_specific = Dict( @@ -69,9 +69,9 @@ function R2( f::F, ∇f!::G, h::H, - options::ROSolverOptions, - x0::AbstractVector, - T::R, + options::ROSolverOptions{R}, + x0::AbstractVector{R}, + neg_tol::R = -eps(R)^(1/3) , ) where {F <: Function, G <: Function, H, R <: Real} start_time = time() elapsed_time = 0.0 @@ -84,6 +84,7 @@ function R2( η2 = options.η2 ν = options.ν γ = options.γ + neg_tol < 0 || error("neg_tol must be negative") if verbose == 0 ptf = Inf @@ -147,9 +148,9 @@ function R2( Complex_hist[k] += 1 mks = mk(s) ξ = hk - mks + max(1, abs(hk)) * 10 * eps() - ξ > T || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)") + ξ > neg_tol || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)") - if sqrt(abs(T)) <= sqrt(abs(ξ)) < ϵ + if sqrt(abs(ξ)) < max(ϵ, abs(neg_tol)) optimal = true continue end @@ -200,7 +201,7 @@ function R2( #! format: off @info @sprintf "%6d %8.1e %8.1e %7.1e %8s %7.1e %7.1e %7.1e" k fk hk sqrt(abs(ξ)) "" σk norm(xk) norm(s) #! format: on - @info "R2: terminating with √ξ = $(sqrt(ξ))" + @info "R2: terminating with √ξ = $(sqrt(abs(ξ)))" end end From d00ebdc6be29d3b7bc530dd72c8b028d66e3ef4f Mon Sep 17 00:00:00 2001 From: MohamedLaghdafHABIBOULLAH <81633807+MohamedLaghdafHABIBOULLAH@users.noreply.github.com> Date: Mon, 8 Aug 2022 19:35:38 -0400 Subject: [PATCH 3/3] Update R2_alg.jl --- src/R2_alg.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/R2_alg.jl b/src/R2_alg.jl index cc5da1d9..d23e4b0c 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -53,7 +53,7 @@ function R2(nlp::AbstractNLPModel, args...; kwargs...) nlp, solution = xk, objective = outdict[:fk] + outdict[:hk], - dual_feas = sqrt(abs(outdict[:ξ])), + dual_feas = sqrt(outdict[:ξ]), iter = k, elapsed_time = outdict[:elapsed_time], solver_specific = Dict( @@ -148,13 +148,14 @@ function R2( Complex_hist[k] += 1 mks = mk(s) ξ = hk - mks + max(1, abs(hk)) * 10 * eps() - ξ > neg_tol || error("R2: prox-gradient step should produce a decrease but ξ = $(ξ)") - - if sqrt(abs(ξ)) < max(ϵ, abs(neg_tol)) + + 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) @@ -167,7 +168,7 @@ function R2( if (verbose > 0) && (k % ptf == 0) #! format: off - @info @sprintf "%6d %8.1e %8.1e %7.1e %8.1e %7.1e %7.1e %7.1e %1s" k fk hk sqrt(abs(ξ)) ρk σk norm(xk) norm(s) σ_stat + @info @sprintf "%6d %8.1e %8.1e %7.1e %8.1e %7.1e %7.1e %7.1e %1s" k fk hk sqrt(ξ) ρk σk norm(xk) norm(s) σ_stat #! format: on end @@ -199,9 +200,9 @@ function R2( @info @sprintf "%6d %8.1e %8.1e" k fk hk elseif optimal #! format: off - @info @sprintf "%6d %8.1e %8.1e %7.1e %8s %7.1e %7.1e %7.1e" k fk hk sqrt(abs(ξ)) "" σk norm(xk) norm(s) + @info @sprintf "%6d %8.1e %8.1e %7.1e %8s %7.1e %7.1e %7.1e" k fk hk sqrt(ξ) "" σk norm(xk) norm(s) #! format: on - @info "R2: terminating with √ξ = $(sqrt(abs(ξ)))" + @info "R2: terminating with √ξ = $(sqrt(ξ))" end end