From d4080fdb9114391d1df5367333e828cc1bc28ed6 Mon Sep 17 00:00:00 2001 From: Manuel Berkemeier Date: Thu, 12 Sep 2024 12:56:09 +0200 Subject: [PATCH] fix in compatibility test --- src/criticality_routine.jl | 21 ++++++++++++++++----- src/trial.jl | 17 +++++++++-------- src/utils.jl | 3 +-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/criticality_routine.jl b/src/criticality_routine.jl index 8d4990e..e9b40da 100644 --- a/src/criticality_routine.jl +++ b/src/criticality_routine.jl @@ -17,6 +17,7 @@ function criticality_routine!( χ = step_vals.crit_ref[] θ = cached_theta(vals) stop_code = nothing + break_because_incompatible = false if θ < eps_theta && (χ < eps_crit && Δ > crit_M * χ ) @logmsg log_level "$(pad_str)ITERATION $(it_index): CRITICALITY ROUTINE (θ = $θ)." ## init @@ -55,6 +56,7 @@ function criticality_routine!( if !compatibility_test(step_vals.n, algo_opts, Δj) # make sure we have compatible steps after exiting the loop universal_copy!(step_vals, crit_cache.step_vals) + break_because_incompatible = true break end @@ -84,11 +86,20 @@ function criticality_routine!( @ignoraise finalize_step_vals!( step_cache, step_vals, Δ, mop, mod, scaler, lin_cons, scaled_cons, vals, mod_vals; log_level) indent end - @logmsg log_level """ - $(pad_str) Finished after $j criticality loop(s), - $(pad_str) Δ=$_Δ <= Mχ=$(crit_M * χ), now Δ=$Δ, - $(pad_str) Criticality χ=$(step_vals.crit_ref[]), $(χ), - $(pad_str) ‖d‖₂=$(LA.norm(step_vals.d)), ‖s‖₂=$(LA.norm(step_vals.s)).""" + @logmsg log_level """\n + $(pad_str) Finished after $j criticality loop(s),\ + $(if break_because_incompatible + "\n$(pad_str) normal step would be incompatible," + else + "" + end) + $(pad_str) Values: + $(pad_str) _Δ = $_Δ + $(pad_str) Mξ = $(crit_M * χ) + $(pad_str) χ = $(step_vals.crit_ref[]), + $(pad_str) ‖d‖₂ = $(LA.norm(step_vals.d)), + $(pad_str) ‖s‖₂ = $(LA.norm(step_vals.s)), + $(pad_str) Δ = $(Δ)""" end if isa(stop_code, AbstractStoppingCriterion) return stop_code diff --git a/src/trial.jl b/src/trial.jl index 816da81..4709041 100644 --- a/src/trial.jl +++ b/src/trial.jl @@ -108,6 +108,12 @@ function _test_trial_point!( if is_f_step iteration_classification = IT_F_STEP + + else + # constraint violation significant compared to predicted decrease + iteration_classification = IT_THETA_STEP + end + if !isnan(rho) if rho >= nu_accept if rho >= nu_success rho_classification = RHO_SUCCESS @@ -117,9 +123,6 @@ function _test_trial_point!( else rho_classification = RHO_FAIL end - else - # constraint violation significant compared to predicted decrease - iteration_classification = IT_THETA_STEP end end return iteration_classification, rho, rho_classification @@ -243,8 +246,8 @@ function _update_radius( nu_accept, nu_success ) radius_update = nothing - if iteration_classification == IT_F_STEP || - iteration_classification == IT_THETA_STEP + if iteration_classification == IT_F_STEP + #iteration_classification == IT_THETA_STEP if rho_classification == RHO_ACCEPT gamma_factor = gamma_shrink if nu_success > nu_accept @@ -261,12 +264,10 @@ function _update_radius( delta_new = delta radius_update = RADIUS_GROW_FAIL end - end - #= + end elseif iteration_classification == IT_THETA_STEP delta_new = delta radius_update = RADIUS_NO_CHANGE - =# end if isnothing(radius_update) diff --git a/src/utils.jl b/src/utils.jl index b9013f6..99c63e4 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -107,9 +107,8 @@ function log_stop_code(crit, log_level) @logmsg log_level stop_message(crit) end - function compatibility_test_rhs(c_delta, c_mu, mu, Δ) - return c_delta * min(Δ, c_mu + Δ^(1+mu)) + return c_delta * min(Δ, c_mu * Δ^(1+mu)) end function compatibility_test(n, c_delta, c_mu, mu, Δ)