Skip to content

Commit

Permalink
solve m-monotoneness issues - R2N w R2DH give the same result now
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxenceGollier committed Jan 20, 2025
1 parent daafb0b commit 3ba5675
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/R2DH_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function SolverCore.solve!(
ψ = solver.ψ
xkn = solver.xkn
s = solver.s
m_fh_hist = solver.m_fh_hist
m_fh_hist = solver.m_fh_hist .= T(-Inf)
has_bnds = solver.has_bnds

if has_bnds
Expand Down Expand Up @@ -279,14 +279,14 @@ function SolverCore.solve!(
sqrt_ξ_νInv = one(T)

@. mν∇fk = -ν₁ * ∇fk
m_monotone > 1 && (m_fh_hist[mod(stats.iter+1, m_monotone - 1) + 1] = fk + hk)

set_iter!(stats, 0)
start_time = time()
set_time!(stats, 0.0)
set_objective!(stats, fk + hk)
set_solver_specific!(stats, :smooth_obj, fk)
set_solver_specific!(stats, :nonsmooth_obj, hk)
m_monotone > 1 && (m_fh_hist[(stats.iter)%(m_monotone - 1) + 1] = fk + hk)

φ(d) = begin
result = zero(T)
Expand Down Expand Up @@ -404,7 +404,7 @@ function SolverCore.solve!(
ν₁ = 1 / ((DNorm + σk) * (1 + θ))

@. mν∇fk = -ν₁ * ∇fk
m_monotone > 1 && (m_fh_hist[mod(stats.iter+1, m_monotone - 1) + 1] = fk + hk)
m_monotone > 1 && (m_fh_hist[stats.iter%(m_monotone - 1) + 1] = fk + hk)

spectral_test ? prox!(s, ψ, mν∇fk, ν₁) : iprox!(s, ψ, ∇fk, dkσk)
mks = mk(s)
Expand Down
8 changes: 4 additions & 4 deletions src/R2N_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function SolverCore.solve!(
xkn = solver.xkn
s = solver.s
s1 = solver.s1
m_fh_hist = solver.m_fh_hist
m_fh_hist = solver.m_fh_hist .= T(-Inf)
has_bnds = solver.has_bnds

if has_bnds
Expand Down Expand Up @@ -299,14 +299,14 @@ function SolverCore.solve!(
sqrt_ξ1_νInv = one(T)

@. mν∇fk = -ν₁ * ∇fk
m_monotone > 1 && (m_fh_hist[mod(stats.iter+1, m_monotone - 1) + 1] = fk + hk)

set_iter!(stats, 0)
start_time = time()
set_time!(stats, 0.0)
set_objective!(stats, fk + hk)
set_solver_specific!(stats, :smooth_obj, fk)
set_solver_specific!(stats, :nonsmooth_obj, hk)
m_monotone > 1 && (m_fh_hist[stats.iter%(m_monotone - 1) + 1] = fk + hk)

φ1 = let ∇fk = ∇fk
d -> dot(∇fk, d)
Expand Down Expand Up @@ -361,7 +361,7 @@ function SolverCore.solve!(
solver.substats;
x = s1,
atol = sub_atol,
ν = ν₁,
ν = 1/σk,
kwargs...
)

Expand Down Expand Up @@ -445,7 +445,7 @@ function SolverCore.solve!(
end

ν₁ = 1 / ((λmax + σk) * (1 + θ))
m_monotone > 1 && (m_fh_hist[mod(stats.iter+1, m_monotone - 1) + 1] = fk + hk)
m_monotone > 1 && (m_fh_hist[stats.iter%(m_monotone - 1) + 1] = fk + hk)

set_objective!(stats, fk + hk)
set_solver_specific!(stats, :smooth_obj, fk)
Expand Down

0 comments on commit 3ba5675

Please sign in to comment.