@@ -51,6 +51,7 @@ function R2N(
5151 subsolver_logger:: Logging.AbstractLogger = Logging. NullLogger (),
5252 subsolver = R2,
5353 subsolver_options = ROSolverOptions (ϵa = options. ϵa),
54+ Mmonotone:: Int = 0 ,
5455 selected:: AbstractVector{<:Integer} = 1 : (f. meta. nvar),
5556) where {H, R}
5657 start_time = time ()
@@ -71,6 +72,7 @@ function R2N(
7172 σmin = options. σmin
7273 α = options. α
7374 β = options. β
75+ σk = options. σk
7476
7577 # store initial values of the subsolver_options fields that will be modified
7678 ν_subsolver = subsolver_options. ν
@@ -94,7 +96,6 @@ function R2N(
9496
9597 # initialize parameters
9698 # σk = max(1 / options.ν, σmin) #SVM
97- σk = σmin
9899 xk = copy (x0)
99100 hk = h (xk[selected])
100101 if hk == Inf
@@ -112,6 +113,7 @@ function R2N(
112113
113114 Fobj_hist = zeros (maxIter)
114115 Hobj_hist = zeros (maxIter)
116+ FHobj_hist = fill! (Vector {R} (undef, Mmonotone), R (- Inf ))
115117 Complex_hist = zeros (Int, maxIter)
116118 if verbose > 0
117119 # ! format: off
@@ -143,6 +145,7 @@ function R2N(
143145 elapsed_time = time () - start_time
144146 Fobj_hist[k] = fk
145147 Hobj_hist[k] = hk
148+ Mmonotone > 0 && (FHobj_hist[mod (k- 1 , Mmonotone) + 1 ] = fk + hk)
146149
147150 # model for first prox-gradient step and ξ1
148151 φ1 (d) = ∇fk' * d
@@ -168,9 +171,6 @@ function R2N(
168171 ξ1 = hk - mk1 (s) + max (1 , abs (hk)) * 10 * eps ()
169172 ξ1 > 0 || error (" R2N: first prox-gradient step should produce a decrease but ξ1 = $(ξ1) " )
170173 sqrt_ξ1_νInv = sqrt (ξ1 * νInv)
171- # println("sqrt_ξ1_νInv: ", sqrt_ξ1_νInv)
172- # println("ξ1: ", ξ1)
173- # println("νInv: ", νInv)
174174
175175 if ξ1 ≥ 0 && k == 1
176176 ϵ_increment = ϵr * sqrt_ξ1_νInv
@@ -186,9 +186,9 @@ function R2N(
186186 s1 = copy (s)
187187
188188 # subsolver_options.ϵa = k == 1 ? 1.0e-1 : max(ϵ_subsolver, min(1.0e-2, ξ1 / 10))
189- subsolver_options. ϵa = k == 1 ? 1.0e-3 : max (ϵ_subsolver, min ( 1e-3 , sqrt_ξ1_νInv) ) # 1.0e-5 default
189+ subsolver_options. ϵa = k == 1 ? 1.0e-3 : min (sqrt_ξ1_νInv ^ ( 1.5 ) , sqrt_ξ1_νInv * 1e-3 ) # 1.0e-5 default
190190 @debug " setting inner stopping tolerance to" subsolver_options. optTol
191- subsolver_args = subsolver == R2DH ? (SpectralGradient (1. , f. meta. nvar),) : ()
191+ subsolver_args = subsolver == R2DH ? (SpectralGradient (νInv , f. meta. nvar),) : ()
192192 s, iter, _ = with_logger (subsolver_logger) do
193193 subsolver (φ, ∇φ!, ψ, subsolver_args... , subsolver_options, s)
194194 end
@@ -208,18 +208,21 @@ function R2N(
208208 hkn = h (xkn[selected])
209209 hkn == - Inf && error (" nonsmooth term is not proper" )
210210 mks = mk (s) # - σk * dot(s, s) / 2
211- Δobj = fk + hk - (fkn + hkn) + max (1 , abs (fk + hk)) * 10 * eps ()
211+
212+ fhmax = Mmonotone > 0 ? maximum (FHobj_hist) : fk + hk
213+ Δobj = fhmax - (fkn + hkn) + max (1 , abs (fhmax)) * 10 * eps ()
214+ Δmod = fhmax - (fk + mks) + max (1 , abs (hk)) * 10 * eps ()
212215 ξ = hk - mks + max (1 , abs (hk)) * 10 * eps ()
213216
214217 if (ξ ≤ 0 || isnan (ξ))
215218 error (" R2N: failed to compute a step: ξ = $ξ " )
216219 end
217220
218- ρk = Δobj / ξ
221+ ρk = Δobj / Δmod
219222
220223 R2N_stat = (η2 ≤ ρk < Inf ) ? " ↗" : (ρk < η1 ? " ↘" : " =" )
221224
222- if (verbose > 0 ) && (k % ptf == 0 )
225+ if (verbose > 0 ) && (( k % ptf == 0 ) || (k == 1 ) )
223226 # ! format: off
224227 @info @sprintf " %6d %8d %8.1e %8.1e %7.1e %7.1e %8.1e %7.1e %7.1e %7.1e %7.1e %1s" k iter fk hk sqrt_ξ1_νInv sqrt (ξ1) ρk σk norm (xk) norm (s) λmax R2N_stat
225228 # ! format: off
@@ -251,8 +254,7 @@ function R2N(
251254 if ρk < η1 || ρk == Inf
252255 σk = σk * γ
253256 end
254- νInv = (1 + θ) * ( σk + λmax)
255-
257+ νInv = (1 + θ) * (σk + λmax)
256258 tired = k ≥ maxIter || elapsed_time > maxTime
257259 end
258260
0 commit comments