Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/demo-bpdn-constr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function demo_solver(f, nls, sol, h, χ, suffix = "l0-linf")
R2_out = R2(f, h, options, x0 = f.meta.x0)
@info "R2 relative error" norm(R2_out.solution - sol) / norm(sol)
plot_bpdn(R2_out, sol, "constr-r2-$(suffix)")

@info " using LMTR to solve with" h χ
reset!(nls)
LMTR_out = LMTR(nls, h, χ, options, x0 = f.meta.x0)
Expand Down
14 changes: 8 additions & 6 deletions src/LMTR_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function LMTR(
subsolver_logger::Logging.AbstractLogger = Logging.NullLogger(),
subsolver = R2,
subsolver_options = ROSolverOptions(),
selected::AbstractVector{<:Integer} = 1:nls.meta.nvar,
selected::AbstractVector{<:Integer} = 1:(nls.meta.nvar),
) where {H, X}
start_time = time()
elapsed_time = 0.0
Expand Down Expand Up @@ -96,10 +96,10 @@ function LMTR(

xkn = similar(xk)
s = zero(xk)
ψ = has_bounds(nls) ? shifted(h, xk, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk), selected) :
ψ =
has_bounds(nls) ? shifted(h, xk, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk), selected) :
shifted(h, xk, Δk, χ)


Fobj_hist = zeros(maxIter)
Hobj_hist = zeros(maxIter)
Complex_hist = zeros(Int, maxIter)
Expand Down Expand Up @@ -178,8 +178,9 @@ function LMTR(

subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ, min(1.0e-1, ξ1 / 10))
∆_effective = min(β * χ(s), Δk)
has_bounds(nls) ? set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :
set_radius!(ψ, ∆_effective)
has_bounds(nls) ?
set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :
set_radius!(ψ, ∆_effective)
s, iter, _ = with_logger(subsolver_logger) do
subsolver(φ, ∇φ!, ψ, subsolver_options, s)
end
Expand Down Expand Up @@ -236,7 +237,8 @@ function LMTR(

if ρk < η1 || ρk == Inf
Δk = Δk / 2
has_bounds(nls) ? set_bounds!(ψ, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk)) : set_radius!(ψ, Δk)
has_bounds(nls) ? set_bounds!(ψ, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk)) :
set_radius!(ψ, Δk)
end

tired = k ≥ maxIter || elapsed_time > maxTime
Expand Down