1414#include < jse/jse.h>
1515
1616#include < spdlog/spdlog.h>
17+ #if defined(SPDLOG_FMT_EXTERNAL)
18+ #include < fmt/color.h>
19+ #else
1720#include < spdlog/fmt/bundled/color.h>
21+ #endif
1822#include < spdlog/fmt/ostr.h>
1923
2024#include < finitediff.hpp>
@@ -279,7 +283,7 @@ namespace polysolve::nonlinear
279283
280284 m_logger.debug (
281285 " Starting {} with {} solve f₀={:g} (stopping criteria: {})" ,
282- descent_strategy_name (), m_line_search->name (), objFunc (x), m_stop);
286+ descent_strategy_name (), m_line_search->name (), objFunc (x), m_stop. print_message () );
283287
284288 update_solver_info (objFunc (x));
285289 objFunc.post_step (PostStepData (m_current.iterations , solver_info, x, grad));
@@ -350,12 +354,12 @@ namespace polysolve::nonlinear
350354 m_status = Status::UpdateDirectionFailed;
351355 log_and_throw_error (
352356 m_logger, " [{}][{}] {} on last strategy; stopping" ,
353- current_name, m_line_search->name (), m_status);
357+ current_name, m_line_search->name (), status_message ( m_status) );
354358 }
355359
356360 m_logger.debug (
357361 " [{}][{}] {}; reverting to {}" , current_name, m_line_search->name (),
358- Status::UpdateDirectionFailed, descent_strategy_name ());
362+ status_message ( Status::UpdateDirectionFailed) , descent_strategy_name ());
359363 m_status = Status::Continue;
360364 continue ;
361365 }
@@ -374,15 +378,15 @@ namespace polysolve::nonlinear
374378 m_status = Status::NotDescentDirection;
375379 log_and_throw_error (
376380 m_logger, " [{}][{}] {} on last strategy (‖Δx‖={:g}; ‖g‖={:g}; Δx⋅g={:g}≥0); stopping" ,
377- current_name, m_line_search->name (), m_status, delta_x.norm (), compute_grad_norm (x, grad),
381+ current_name, m_line_search->name (), status_message ( m_status) , delta_x.norm (), compute_grad_norm (x, grad),
378382 m_current.xDeltaDotGrad );
379383 }
380384 else
381385 {
382386 m_status = Status::Continue;
383387 m_logger.debug (
384388 " [{}][{}] {} (‖Δx‖={:g}; ‖g‖={:g}; Δx⋅g={:g}≥0); reverting to {}" ,
385- current_name, m_line_search->name (), Status::NotDescentDirection,
389+ current_name, m_line_search->name (), status_message ( Status::NotDescentDirection) ,
386390 delta_x.norm (), compute_grad_norm (x, grad), m_current.xDeltaDotGrad ,
387391 descent_strategy_name ());
388392 }
@@ -479,7 +483,7 @@ namespace polysolve::nonlinear
479483
480484 m_logger.debug (
481485 " [{}][{}] {} (stopping criteria: {})" ,
482- descent_strategy_name (), m_line_search->name (), m_current, m_stop);
486+ descent_strategy_name (), m_line_search->name (), m_current. print_message () , m_stop. print_message () );
483487
484488 if (++m_current.iterations >= m_stop.iterations )
485489 m_status = Status::IterationLimit;
@@ -501,8 +505,8 @@ namespace polysolve::nonlinear
501505 m_logger.log (
502506 succeeded ? spdlog::level::info : spdlog::level::err,
503507 " [{}][{}] Finished: {} took {:g}s ({}) (stopping criteria: {})" ,
504- descent_strategy_name (), m_line_search->name (), m_status, tot_time,
505- m_current, m_stop);
508+ descent_strategy_name (), m_line_search->name (), status_message ( m_status) , tot_time,
509+ m_current. print_message () , m_stop. print_message () );
506510
507511 log_times ();
508512 update_solver_info (objFunc (x));
0 commit comments