Skip to content

Commit 5b2cc0a

Browse files
fix reproducibility with TR-TRDH
1 parent ea0eaa2 commit 5b2cc0a

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

src/TR_alg.jl

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ function TR(
159159
χ::X,
160160
options::ROSolverOptions{R};
161161
x0::AbstractVector{R} = f.meta.x0,
162-
subsolver = R2Solver,
163162
subsolver_options = ROSolverOptions(ϵa = options.ϵa),
164163
selected::AbstractVector{<:Integer} = 1:(f.meta.nvar),
165164
kwargs...
@@ -181,7 +180,6 @@ function TR(
181180
γ = options.γ,
182181
α = options.α,
183182
β = options.β,
184-
subsolver = R2Solver,
185183
kwargs...
186184
)
187185
return stats
@@ -429,12 +427,21 @@ function SolverCore.solve!(
429427
colsep = 1,
430428
)
431429

430+
if η2 ρk < Inf
431+
Δk = max(Δk, γ * sNorm)
432+
if !(has_bnds || isa(solver.subsolver, TRDHSolver))
433+
set_radius!(ψ, Δk)
434+
set_radius!(solver.subsolver.ψ, Δk)
435+
end
436+
end
437+
432438
if η1 ρk < Inf
433439
xk .= xkn
434-
∆_effective = min* χ(s), Δk)
435440
if has_bnds || isa(solver.subsolver, TRDHSolver)
436441
@. l_bound_m_x = l_bound - xk
437442
@. u_bound_m_x = u_bound - xk
443+
@. l_bound_m_x .= max.(l_bound_m_x, -Δk)
444+
@. u_bound_m_x .= min.(u_bound_m_x, Δk)
438445
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
439446
set_bounds!(solver.subsolver.ψ, l_bound_m_x, u_bound_m_x)
440447
end
@@ -447,6 +454,8 @@ function SolverCore.solve!(
447454
if quasiNewtTest
448455
@. ∇fk⁻ = ∇fk - ∇fk⁻
449456
push!(nlp, s, ∇fk⁻) # update QN operator
457+
#println(ψ)
458+
#stats.iter == 1 && error("done")
450459
end
451460

452461
solver.subpb.model.B = hess_op(nlp, xk)
@@ -457,20 +466,19 @@ function SolverCore.solve!(
457466
∇fk⁻ .= ∇fk
458467
end
459468

460-
if η2 ρk < Inf
461-
Δk = max(Δk, γ * sNorm)
462-
if !(has_bnds || isa(solver.subsolver, TRDHSolver))
463-
set_radius!(ψ, Δk)
464-
end
465-
end
466-
467-
if η2 ρk < Inf
468-
Δk = max(Δk, γ * sNorm)
469-
!(has_bnds || isa(solver.subsolver, TRDHSolver)) && set_radius!(ψ, Δk)
470-
end
471-
472469
if ρk < η1 || ρk == Inf
473470
Δk = Δk / 2
471+
if has_bnds || isa(solver.subsolver, TRDHSolver)
472+
@. l_bound_m_x = l_bound - xk
473+
@. u_bound_m_x = u_bound - xk
474+
@. l_bound_m_x .= max.(l_bound_m_x, -Δk)
475+
@. u_bound_m_x .= min.(u_bound_m_x, Δk)
476+
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
477+
set_bounds!(solver.subsolver.ψ, l_bound_m_x, u_bound_m_x)
478+
else
479+
set_radius!(ψ, Δk)
480+
set_radius!(solver.subsolver.ψ, Δk)
481+
end
474482
end
475483

476484
set_objective!(stats, fk + hk)

0 commit comments

Comments
 (0)