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
15 changes: 3 additions & 12 deletions src/LMTR_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,7 @@ function SolverCore.solve!(
∆_effective = min(β * χ(s), Δk)

if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
@. l_bound_m_x .= max.(l_bound_m_x, -∆_effective)
@. u_bound_m_x .= min.(u_bound_m_x, ∆_effective)
update_bounds!(l_bound_m_x, u_bound_m_x, false, l_bound, u_bound, xk, ∆_effective)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
set_bounds!(solver.subsolver.ψ, l_bound_m_x, u_bound_m_x)
else
Expand Down Expand Up @@ -399,10 +396,7 @@ function SolverCore.solve!(
if η1 ≤ ρk < Inf
xk .= xkn
if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
@. l_bound_m_x .= max.(l_bound_m_x, -Δk)
@. u_bound_m_x .= min.(u_bound_m_x, Δk)
update_bounds!(l_bound_m_x, u_bound_m_x, false, l_bound, u_bound, xk, Δk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
set_bounds!(solver.subsolver.ψ, l_bound_m_x, u_bound_m_x)
end
Expand Down Expand Up @@ -430,10 +424,7 @@ function SolverCore.solve!(
if ρk < η1 || ρk == Inf
Δk = Δk / 2
if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
@. l_bound_m_x .= max.(l_bound_m_x, -Δk)
@. u_bound_m_x .= min.(u_bound_m_x, Δk)
update_bounds!(l_bound_m_x, u_bound_m_x, false, l_bound, u_bound, xk, ∆k)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
set_bounds!(solver.subsolver.ψ, l_bound_m_x, u_bound_m_x)
else
Expand Down
11 changes: 5 additions & 6 deletions src/LM_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ function SolverCore.solve!(
m_monotone = length(m_fh_hist) + 1

if has_bnds
l_bound = solver.l_bound
u_bound = solver.u_bound
l_bound_m_x = solver.l_bound_m_x
u_bound_m_x = solver.u_bound_m_x
l_bound, u_bound = solver.l_bound, solver.u_bound
l_bound_m_x, u_bound_m_x = solver.l_bound_m_x, solver.u_bound_m_x
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end

# initialize parameters
Expand Down Expand Up @@ -387,8 +387,7 @@ function SolverCore.solve!(
xk .= xkn

if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end

Expand Down
11 changes: 5 additions & 6 deletions src/R2DH.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ function SolverCore.solve!(
has_bnds = solver.has_bnds

if has_bnds
l_bound_m_x = solver.l_bound_m_x
u_bound_m_x = solver.u_bound_m_x
l_bound = solver.l_bound
u_bound = solver.u_bound
l_bound, u_bound = solver.l_bound, solver.u_bound
l_bound_m_x, u_bound_m_x = solver.l_bound_m_x, solver.u_bound_m_x
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end
m_monotone = length(m_fh_hist) + 1

Expand Down Expand Up @@ -388,8 +388,7 @@ function SolverCore.solve!(
if η1 ≤ ρk < Inf
xk .= xkn
if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end
fk = fkn
Expand Down
11 changes: 5 additions & 6 deletions src/R2N.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ function SolverCore.solve!(
has_bnds = solver.has_bnds

if has_bnds
l_bound_m_x = solver.l_bound_m_x
u_bound_m_x = solver.u_bound_m_x
l_bound = solver.l_bound
u_bound = solver.u_bound
l_bound, u_bound = solver.l_bound, solver.u_bound
l_bound_m_x, u_bound_m_x = solver.l_bound_m_x, solver.u_bound_m_x
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end
m_monotone = length(m_fh_hist) + 1

Expand Down Expand Up @@ -430,8 +430,7 @@ function SolverCore.solve!(
if η1 ≤ ρk < Inf
xk .= xkn
if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end
#update functions
Expand Down
11 changes: 5 additions & 6 deletions src/R2_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ function SolverCore.solve!(
s = solver.s
has_bnds = solver.has_bnds
if has_bnds
l_bound = solver.l_bound
u_bound = solver.u_bound
l_bound_m_x = solver.l_bound_m_x
u_bound_m_x = solver.u_bound_m_x
l_bound, u_bound = solver.l_bound, solver.u_bound
l_bound_m_x, u_bound_m_x = solver.l_bound_m_x, solver.u_bound_m_x
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end

# initialize parameters
Expand Down Expand Up @@ -462,8 +462,7 @@ function SolverCore.solve!(
if η1 ≤ ρk < Inf
xk .= xkn
if has_bnds
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
update_bounds!(l_bound_m_x, u_bound_m_x, l_bound, u_bound, xk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end
fk = fkn
Expand Down
11 changes: 0 additions & 11 deletions src/RegularizedOptimization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ Notably, you can access, and modify, the following:
- `stats.elapsed_time`: elapsed time in seconds.
"

# update l_bound_k and u_bound_k
function update_bounds!(l_bound_k, u_bound_k, is_subsolver, l_bound, u_bound, xk, Δ)
if is_subsolver
@. l_bound_k = max(xk - Δ, l_bound)
@. u_bound_k = min(xk + Δ, u_bound)
else
@. l_bound_k = max(-Δ, l_bound - xk)
@. u_bound_k = min(Δ, u_bound - xk)
end
end

include("utils.jl")
include("input_struct.jl")
include("TR_alg.jl")
Expand Down
23 changes: 11 additions & 12 deletions src/TRDH_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,17 @@ function SolverCore.solve!(
χ = solver.χ
has_bnds = solver.has_bnds

is_subsolver = h isa ShiftedProximableFunction # case TRDH is used as a subsolver

if has_bnds
l_bound_m_x = solver.l_bound_m_x
u_bound_m_x = solver.u_bound_m_x
l_bound = solver.l_bound
u_bound = solver.u_bound
l_bound_m_x, u_bound_m_x = solver.l_bound_m_x, solver.u_bound_m_x
l_bound, u_bound = solver.l_bound, solver.u_bound
if is_subsolver
l_bound .= ψ.l
u_bound .= ψ.u
end
update_bounds!(l_bound_m_x, u_bound_m_x, is_subsolver, l_bound, u_bound, xk, Δk)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end

# initialize parameters
Expand All @@ -286,13 +292,6 @@ function SolverCore.solve!(
improper == true && @warn "TRDH: Improper term detected"
improper == true && return stats

is_subsolver = h isa ShiftedProximableFunction # case TRDH is used as a subsolver

if is_subsolver
l_bound .= ψ.l
u_bound .= ψ.u
end

if verbose > 0
@info log_header(
[:iter, :fx, :hx, :xi, :ρ, :Δ, :normx, :norms, :normD, :arrow],
Expand Down Expand Up @@ -439,7 +438,7 @@ function SolverCore.solve!(
xk .= xkn
if has_bnds
update_bounds!(l_bound_m_x, u_bound_m_x, is_subsolver, l_bound, u_bound, xk, Δk)
has_bnds && set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
set_bounds!(ψ, l_bound_m_x, u_bound_m_x)
end
fk = fkn
hk = hkn
Expand Down
15 changes: 15 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,18 @@ function get_status(
:unknown
end
end

function update_bounds!(l_bound_m_x::V, u_bound_m_x::V, l_bound::V, u_bound::V, xk::V,) where {V <: AbstractVector}
@. l_bound_m_x = l_bound - xk
@. u_bound_m_x = u_bound - xk
end

function update_bounds!(l_bound_m_x::V, u_bound_m_x::V, is_subsolver::Bool, l_bound::V, u_bound::V, xk::V, Δ::T) where {T <: Real, V <: AbstractVector{T}}
if is_subsolver
@. l_bound_m_x = max(xk - Δ, l_bound)
@. u_bound_m_x = min(xk + Δ, u_bound)
else
@. l_bound_m_x = max(-Δ, l_bound - xk)
@. u_bound_m_x = min(Δ, u_bound - xk)
end
end
Loading