@@ -542,14 +542,15 @@ struct WolfeInfo {
542542/* *
543543 * Retry evaluation of a step until it passes a validity check.
544544 *
545- * The update callable is invoked with `(curr, prev, eval, p)` and is expected to
546- * fill `eval` (at `eval.alpha()`) with the objective and directional
545+ * The update callable is invoked with `(curr, prev, eval, p)` and is expected
546+ * to fill `eval` (at `eval.alpha()`) with the objective and directional
547547 * derivative. If the evaluation is not valid, the backoff callable should
548548 * shrink `eval.alpha()` and return whether another retry should be attempted.
549549 * The validity check can inspect the evaluation and, for non-void updates, the
550550 * returned status.
551551 *
552- * @tparam Update Callable that performs one evaluation step. Must accept 4 arguments.
552+ * @tparam Update Callable that performs one evaluation step. Must accept 4
553+ * arguments.
553554 * @tparam Curr Current state type passed to `update`.
554555 * @tparam Prev Previous state type passed to `update`.
555556 * @tparam Eval Evaluation record containing alpha/obj/dir.
@@ -568,12 +569,13 @@ struct WolfeInfo {
568569 * @return For void updates, returns void. Otherwise returns the value from the
569570 * first valid evaluation.
570571 */
571- template <typename Update, typename Proposal, typename Curr, typename Prev, typename Eval,
572- typename P, typename Backoff, typename IsValid>
573- inline auto retry_evaluate (Update&& update, Proposal&& proposal, Curr&& curr, Prev&& prev, Eval& eval,
574- P&& p, Backoff&& backoff, IsValid&& is_valid) {
575- if constexpr (std::is_void_v<
576- std::invoke_result_t <Update&, Proposal, Curr, Prev, Eval&, P>>) {
572+ template <typename Update, typename Proposal, typename Curr, typename Prev,
573+ typename Eval, typename P, typename Backoff, typename IsValid>
574+ inline auto retry_evaluate (Update&& update, Proposal&& proposal, Curr&& curr,
575+ Prev&& prev, Eval& eval, P&& p, Backoff&& backoff,
576+ IsValid&& is_valid) {
577+ if constexpr (std::is_void_v<std::invoke_result_t <Update&, Proposal, Curr,
578+ Prev, Eval&, P>>) {
577579 while (true ) {
578580 update (proposal, curr, prev, eval, p);
579581 if (is_valid (eval)) {
@@ -596,7 +598,6 @@ inline auto retry_evaluate(Update&& update, Proposal&& proposal, Curr&& curr, Pr
596598 }
597599}
598600
599-
600601/* *
601602 * @brief Strong-Wolfe line search with expansion, bracketing, and
602603 * cubic/bisection zoom.
@@ -885,8 +886,10 @@ inline WolfeStatus wolfe_line_search(Info& wolfe_info, UpdateFun&& update_fun,
885886 && state.theta ().allFinite () && state.theta_grad ().allFinite ();
886887 };
887888 Eval best = low; // keep the best Armijo-OK in case strong-Wolfe fails
888- auto update_with_tick
889- = [&total_updates, &opt, &best, &update_fun, &assign_step, &wolfe_ok, &armijo_ok](auto && proposal, auto && curr, auto && prev, Eval& e, auto && p) {
889+ auto update_with_tick = [&total_updates, &opt, &best, &update_fun,
890+ &assign_step, &wolfe_ok,
891+ &armijo_ok](auto && proposal, auto && curr,
892+ auto && prev, Eval& e, auto && p) {
890893 const bool over_budget = total_updates > opt.max_iterations ;
891894 if (over_budget) {
892895 // Soft budget: stop evaluating new trial points once exceeded.
@@ -918,10 +921,11 @@ inline WolfeStatus wolfe_line_search(Info& wolfe_info, UpdateFun&& update_fun,
918921 return eval.alpha () >= opt.min_alpha ;
919922 };
920923 auto is_valid = [&](const Eval& eval, const WolfeStatus& status) {
921- return status.stop_ != WolfeReturn::Continue || eval_finite (eval, scratch);
924+ return status.stop_ != WolfeReturn::Continue
925+ || eval_finite (eval, scratch);
922926 };
923- wolfe_check = retry_evaluate (update_with_tick, scratch, curr, prev, high, p, backoff,
924- is_valid);
927+ wolfe_check = retry_evaluate (update_with_tick, scratch, curr, prev, high, p,
928+ backoff, is_valid);
925929 if (wolfe_check.stop_ != WolfeReturn::Continue) {
926930 return wolfe_check;
927931 }
@@ -1081,10 +1085,11 @@ inline WolfeStatus wolfe_line_search(Info& wolfe_info, UpdateFun&& update_fun,
10811085 return eval.alpha () > opt.min_alpha ;
10821086 };
10831087 auto is_valid = [&](const Eval& eval, const WolfeStatus& status) {
1084- return status.stop_ != WolfeReturn::Continue || eval_finite (eval, scratch);
1088+ return status.stop_ != WolfeReturn::Continue
1089+ || eval_finite (eval, scratch);
10851090 };
1086- auto wolfe_check = retry_evaluate (update_with_tick, scratch, curr, prev, mid, p,
1087- backoff, is_valid);
1091+ auto wolfe_check = retry_evaluate (update_with_tick, scratch, curr, prev,
1092+ mid, p, backoff, is_valid);
10881093 if (wolfe_check.stop_ != WolfeReturn::Continue) {
10891094 return wolfe_check;
10901095 }
0 commit comments