Skip to content

Commit

Permalink
add theta to nu and remove summation
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedLaghdafHABIBOULLAH committed Sep 16, 2024
1 parent 339a6cf commit 4700798
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/LM_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,14 @@ function LM(
shift!(ψ, xk)
Jk = jac_op_residual(nls, xk)
jtprod_residual!(nls, xk, Fk, ∇fk)

σmax = opnorm(Jk)


Complex_hist[k] += 1
end

if ρk < η1 || ρk == Inf
σk = σk * γ
end
νInv = (1 + θ) * (σmax^2 + σk) # ‖J'J + σₖ I‖ = ‖J‖² + σₖ

tired = k maxIter || elapsed_time > maxTime
end

Expand Down
19 changes: 11 additions & 8 deletions src/R2DH.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ About each iterate xₖ, a step sₖ is computed as a solution of
min φ(s; xₖ) + ψ(s; xₖ)
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ₖ,
where φ(s ; xₖ) = f(xₖ) + ∇f(xₖ)ᵀs + ½ sᵀ (σₖ+Dₖ) s is a quadratic approximation of f about xₖ,
ψ(s; xₖ) = h(xₖ + s), ‖⋅‖ is a user-defined norm, Dₖ is a diagonal Hessian approximation
and σₖ > 0 is the regularization parameter.
Expand All @@ -31,7 +31,6 @@ and σₖ > 0 is the regularization parameter.
* `x0::AbstractVector`: an initial guess (in the first calling form: default = `nlp.meta.x0`)
* `selected::AbstractVector{<:Integer}`: (default `1:length(x0)`).
* `Bk`: initial diagonal Hessian approximation (default: `(one(R) / options.ν) * I`).
* `summation`: boolean used to choose between the two versions of R2DH (see above, default : `true`).
The objective and gradient of `nlp` will be accessed.
Expand Down Expand Up @@ -74,6 +73,7 @@ function R2DH(
set_time!(stats, outdict[:elapsed_time])
set_solver_specific!(stats, :Fhist, outdict[:Fhist])
set_solver_specific!(stats, :Hhist, outdict[:Hhist])
set_solver_specific!(stats, :Time_hist, outdict[:Time_hist])
set_solver_specific!(stats, :NonSmooth, outdict[:NonSmooth])
set_solver_specific!(stats, :SubsolverCounter, outdict[:Chist])
return stats
Expand All @@ -88,7 +88,6 @@ function R2DH(
x0::AbstractVector{R};
Mmonotone::Int = 5,
selected::AbstractVector{<:Integer} = 1:length(x0),
summation::Bool = true,
kwargs...,
) where {F <: Function, G <: Function, H, R <: Real, DQN <: AbstractDiagonalQuasiNewtonOperator}
start_time = time()
Expand All @@ -104,6 +103,7 @@ function R2DH(
η2 = options.η2
ν = options.ν
γ = options.γ
θ = options.θ

local l_bound, u_bound
has_bnds = false
Expand Down Expand Up @@ -145,6 +145,7 @@ function R2DH(

Fobj_hist = zeros(maxIter)
Hobj_hist = zeros(maxIter)
time_hist = zeros(maxIter)
FHobj_hist = fill!(Vector{R}(undef, Mmonotone), R(-Inf))
Complex_hist = zeros(Int, maxIter)
if verbose > 0
Expand All @@ -155,18 +156,18 @@ function R2DH(

local ξ
k = 0
σk = summation ? σmin : max(1 / ν, σmin)
σk = σmin

fk = f(xk)
∇fk = similar(xk)
∇f!(∇fk, xk)
∇fk⁻ = copy(∇fk)
spectral_test = isa(D, SpectralGradient)
D.d .= summation ? D.d .+ σk : D.d .* σk
D.d .= D.d .+ σk
DNorm = norm(D.d, Inf)


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

Expand All @@ -178,6 +179,7 @@ function R2DH(
elapsed_time = time() - start_time
Fobj_hist[k] = fk
Hobj_hist[k] = hk
time_hist[k] = elapsed_time
Mmonotone > 0 && (FHobj_hist[mod(k-1, Mmonotone) + 1] = fk + hk)

D.d .= max.(D.d, eps(R))
Expand Down Expand Up @@ -251,9 +253,9 @@ function R2DH(
σk = σk * γ
end

D.d .= summation ? D.d .+ σk : D.d .* σk
D.d .= D.d .+ σk
DNorm = norm(D.d, Inf)
ν = 1 / DNorm
ν = 1 / (DNorm * (1 + θ))

tired = maxIter > 0 && k maxIter
if !tired
Expand Down Expand Up @@ -284,6 +286,7 @@ function R2DH(
outdict = Dict(
:Fhist => Fobj_hist[1:k],
:Hhist => Hobj_hist[1:k],
:Time_hist => time_hist[1:k],
:Chist => Complex_hist[1:k],
:NonSmooth => h,
:status => status,
Expand Down

0 comments on commit 4700798

Please sign in to comment.