@@ -25,7 +25,7 @@ mutable struct R2DHSolver{
2525 m_fh_hist:: V
2626end
2727
28- function R2DHSolver (reg_nlp:: AbstractRegularizedNLPModel{T, V} ; m_monotone:: Int = 6 ) where {T, V}
28+ function R2DHSolver (reg_nlp:: AbstractRegularizedNLPModel{T, V} ; m_monotone:: Int = 6 , D :: Union{Nothing, AbstractDiagonalQuasiNewtonOperator} = nothing ) where {T, V}
2929 x0 = reg_nlp. model. meta. x0
3030 l_bound = reg_nlp. model. meta. lvar
3131 u_bound = reg_nlp. model. meta. uvar
@@ -50,7 +50,7 @@ function R2DHSolver(reg_nlp::AbstractRegularizedNLPModel{T, V}; m_monotone::Int
5050 m_fh_hist = fill (T (- Inf ), m_monotone - 1 )
5151
5252 ψ = has_bnds ? shifted (reg_nlp. h, xk, l_bound_m_x, u_bound_m_x, reg_nlp. selected) : shifted (reg_nlp. h, xk)
53- D = isa (reg_nlp. model, AbstractDiagonalQNModel) ? hess_op (reg_nlp. model, x0) : SpectralGradient (T (1 ), reg_nlp. model. meta. nvar)
53+ isnothing (D) && (D = isa (reg_nlp. model, AbstractDiagonalQNModel) ? hess_op (reg_nlp. model, x0) : SpectralGradient (T (1 ), reg_nlp. model. meta. nvar) )
5454
5555 return R2DHSolver (
5656 xk,
@@ -170,13 +170,48 @@ function R2DH(
170170 )
171171end
172172
173+ function R2DH (
174+ f:: F ,
175+ ∇f!:: G ,
176+ h:: H ,
177+ D:: DQN ,
178+ options:: ROSolverOptions{R} ,
179+ x0:: AbstractVector{R} ;
180+ selected:: AbstractVector{<:Integer} = 1 : length (x0),
181+ kwargs... ,
182+ ) where {F <: Function , G <: Function , H, R <: Real , DQN <: AbstractDiagonalQuasiNewtonOperator }
183+ nlp = FirstOrderModel (f, ∇f!, x0)
184+ reg_nlp = RegularizedNLPModel (nlp, h, selected)
185+ stats = R2DH (
186+ reg_nlp,
187+ x = x0,
188+ D = D,
189+ atol = options. ϵa,
190+ rtol = options. ϵr,
191+ neg_tol = options. neg_tol,
192+ verbose = options. verbose,
193+ max_iter = options. maxIter,
194+ max_time = options. maxTime,
195+ σmin = options. σmin,
196+ η1 = options. η1,
197+ η2 = options. η2,
198+ ν = options. ν,
199+ γ = options. γ,
200+ θ = options. θ,
201+ kwargs... ,
202+ )
203+
204+ return stats. solution, stats. iter, nothing
205+ end
206+
173207function R2DH (
174208 reg_nlp:: AbstractRegularizedNLPModel{T, V} ;
175209 kwargs...
176210) where {T, V}
177211 kwargs_dict = Dict (kwargs... )
178212 m_monotone = pop! (kwargs_dict, :m_monotone , 6 )
179- solver = R2DHSolver (reg_nlp, m_monotone = m_monotone)
213+ D = pop! (kwargs_dict, :D , nothing )
214+ solver = R2DHSolver (reg_nlp, m_monotone = m_monotone, D = D)
180215 stats = GenericExecutionStats (reg_nlp. model)
181216 solve! (solver, reg_nlp, stats; kwargs_dict... )
182217 return stats
0 commit comments