Skip to content

Commit 688df74

Browse files
rjbaraldpo
authored andcommitted
stopping criteria update
1 parent 20fb633 commit 688df74

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

src/LMTR_alg.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ function LMTR(
115115

116116
if verbose > 0
117117
#! format: off
118-
@info @sprintf "%6s %8s %8s %8s %7s %7s %8s %7s %7s %7s %7s %1s" "outer" "inner" "f(x)" "h(x)" "ξ1" "ξ" "ρ" "Δ" "‖x‖" "‖s‖" "1/ν" "TR"
118+
@info @sprintf "%6s %8s %8s %8s %7s %7s %8s %7s %7s %7s %7s %1s" "outer" "inner" "f(x)" "h(x)" "(ξ1/ν)" "(ξ/ν)" "ρ" "Δ" "‖x‖" "‖s‖" "1/ν" "TR"
119119
#! format: on
120120
end
121121

122-
local ξ1
122+
local ξ1, ξ
123123
k = 0
124124

125125
Fk = residual(nls, xk)
@@ -132,6 +132,7 @@ function LMTR(
132132

133133
σmax = opnorm(Jk)
134134
νInv = (1 + θ) * σmax^2 # ‖J'J‖ = ‖J‖²
135+
ν = 1 / νInv
135136

136137
mν∇fk = -∇fk / νInv
137138

@@ -179,18 +180,18 @@ function LMTR(
179180
ξ1 > 0 || error("LMTR: first prox-gradient step should produce a decrease but ξ1 = $(ξ1)")
180181

181182
if ξ1 0 && k == 1
182-
ϵ_increment = ϵr * sqrt(ξ1)
183+
ϵ_increment = ϵr * sqrt(ξ1/ν)
183184
ϵ += ϵ_increment # make stopping test absolute and relative
184185
ϵ_subsolver += ϵ_increment
185186
end
186187

187-
if sqrt(ξ1) < ϵ
188+
if sqrt(ξ1/ν) < ϵ
188189
# the current xk is approximately first-order stationary
189190
optimal = true
190191
continue
191192
end
192193

193-
subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ_subsolver, min(1.0e-1, ξ1 / 10))
194+
subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ_subsolver, min(1.0e-1, ξ1 / ν / 10))
194195
∆_effective = min* χ(s), Δk)
195196
treats_bounds ?
196197
set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :
@@ -230,7 +231,7 @@ function LMTR(
230231

231232
if (verbose > 0) && (k % ptf == 0)
232233
#! format: off
233-
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8.1e %7.1e %7.1e %7.1e %7.1e %1s" k iter fk hk sqrt(ξ1) sqrt(ξ) ρk ∆_effective χ(xk) sNorm νInv TR_stat
234+
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8.1e %7.1e %7.1e %7.1e %7.1e %1s" k iter fk hk sqrt(ξ1/ν) sqrt/ν) ρk ∆_effective χ(xk) sNorm νInv TR_stat
234235
#! format: on
235236
end
236237

@@ -270,9 +271,9 @@ function LMTR(
270271
@info @sprintf "%6d %8s %8.1e %8.1e" k "" fk hk
271272
elseif optimal
272273
#! format: off
273-
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8s %7.1e %7.1e %7.1e %7.1e" k 1 fk hk sqrt(ξ1) sqrt(ξ1) "" Δk χ(xk) χ(s) νInv
274+
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8s %7.1e %7.1e %7.1e %7.1e" k 1 fk hk sqrt(ξ1/ν) sqrt(ξ/ν) "" Δk χ(xk) χ(s) νInv
274275
#! format: on
275-
@info "LMTR: terminating with √ξ1 = $(sqrt(ξ1))"
276+
@info "LMTR: terminating with √(ξ1/ν) = $(sqrt(ξ1/ν))"
276277
end
277278
end
278279

@@ -290,7 +291,7 @@ function LMTR(
290291
set_status!(stats, status)
291292
set_solution!(stats, xk)
292293
set_objective!(stats, fk + hk)
293-
set_residuals!(stats, zero(eltype(xk)), ξ1 0 ? sqrt(ξ1) : ξ1)
294+
set_residuals!(stats, zero(eltype(xk)), ξ1 0 ? sqrt(ξ1/ν) : ξ1)
294295
set_iter!(stats, k)
295296
set_time!(stats, elapsed_time)
296297
set_solver_specific!(stats, :Fhist, Fobj_hist[1:k])

src/LM_alg.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function LM(
100100

101101
xkn = similar(xk)
102102

103-
local ξ1
103+
local ξ1, ξ
104104
k = 0
105105
Fobj_hist = zeros(maxIter)
106106
Hobj_hist = zeros(maxIter)
@@ -110,7 +110,7 @@ function LM(
110110

111111
if verbose > 0
112112
#! format: off
113-
@info @sprintf "%6s %8s %8s %8s %7s %7s %8s %7s %7s %7s %7s %1s" "outer" "inner" "f(x)" "h(x)" "√ξ1" "ξ" "ρ" "σ" "‖x‖" "‖s‖" "‖Jₖ‖²" "reg"
113+
@info @sprintf "%6s %8s %8s %8s %7s %7s %8s %7s %7s %7s %7s %1s" "outer" "inner" "f(x)" "h(x)" "√(ξ1/ν)" "(ξ/ν)" "ρ" "σ" "‖x‖" "‖s‖" "‖Jₖ‖²" "reg"
114114
#! format: on
115115
end
116116

@@ -125,6 +125,7 @@ function LM(
125125

126126
σmax = opnorm(Jk)
127127
νInv = (1 + θ) * (σmax^2 + σk) # ‖J'J + σₖ I‖ = ‖J‖² + σₖ
128+
ν = 1 / νInv
128129

129130
s = zero(xk)
130131

@@ -178,18 +179,18 @@ function LM(
178179
ξ1 > 0 || error("LM: first prox-gradient step should produce a decrease but ξ1 = $(ξ1)")
179180

180181
if ξ1 0 && k == 1
181-
ϵ_increment = ϵr * sqrt(ξ1)
182+
ϵ_increment = ϵr * sqrt(ξ1/ν)
182183
ϵ += ϵ_increment # make stopping test absolute and relative
183184
ϵ_subsolver += ϵ_increment
184185
end
185186

186-
if sqrt(ξ1) < ϵ
187+
if sqrt(ξ1/ν) < ϵ
187188
# the current xk is approximately first-order stationary
188189
optimal = true
189190
continue
190191
end
191192

192-
subsolver_options.ϵa = k == 1 ? 1.0e-1 : max(ϵ_subsolver, min(1.0e-2, ξ1 / 10))
193+
subsolver_options.ϵa = k == 1 ? 1.0e-1 : max(ϵ_subsolver, min(1.0e-2, ξ1 / ν / 10))
193194
subsolver_options.ν = ν
194195
@debug "setting inner stopping tolerance to" subsolver_options.optTol
195196
s, iter, _ = with_logger(subsolver_logger) do
@@ -220,7 +221,7 @@ function LM(
220221

221222
if (verbose > 0) && (k % ptf == 0)
222223
#! format: off
223-
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8.1e %7.1e %7.1e %7.1e %7.1e %1s" k iter fk hk sqrt(ξ1) sqrt(ξ) ρk σk norm(xk) norm(s) νInv σ_stat
224+
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8.1e %7.1e %7.1e %7.1e %7.1e %1s" k iter fk hk sqrt(ξ1/ν) sqrt/ν) ρk σk norm(xk) norm(s) νInv σ_stat
224225
#! format: off
225226
end
226227

@@ -260,9 +261,9 @@ function LM(
260261
@info @sprintf "%6d %8s %8.1e %8.1e" k "" fk hk
261262
elseif optimal
262263
#! format: off
263-
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8s %7.1e %7.1e %7.1e %7.1e" k 1 fk hk sqrt(ξ1) sqrt(ξ1) "" σk norm(xk) norm(s) νInv
264+
@info @sprintf "%6d %8d %8.1e %8.1e %7.1e %7.1e %8s %7.1e %7.1e %7.1e %7.1e" k 1 fk hk sqrt(ξ1/ν) sqrt(ξ/ν) "" σk norm(xk) norm(s) νInv
264265
#! format: on
265-
@info "LM: terminating with √ξ1 = $(sqrt(ξ1))"
266+
@info "LM: terminating with √(ξ1/ν) = $(sqrt(ξ1/ν))"
266267
end
267268
end
268269
status = if optimal
@@ -279,7 +280,7 @@ function LM(
279280
set_status!(stats, status)
280281
set_solution!(stats, xk)
281282
set_objective!(stats, fk + hk)
282-
set_residuals!(stats, zero(eltype(xk)), ξ1 0 ? sqrt(ξ1) : ξ1)
283+
set_residuals!(stats, zero(eltype(xk)), ξ1 0 ? sqrt(ξ1/ν) : ξ1)
283284
set_iter!(stats, k)
284285
set_time!(stats, elapsed_time)
285286
set_solver_specific!(stats, :Fhist, Fobj_hist[1:k])

src/R2_alg.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ function R2!(
313313
#! format: off
314314
σ_stat = (η2 ρk < Inf) ? "" : (ρk < η1 ? "" : "=")
315315
@info @sprintf "%6d %8.1e %8.1e %7.1e %8.1e %7.1e %7.1e %7.1e %1s" k fk hk sqrt_ξ_νInv ρk σk norm(xk) norm(s) σ_stat
316-
317316
#! format: on
318317
end
319318

src/TRDH_alg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function TRDH(
252252
set_radius!(ψ, Δ_effective)
253253
end
254254

255-
# model with diagonal hessian
255+
# model with diagonal hessian
256256
φ(d) = ∇fk' * d + (d' * (Dk.d .* d)) / 2
257257
mk(d) = φ(d) + ψ(d)
258258

src/TR_alg.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function TR(
121121
#! format: on
122122
end
123123

124-
local ξ1
124+
local ξ1, ξ
125125
k = 0
126126

127127
fk = obj(f, xk)
@@ -133,8 +133,6 @@ function TR(
133133

134134
λmax = opnorm(Bk)
135135
νInv = (1 + θ) * λmax
136-
ν = 1 / (νInv + 1 / (Δk * α))
137-
sqrt_ξ1_νInv = one(R)
138136

139137
optimal = false
140138
tired = k maxIter || elapsed_time > maxTime
@@ -179,7 +177,7 @@ function TR(
179177
continue
180178
end
181179

182-
subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ_subsolver, min(1e-2, sqrt_ξ1_νInv))
180+
subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ_subsolver, min(1e-2, sqrt_ξ1_νInv) * ξ1)
183181
∆_effective = min* χ(s), Δk)
184182
(has_bounds(f) || subsolver == TRDH) ?
185183
set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :

0 commit comments

Comments
 (0)