Skip to content

Commit 1e31822

Browse files
update Mmonotone as in the paper
1 parent ac7dfdb commit 1e31822

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/R2DH.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ where φ(s ; xₖ) = f(xₖ) + ∇f(xₖ)ᵀs + ½ sᵀ(Dₖ + σₖI)s is a qua
2929
* `x0::AbstractVector`: an initial guess (in the first calling form: default = `nlp.meta.x0`)
3030
* `selected::AbstractVector{<:Integer}`: (default `1:length(x0)`).
3131
* `D`: Diagonal quasi-Newton operator.
32-
* `Mmonotone::Int`: number of previous values of the objective to consider for the non-monotone variant (default: 5).
32+
* `Mmonotone::Int`: number of previous values of the objective to consider for the non-monotone variant (default: 6).
3333
3434
The objective and gradient of `nlp` will be accessed.
3535
@@ -87,7 +87,7 @@ function R2DH(
8787
D::DQN,
8888
options::ROSolverOptions{R},
8989
x0::AbstractVector{R};
90-
Mmonotone::Int = 5,
90+
Mmonotone::Int = 6,
9191
selected::AbstractVector{<:Integer} = 1:length(x0),
9292
kwargs...,
9393
) where {F <: Function, G <: Function, H, R <: Real, DQN <: AbstractDiagonalQuasiNewtonOperator}
@@ -148,7 +148,7 @@ function R2DH(
148148
Fobj_hist = zeros(maxIter+1)
149149
Hobj_hist = zeros(maxIter+1)
150150
time_hist = zeros(maxIter+1)
151-
FHobj_hist = fill!(Vector{R}(undef, Mmonotone), R(-Inf))
151+
FHobj_hist = fill!(Vector{R}(undef, - 1), R(-Inf))
152152
Complex_hist = zeros(Int, maxIter+1)
153153
k_prox = 0
154154
if verbose > 0
@@ -202,7 +202,7 @@ function R2DH(
202202
Fobj_hist[k] = fk
203203
Hobj_hist[k] = hk
204204
time_hist[k] = elapsed_time
205-
Mmonotone > 0 && (FHobj_hist[mod(k-1, Mmonotone) + 1] = fk + hk)
205+
Mmonotone > 1 && (FHobj_hist[mod(k-1, Mmonotone - 1) + 1] = fk + hk)
206206

207207
Complex_hist[k] += k_prox
208208
k_prox = 0
@@ -211,7 +211,7 @@ function R2DH(
211211
hkn = h(xkn[selected])
212212
hkn == -Inf && error("nonsmooth term is not proper")
213213

214-
fhmax = Mmonotone > 0 ? maximum(FHobj_hist) : fk + hk
214+
fhmax = Mmonotone > 1 ? maximum(FHobj_hist) : fk + hk
215215
Δobj = fhmax - (fkn + hkn) + max(1, abs(fhmax)) * 10 * eps()
216216
Δmod = fhmax - (fk + mks) + max(1, abs(hk)) * 10 * eps()
217217
ξ = hk - mks + max(1, abs(hk)) * 10 * eps()

src/R2N.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The Hessian is accessed as an abstract operator and need not be the exact Hessia
3434
* `subsolver`: the procedure used to compute a step (`R2DH`, `R2` or `PG`)
3535
* `subsolver_options::ROSolverOptions`: default options to pass to the subsolver (default: all defaut options)
3636
* `selected::AbstractVector{<:Integer}`: subset of variables to which `h` is applied (default `1:nlp.meta.nvar`).
37-
* `Mmonotone::Int`: number of previous values of the objective to consider for the non-monotone variant (default: 0).
37+
* `Mmonotone::Int`: number of previous values of the objective to consider for the non-monotone variant (default: 1).
3838
3939
### Return values
4040
@@ -51,7 +51,7 @@ function R2N(
5151
subsolver_logger::Logging.AbstractLogger = Logging.NullLogger(),
5252
subsolver = R2,
5353
subsolver_options = ROSolverOptions(ϵa = options.ϵa),
54-
Mmonotone::Int = 0,
54+
Mmonotone::Int = 1,
5555
selected::AbstractVector{<:Integer} = 1:(f.meta.nvar),
5656
) where {H, R}
5757
start_time = time()
@@ -112,7 +112,7 @@ function R2N(
112112

113113
Fobj_hist = zeros(maxIter)
114114
Hobj_hist = zeros(maxIter)
115-
FHobj_hist = fill!(Vector{R}(undef, Mmonotone), R(-Inf))
115+
FHobj_hist = fill!(Vector{R}(undef, Mmonotone - 1), R(-Inf))
116116
Complex_hist = zeros(Int, maxIter)
117117
if verbose > 0
118118
#! format: off
@@ -144,7 +144,7 @@ function R2N(
144144
elapsed_time = time() - start_time
145145
Fobj_hist[k] = fk
146146
Hobj_hist[k] = hk
147-
Mmonotone > 0 && (FHobj_hist[mod(k-1, Mmonotone) + 1] = fk + hk)
147+
Mmonotone > 1 && (FHobj_hist[mod(k-1, Mmonotone - 1) + 1] = fk + hk)
148148

149149
# model for first prox-gradient step and ξ1
150150
φ1(d) = ∇fk' * d
@@ -207,7 +207,7 @@ function R2N(
207207
hkn == -Inf && error("nonsmooth term is not proper")
208208
mks = mk(s)
209209

210-
fhmax = Mmonotone > 0 ? maximum(FHobj_hist) : fk + hk
210+
fhmax = Mmonotone > 1 ? maximum(FHobj_hist) : fk + hk
211211
Δobj = fhmax - (fkn + hkn) + max(1, abs(fhmax)) * 10 * eps()
212212
Δmod = fhmax - (fk + mks) + max(1, abs(fhmax)) * 10 * eps()
213213
ξ = hk - mks + max(1, abs(hk)) * 10 * eps()

0 commit comments

Comments
 (0)