Skip to content

Commit 08bc4d6

Browse files
implicit hessian update fix
1 parent 8202046 commit 08bc4d6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/TR_alg.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function TRSolver(
5959
shifted(reg_nlp.h, xk, l_bound_m_x, u_bound_m_x, reg_nlp.selected) :
6060
shifted(reg_nlp.h, xk, T(1), χ)
6161

62-
Bk = hess_op(reg_nlp.model, x0)
62+
Bk = isa(reg_nlp.model, QuasiNewtonModel) ? hess_op(reg_nlp.model, xk) : hess_op!(reg_nlp.model, xk, similar(xk))
6363
sub_nlp = R2NModel(Bk, ∇fk, zero(T), x0) #FIXME
6464
subpb = RegularizedNLPModel(sub_nlp, ψ)
6565
substats = RegularizedExecutionStats(subpb)
@@ -94,7 +94,7 @@ A trust-region method for the problem
9494
min f(x) + h(x)
9595
9696
where f: ℝⁿ → ℝ has a Lipschitz-continuous gradient, and h: ℝⁿ → ℝ is
97-
lower semi-continuous, proper and prox-bounded.
97+
lower semi-continuous and proper.
9898
9999
About each iterate xₖ, a step sₖ is computed as an approximate solution of
100100
@@ -266,7 +266,6 @@ function SolverCore.solve!(
266266
end
267267
improper = (hk == -Inf)
268268
improper == true && @warn "TR: Improper term detected"
269-
improper == true && return stats
270269

271270
if verbose > 0
272271
@info log_header(
@@ -286,15 +285,14 @@ function SolverCore.solve!(
286285
end
287286

288287
local ξ1::T
289-
local ρk::T = zero(T)
288+
local ρk = zero(T)
290289

291290
fk = obj(nlp, xk)
292291
grad!(nlp, xk, ∇fk)
293292
∇fk⁻ .= ∇fk
294293

295294
quasiNewtTest = isa(nlp, QuasiNewtonModel)
296-
λmax::T = T(1)
297-
solver.subpb.model.B = hess_op(nlp, xk)
295+
λmax = T(1)
298296

299297
λmax, found_λ = opnorm(solver.subpb.model.B)
300298
found_λ || error("operator norm computation failed")
@@ -324,6 +322,7 @@ function SolverCore.solve!(
324322
end
325323

326324
prox!(s, ψ, mν∇fk, ν₁)
325+
#println(solver.subpb.model.B*ones(length(xk)))
327326
ξ1 = hk - mk1(s) + max(1, abs(hk)) * 10 * eps()
328327
ξ1 > 0 || error("TR: first prox-gradient step should produce a decrease but ξ1 = $(ξ1)")
329328
sqrt_ξ1_νInv = sqrt(ξ1 / ν₁)
@@ -419,7 +418,7 @@ function SolverCore.solve!(
419418
χ(xk),
420419
sNorm,
421420
λmax,
422-
(η2 ρk < Inf) ? "" : (ρk < η1 ? "" : "="),
421+
(η2 ρk < Inf) ? '' : (ρk < η1 ? '' : '='),
423422
],
424423
colsep = 1,
425424
)
@@ -453,8 +452,6 @@ function SolverCore.solve!(
453452
push!(nlp, s, ∇fk⁻) # update QN operator
454453
end
455454

456-
solver.subpb.model.B = hess_op(nlp, xk)
457-
458455
λmax, found_λ = opnorm(solver.subpb.model.B)
459456
found_λ || error("operator norm computation failed")
460457

0 commit comments

Comments
 (0)