Skip to content

Commit bdd5a1c

Browse files
committed
add extra vector of storage inside QN models
The objective of this change is to move the QN updates to a callback instead of having it performed in a generic manner by the solver. This will allow for customized QN updates.
1 parent 233b881 commit bdd5a1c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/quasi-newton.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mutable struct LBFGSModel{
1919
meta::Meta
2020
model::M
2121
op::Op
22+
v::S # extra vector to compute and store yₖ = ∇fₖ₊₁ - ∇fₖ
2223
end
2324

2425
mutable struct LSR1Model{
@@ -31,6 +32,7 @@ mutable struct LSR1Model{
3132
meta::Meta
3233
model::M
3334
op::Op
35+
v::S # extra vector to compute and store yₖ = ∇fₖ₊₁ - ∇fₖ
3436
end
3537

3638
mutable struct DiagonalQNModel{
@@ -48,13 +50,15 @@ end
4850
"Construct a `LBFGSModel` from another type of model."
4951
function LBFGSModel(nlp::AbstractNLPModel{T, S}; kwargs...) where {T, S}
5052
op = LBFGSOperator(T, nlp.meta.nvar; kwargs...)
51-
return LBFGSModel{T, S, typeof(nlp), typeof(nlp.meta), typeof(op)}(nlp.meta, nlp, op)
53+
v = similar(nlp.meta.x0)
54+
return LBFGSModel{T, S, typeof(nlp), typeof(nlp.meta), typeof(op)}(nlp.meta, nlp, op, v)
5255
end
5356

5457
"Construct a `LSR1Model` from another type of nlp."
5558
function LSR1Model(nlp::AbstractNLPModel{T, S}; kwargs...) where {T, S}
5659
op = LSR1Operator(T, nlp.meta.nvar; kwargs...)
57-
return LSR1Model{T, S, typeof(nlp), typeof(nlp.meta), typeof(op)}(nlp.meta, nlp, op)
60+
v = similar(nlp.meta.x0)
61+
return LSR1Model{T, S, typeof(nlp), typeof(nlp.meta), typeof(op)}(nlp.meta, nlp, op, v)
5862
end
5963

6064
"""

0 commit comments

Comments
 (0)