Skip to content

Commit 4700798

Browse files
add theta to nu and remove summation
1 parent 339a6cf commit 4700798

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/LM_alg.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,14 @@ function LM(
246246
shift!(ψ, xk)
247247
Jk = jac_op_residual(nls, xk)
248248
jtprod_residual!(nls, xk, Fk, ∇fk)
249-
250249
σmax = opnorm(Jk)
251-
252-
253250
Complex_hist[k] += 1
254251
end
255252

256253
if ρk < η1 || ρk == Inf
257254
σk = σk * γ
258255
end
259256
νInv = (1 + θ) * (σmax^2 + σk) # ‖J'J + σₖ I‖ = ‖J‖² + σₖ
260-
261257
tired = k maxIter || elapsed_time > maxTime
262258
end
263259

src/R2DH.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ About each iterate xₖ, a step sₖ is computed as a solution of
1515
1616
min φ(s; xₖ) + ψ(s; xₖ)
1717
18-
where φ(s ; xₖ) = f(xₖ) + ∇f(xₖ)ᵀs + ½ sᵀ (σₖ+Dₖ) s (if `summation = true`) and φ(s ; xₖ) = f(xₖ) + ∇f(xₖ)ᵀs + ½ sᵀ (σₖ+Dₖ) s (if `summation = false`) is a quadratic approximation of f about xₖ,
18+
where φ(s ; xₖ) = f(xₖ) + ∇f(xₖ)ᵀs + ½ sᵀ (σₖ+Dₖ) s is a quadratic approximation of f about xₖ,
1919
ψ(s; xₖ) = h(xₖ + s), ‖⋅‖ is a user-defined norm, Dₖ is a diagonal Hessian approximation
2020
and σₖ > 0 is the regularization parameter.
2121
@@ -31,7 +31,6 @@ and σₖ > 0 is the regularization parameter.
3131
* `x0::AbstractVector`: an initial guess (in the first calling form: default = `nlp.meta.x0`)
3232
* `selected::AbstractVector{<:Integer}`: (default `1:length(x0)`).
3333
* `Bk`: initial diagonal Hessian approximation (default: `(one(R) / options.ν) * I`).
34-
* `summation`: boolean used to choose between the two versions of R2DH (see above, default : `true`).
3534
3635
The objective and gradient of `nlp` will be accessed.
3736
@@ -74,6 +73,7 @@ function R2DH(
7473
set_time!(stats, outdict[:elapsed_time])
7574
set_solver_specific!(stats, :Fhist, outdict[:Fhist])
7675
set_solver_specific!(stats, :Hhist, outdict[:Hhist])
76+
set_solver_specific!(stats, :Time_hist, outdict[:Time_hist])
7777
set_solver_specific!(stats, :NonSmooth, outdict[:NonSmooth])
7878
set_solver_specific!(stats, :SubsolverCounter, outdict[:Chist])
7979
return stats
@@ -88,7 +88,6 @@ function R2DH(
8888
x0::AbstractVector{R};
8989
Mmonotone::Int = 5,
9090
selected::AbstractVector{<:Integer} = 1:length(x0),
91-
summation::Bool = true,
9291
kwargs...,
9392
) where {F <: Function, G <: Function, H, R <: Real, DQN <: AbstractDiagonalQuasiNewtonOperator}
9493
start_time = time()
@@ -104,6 +103,7 @@ function R2DH(
104103
η2 = options.η2
105104
ν = options.ν
106105
γ = options.γ
106+
θ = options.θ
107107

108108
local l_bound, u_bound
109109
has_bnds = false
@@ -145,6 +145,7 @@ function R2DH(
145145

146146
Fobj_hist = zeros(maxIter)
147147
Hobj_hist = zeros(maxIter)
148+
time_hist = zeros(maxIter)
148149
FHobj_hist = fill!(Vector{R}(undef, Mmonotone), R(-Inf))
149150
Complex_hist = zeros(Int, maxIter)
150151
if verbose > 0
@@ -155,18 +156,18 @@ function R2DH(
155156

156157
local ξ
157158
k = 0
158-
σk = summation ? σmin : max(1 / ν, σmin)
159+
σk = σmin
159160

160161
fk = f(xk)
161162
∇fk = similar(xk)
162163
∇f!(∇fk, xk)
163164
∇fk⁻ = copy(∇fk)
164165
spectral_test = isa(D, SpectralGradient)
165-
D.d .= summation ? D.d .+ σk : D.d .* σk
166+
D.d .= D.d .+ σk
166167
DNorm = norm(D.d, Inf)
167168

168169

169-
ν = 1 / DNorm
170+
ν = 1 / (DNorm * (1 + θ))
170171
mν∇fk = -ν * ∇fk
171172
sqrt_ξ_νInv = one(R)
172173

@@ -178,6 +179,7 @@ function R2DH(
178179
elapsed_time = time() - start_time
179180
Fobj_hist[k] = fk
180181
Hobj_hist[k] = hk
182+
time_hist[k] = elapsed_time
181183
Mmonotone > 0 && (FHobj_hist[mod(k-1, Mmonotone) + 1] = fk + hk)
182184

183185
D.d .= max.(D.d, eps(R))
@@ -251,9 +253,9 @@ function R2DH(
251253
σk = σk * γ
252254
end
253255

254-
D.d .= summation ? D.d .+ σk : D.d .* σk
256+
D.d .= D.d .+ σk
255257
DNorm = norm(D.d, Inf)
256-
ν = 1 / DNorm
258+
ν = 1 / (DNorm * (1 + θ))
257259

258260
tired = maxIter > 0 && k maxIter
259261
if !tired
@@ -284,6 +286,7 @@ function R2DH(
284286
outdict = Dict(
285287
:Fhist => Fobj_hist[1:k],
286288
:Hhist => Hobj_hist[1:k],
289+
:Time_hist => time_hist[1:k],
287290
:Chist => Complex_hist[1:k],
288291
:NonSmooth => h,
289292
:status => status,

0 commit comments

Comments
 (0)