From d0908ada6dc3705dd86d6f06557beec3722cc333 Mon Sep 17 00:00:00 2001 From: Dominique Orban Date: Thu, 8 Sep 2022 11:22:14 -0400 Subject: [PATCH] update deps, stats API - clean up Project.toml; - specify dependencies versions; - update to new stats API. --- Project.toml | 15 +++++++++++---- src/LMTR_alg.jl | 27 ++++++++++++--------------- src/LM_alg.jl | 27 ++++++++++++--------------- src/R2_alg.jl | 29 +++++++++++++---------------- src/TR_alg.jl | 27 ++++++++++++--------------- 5 files changed, 60 insertions(+), 65 deletions(-) diff --git a/Project.toml b/Project.toml index c7188ca0..8208c222 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "RegularizedOptimization" uuid = "196f2941-2d58-45ba-9f13-43a2532b2fa8" -author = ["Robert Baraldi "] +author = ["Robert Baraldi and Dominique Orban "] version = "0.1.0" [deps] @@ -11,17 +11,24 @@ NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6" NLPModelsModifiers = "e01155f1-5c6f-4375-a9d8-616dd036575f" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" ProximalOperators = "a725b495-10eb-56fe-b38b-717eba820537" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ShiftedProximalOperators = "d4fd37fa-580c-4e43-9b30-361c21aae263" SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843" [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" [extras] +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +RegularizedProblems = "ea076b23-609f-44d2-bb12-a4ae45328278" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04" -RegularizedProblems = "ea076b23-609f-44d2-bb12-a4ae45328278" [targets] -test = ["Test", "TestSetExtensions", "RegularizedProblems"] +test = ["Random", "RegularizedProblems", "Test", "TestSetExtensions"] diff --git a/src/LMTR_alg.jl b/src/LMTR_alg.jl index 5864f27c..36a0ae8a 100644 --- a/src/LMTR_alg.jl +++ b/src/LMTR_alg.jl @@ -247,19 +247,16 @@ function LMTR( :exception end - return GenericExecutionStats( - status, - nls, - solution = xk, - objective = fk + hk, - dual_feas = sqrt(ξ1), - iter = k, - elapsed_time = elapsed_time, - solver_specific = Dict( - :Fhist => Fobj_hist[1:k], - :Hhist => Hobj_hist[1:k], - :NonSmooth => h, - :SubsolverCounter => Complex_hist[1:k], - ), - ) + stats = GenericExecutionStats(nls) + set_status!(stats, status) + set_solution!(stats, xk) + set_objective!(stats, fk + hk) + set_residuals!(stats, zero(eltype(xk)), ξ1 ≥ 0 ? sqrt(ξ1) : ξ1) + set_iter!(stats, k) + set_time!(stats, elapsed_time) + set_solver_specific!(stats, :Fhist, Fobj_hist[1:k]) + set_solver_specific!(stats, :Hhist, Hobj_hist[1:k]) + set_solver_specific!(stats, :NonSmooth, h) + set_solver_specific!(stats, :SubsolverCounter, Complex_hist[1:k]) + return stats end diff --git a/src/LM_alg.jl b/src/LM_alg.jl index 5c4caabc..1f64f557 100644 --- a/src/LM_alg.jl +++ b/src/LM_alg.jl @@ -247,19 +247,16 @@ function LM( :exception end - return GenericExecutionStats( - status, - nls, - solution = xk, - objective = fk + hk, - dual_feas = sqrt(ξ1), - iter = k, - elapsed_time = elapsed_time, - solver_specific = Dict( - :Fhist => Fobj_hist[1:k], - :Hhist => Hobj_hist[1:k], - :NonSmooth => h, - :SubsolverCounter => Complex_hist[1:k], - ), - ) + stats = GenericExecutionStats(nls) + set_status!(stats, status) + set_solution!(stats, xk) + set_objective!(stats, fk + hk) + set_residuals!(stats, zero(eltype(xk)), ξ1 ≥ 0 ? sqrt(ξ1) : ξ1) + set_iter!(stats, k) + set_time!(stats, elapsed_time) + set_solver_specific!(stats, :Fhist, Fobj_hist[1:k]) + set_solver_specific!(stats, :Hhist, Hobj_hist[1:k]) + set_solver_specific!(stats, :NonSmooth, h) + set_solver_specific!(stats, :SubsolverCounter, Complex_hist[1:k]) + return stats end diff --git a/src/R2_alg.jl b/src/R2_alg.jl index 4d9ba7b4..d664ca7d 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -47,22 +47,19 @@ function R2(nlp::AbstractNLPModel, args...; kwargs...) kwargs_dict = Dict(kwargs...) x0 = pop!(kwargs_dict, :x0, nlp.meta.x0) xk, k, outdict = R2(x -> obj(nlp, x), (g, x) -> grad!(nlp, x, g), args..., x0; kwargs_dict...) - - return GenericExecutionStats( - outdict[:status], - nlp, - solution = xk, - objective = outdict[:fk] + outdict[:hk], - dual_feas = sqrt(outdict[:ξ]), - iter = k, - elapsed_time = outdict[:elapsed_time], - solver_specific = Dict( - :Fhist => outdict[:Fhist], - :Hhist => outdict[:Hhist], - :NonSmooth => outdict[:NonSmooth], - :SubsolverCounter => outdict[:Chist], - ), - ) + ξ = outdict[:ξ] + stats = GenericExecutionStats(nlp) + set_status!(stats, outdict[:status]) + set_solution!(stats, xk) + set_objective!(stats, outdict[:fk] + outdict[:hk]) + set_residuals!(stats, zero(eltype(xk)), ξ ≥ 0 ? sqrt(ξ) : ξ) + set_iter!(stats, k) + set_time!(stats, outdict[:elapsed_time]) + set_solver_specific!(stats, :Fhist, outdict[:Fhist]) + set_solver_specific!(stats, :Hhist, outdict[:Hhist]) + set_solver_specific!(stats, :NonSmooth, outdict[:NonSmooth]) + set_solver_specific!(stats, :SubsolverCounter, outdict[:Chist]) + return stats end function R2( diff --git a/src/TR_alg.jl b/src/TR_alg.jl index 354b337c..4f6d03e9 100644 --- a/src/TR_alg.jl +++ b/src/TR_alg.jl @@ -236,19 +236,16 @@ function TR( :exception end - return GenericExecutionStats( - status, - f, - solution = xk, - objective = fk + hk, - dual_feas = sqrt(ξ1), - iter = k, - elapsed_time = elapsed_time, - solver_specific = Dict( - :Fhist => Fobj_hist[1:k], - :Hhist => Hobj_hist[1:k], - :NonSmooth => h, - :SubsolverCounter => Complex_hist[1:k], - ), - ) + stats = GenericExecutionStats(f) + set_status!(stats, status) + set_solution!(stats, xk) + set_objective!(stats, fk + hk) + set_residuals!(stats, zero(eltype(xk)), ξ1 ≥ 0 ? sqrt(ξ1) : ξ1) + set_iter!(stats, k) + set_time!(stats, elapsed_time) + set_solver_specific!(stats, :Fhist, Fobj_hist[1:k]) + set_solver_specific!(stats, :Hhist, Hobj_hist[1:k]) + set_solver_specific!(stats, :NonSmooth, h) + set_solver_specific!(stats, :SubsolverCounter, Complex_hist[1:k]) + return stats end