@@ -213,8 +213,6 @@ namespace polysolve::nonlinear
213213 objFunc.solution_changed (x);
214214 }
215215
216- objFunc.post_step (PostStepData (this ->m_current .iterations , x, grad));
217-
218216 const auto g_norm_tol = this ->m_stop .gradNorm ;
219217 this ->m_stop .gradNorm = first_grad_norm_tol;
220218
@@ -229,6 +227,7 @@ namespace polysolve::nonlinear
229227 this ->m_stop .fDelta , this ->m_stop .gradNorm , this ->m_stop .xDelta );
230228
231229 update_solver_info (objFunc.value (x));
230+ objFunc.post_step (PostStepData (this ->m_current .iterations , solver_info, x, grad));
232231
233232 int f_delta_step_cnt = 0 ;
234233 double f_delta = 0 ;
@@ -386,15 +385,16 @@ namespace polysolve::nonlinear
386385 // -----------
387386 const double step = (rate * delta_x).norm ();
388387
388+ update_solver_info (energy);
389+ objFunc.post_step (PostStepData (this ->m_current .iterations , solver_info, x, grad));
390+
389391 if (objFunc.stop (x))
390392 {
391393 this ->m_status = cppoptlib::Status::UserDefined;
392394 m_error_code = ErrorCode::SUCCESS;
393395 m_logger.debug (" [{}][{}] Objective decided to stop" , name (), m_line_search->name ());
394396 }
395397
396- objFunc.post_step (PostStepData (this ->m_current .iterations , x, grad));
397-
398398 if (f_delta < this ->m_stop .fDelta )
399399 f_delta_step_cnt++;
400400 else
@@ -411,8 +411,6 @@ namespace polysolve::nonlinear
411411 if (++this ->m_current .iterations >= this ->m_stop .iterations )
412412 this ->m_status = cppoptlib::Status::IterationLimit;
413413
414- update_solver_info (energy);
415-
416414 // reset the tolerance, since in the first iter it might be smaller
417415 this ->m_stop .gradNorm = g_norm_tol;
418416 } while (objFunc.callback (this ->m_current , x) && (this ->m_status == cppoptlib::Status::Continue));
0 commit comments