@@ -148,8 +148,8 @@ function SolverCore.solve!(
148
148
[Int64, T, T, T, String, T, T, T],
149
149
)
150
150
verbose > 0 && @info log_row (Any[iter, ft, norm_∇f, 0.0 , " First iteration" , α])
151
-
152
- callback (nlp , solver, stats)
151
+ # Pass the nlp_at_x so that we have access to xᵢₜₑᵣ
152
+ callback (nlp_at_x , solver, stats)
153
153
154
154
while ! OK && (stats. status != :user )
155
155
preprocess! (nlp_stop, PData, workspace, ∇f, norm_∇f, α)
@@ -177,7 +177,7 @@ function SolverCore.solve!(
177
177
178
178
if Δq < 0.0 # very unsucessful
179
179
verbose > 0 &&
180
- mod (iter, verbose) == 0 &&
180
+ mod (iter, verbose) == 0 &&
181
181
@info log_row (Any[iter, ft, norm_∇f, λ, " VU" , α, norm (d), Δq])
182
182
unsucc += 1
183
183
unsuccinarow += 1
@@ -188,7 +188,7 @@ function SolverCore.solve!(
188
188
α = min (decrease (PData, α, TR), max (TR. large_decrease_factor, αbad) * α)
189
189
elseif r < acceptance_threshold # unsucessful
190
190
verbose > 0 &&
191
- mod (iter, verbose) == 0 &&
191
+ mod (iter, verbose) == 0 &&
192
192
@info log_row (Any[iter, ft, norm_∇f, λ, " U" , α, norm (d), Δq])
193
193
unsucc += 1
194
194
unsuccinarow += 1
@@ -205,25 +205,23 @@ function SolverCore.solve!(
205
205
∇f = grad! (nlp, xt, workspace)
206
206
end
207
207
norm_∇f = norm (∇f)
208
-
209
- verysucc += 1
210
208
if r > increase_threshold # very sucessful
211
209
α = increase (PData, α, TR)
212
210
verbose > 0 &&
213
- mod (iter, verbose) == 0 &&
211
+ mod (iter, verbose) == 0 &&
214
212
@info log_row (Any[iter, ft, norm_∇f, λ, " V" , α, norm (d), Δq])
213
+ verysucc += 1 # TODO : check if this makes sense
215
214
else # sucessful
216
215
if r < reduce_threshold
217
216
α = decrease (PData, α, TR)
218
217
end
219
- verbose > 0 &&
220
- mod (iter, verbose) == 0 &&
218
+ verbose > 0 &&
219
+ mod (iter, verbose) == 0 &&
221
220
@info log_row (Any[iter, ft, norm_∇f, λ, " S" , α, norm (d), Δq])
222
221
succ += 1
223
222
end
224
223
end
225
224
end # while !success
226
-
227
225
nlp_stop. meta. nb_of_stop = iter
228
226
set_x! (nlp_at_x, xt)
229
227
set_fx! (nlp_at_x, ft)
@@ -237,7 +235,11 @@ function SolverCore.solve!(
237
235
set_dual_residual! (stats, nlp_at_x. current_score)
238
236
set_iter! (stats, nlp_stop. meta. nb_of_stop)
239
237
set_time! (stats, nlp_at_x. current_time - nlp_stop. meta. start_time)
240
- callback (nlp, solver, stats)
238
+ if ! success & (unsuccinarow >= max_unsuccinarow)
239
+ # don't just cycle if we have to many unsucessful iterations
240
+ stats. status = :user
241
+ end
242
+ callback (nlp_at_x, solver, stats)
241
243
end # while !OK
242
244
243
245
stats
0 commit comments