Skip to content

Add StopWhenBelow stopping criterion - #39

Merged
lkdvos merged 3 commits into
mainfrom
stop-when-below
Nov 9, 2026
Merged

lkdvos merged 3 commits into
mainfrom
stop-when-below

Conversation

@lkdvos

@lkdvos lkdvos commented Nov 6, 2026

Copy link
Copy Markdown
Member

This PR adds StopWhenBelow(quantity, threshold), a generic criterion that stops once quantity(problem, algorithm, state) <= threshold, and indicates convergence.

  • quantity is any function of (problem, algorithm, state), such as a gradient norm or a residual.
  • StopWhenBelowState{T} records the last value and the iteration at which the threshold was reached, with T the floating point type of the threshold.
  • get_reason and summary refer to the quantity by nameof(quantity), or as "value" for anonymous functions and callable objects.
gradient_norm(problem, algorithm, state) = norm(state.gradient)
StopWhenBelow(gradient_norm, 1e-8) | StopAfterIteration(100)

This change is non-breaking.

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/AlgorithmsInterface.jl 100.00% <ø> (ø)
src/stopping_criterion.jl 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos
lkdvos marked this pull request as ready for review November 6, 2026 20:21
@lkdvos

lkdvos commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

@jack-dunham or @mtfishman, it seems like this is a generically useful primitive, any comments or suggestions still welcome!

@lkdvos
lkdvos enabled auto-merge (squash) November 9, 2026 14:51
@lkdvos
lkdvos merged commit ceb5cc5 into main Nov 9, 2026
14 checks passed
@lkdvos
lkdvos deleted the stop-when-below branch November 9, 2026 14:53
@mtfishman

Copy link
Copy Markdown

Looks good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants