diff --git a/src/main.jl b/src/main.jl index 8e2c98b..73702df 100644 --- a/src/main.jl +++ b/src/main.jl @@ -148,7 +148,6 @@ function SolverCore.solve!( [Int64, T, T, T, String, T, T, T], ) verbose > 0 && @info log_row(Any[iter, ft, norm_∇f, 0.0, "First iteration", α]) - callback(nlp, solver, stats) while !OK && (stats.status != :user) @@ -177,7 +176,7 @@ function SolverCore.solve!( if Δq < 0.0 # very unsucessful verbose > 0 && - mod(iter, verbose) == 0 && + mod(iter, verbose) == 0 && @info log_row(Any[iter, ft, norm_∇f, λ, "VU", α, norm(d), Δq]) unsucc += 1 unsuccinarow += 1 @@ -188,7 +187,7 @@ function SolverCore.solve!( α = min(decrease(PData, α, TR), max(TR.large_decrease_factor, αbad) * α) elseif r < acceptance_threshold # unsucessful verbose > 0 && - mod(iter, verbose) == 0 && + mod(iter, verbose) == 0 && @info log_row(Any[iter, ft, norm_∇f, λ, "U", α, norm(d), Δq]) unsucc += 1 unsuccinarow += 1 @@ -205,25 +204,23 @@ function SolverCore.solve!( ∇f = grad!(nlp, xt, workspace) end norm_∇f = norm(∇f) - - verysucc += 1 if r > increase_threshold # very sucessful α = increase(PData, α, TR) verbose > 0 && - mod(iter, verbose) == 0 && + mod(iter, verbose) == 0 && @info log_row(Any[iter, ft, norm_∇f, λ, "V", α, norm(d), Δq]) + verysucc += 1 else # sucessful if r < reduce_threshold α = decrease(PData, α, TR) end - verbose > 0 && - mod(iter, verbose) == 0 && + verbose > 0 && + mod(iter, verbose) == 0 && @info log_row(Any[iter, ft, norm_∇f, λ, "S", α, norm(d), Δq]) succ += 1 end end end # while !success - nlp_stop.meta.nb_of_stop = iter set_x!(nlp_at_x, xt) set_fx!(nlp_at_x, ft) @@ -237,6 +234,9 @@ function SolverCore.solve!( set_dual_residual!(stats, nlp_at_x.current_score) set_iter!(stats, nlp_stop.meta.nb_of_stop) set_time!(stats, nlp_at_x.current_time - nlp_stop.meta.start_time) + if unsuccinarow >= max_unsuccinarow + stats.status = :user + end callback(nlp, solver, stats) end # while !OK