Skip to content

Add callbacks to all solver states and interfaces, and start a developer guide section - #626

Merged
kellertuer merged 71 commits into
masterfrom
kellertuer/Callbacks
Jul 17, 2026
Merged

Add callbacks to all solver states and interfaces, and start a developer guide section#626
kellertuer merged 71 commits into
masterfrom
kellertuer/Callbacks

Conversation

@kellertuer

@kellertuer kellertuer commented Jul 10, 2026

Copy link
Copy Markdown
Member

This PR introduces callbacks into the solver interface by adding a field to all solvers.
The documentation is refactored to some extend to split the formerplan into a Developer guid (base/) and the library section of common elements that solvers share (commons) – which is also reflected in the code organisation.

Solvers to refactor

  • adaptive_regularization_with_cubics (AdaptiveRegularizationState)
  • alternating_gradient_descent (AlternatingGradientDescentState)
  • augmented_Lagrangian_method (AugmentedLagrangianMethodState)
  • convex_bundle_method (ConvexBundleMethodState)
  • ChambollePock (ChambollePockState)
  • cma_es (CMAESState) - state is now also exported
  • conjugate_gradient_descent (ConjugateGradientDescentState)
  • conjugate_residual (ConjugateResidualState)
  • CoordinatesNormalSystemState not necessary
  • cyclic_proximal_point (CyclicProximalPointState)
  • difference_of_convex_algorithm (DifferenceOfConvexState)
  • difference_of_convex_proximal_point (DifferenceOfConvexProximalState)
  • DouglasRachford (DouglasRachfordState)
  • exact_penalty_method (ExactPenaltyMethodState)
  • Frank_Wolfe_method (FrankWolfeState)
  • gradient_descent (GradientDescentState)
  • gradient_sampling (GradientSamplingState) state is now also exported
  • interior_point_Newton (InteriorPointNewtonState)
  • LanczosState
  • LevenbergMarquardt (LevenbergMarquardtState)
  • LevenbergMarquardtBoxSubsolver not necessary
  • mesh_adaptive_direct_search (MeshAdaptiveDirectSearchState)
  • NelderMead (NelderMeadState)
  • particle_swarm (ParticleSwarmState)
  • primal_dual_semismooth_Newton (PrimalDualSemismoothNewtonState)
  • projected_gradient_method (ProjectedGradientMethodState)
  • proximal_bundle_method (ProximalBundleMethodState)
  • proximal_gradient_method (ProximalGradientMethodState)
  • proximal_point (ProximalPointState)
  • quasi_Newton (QuasiNewtonState)
  • StepsizeState not necessary, mainly serves as an interims storage.
  • stochastic_gradient_descent (StochasticGradientDescentState)
  • subgradient_method (SubGradientMethodState)
  • truncated_conjugate_gradient_descent (TruncatedConjugateGradientState)
  • trust_regions (TrustRegionsState)
  • vectorbundle_newton (VectorBundleNewtonState)

In the end

  • remove the warning in get_callbacks once all states have that implemented, cf.
    @warn """
    This is a safety fallback! Upon initialization/setup, reaching this means your callback(s)
    are not stored in the state of type $(typeof(state).name).
    Reaching this during a solver run, means your callbacks will not be called
    """
    – then this PR is even nonbreaking, since this accessor has a “default empty return”

kellertuer and others added 26 commits July 4, 2026 16:47
…e (interfaces / developer guide / design concepts) – and start rambling about Callbacks.
…ural (debugs.jl), base ones with singular (e.g. debug.jl)

...refactor debug and action into these two parts.
@kellertuer kellertuer linked an issue Jul 10, 2026 that may be closed by this pull request
…ding a struct field refactor compared to 29 with.
...also fix the outdated docs of TR where an outdated subsolver was specified still.
@kellertuer

Copy link
Copy Markdown
Member Author

If this is not so urgent, then I can continue a bit refactoring the docs; I can also do that on a next PR though.

Besides looking at the changes once more, we should also properly deprecate the callback= keyword in the decoration of a state (and test the warning instead of showing one in the tests) – and deprecate the DebugCallback action.

@kellertuer kellertuer changed the title [WIP] Add callbacks and a developer guide section Add callbacks to all solver states and interfaces, and start a developer guide section Jul 15, 2026
@mateuszbaran

Copy link
Copy Markdown
Member

I've added a small tutorial for callbacks, fixed coverage regression, and fixed one bug I've encountered while fixing the regression (HZ status summary not working right). provided_callbacks maybe should be exported now?

@kellertuer

Copy link
Copy Markdown
Member Author

I think we can postpone further rework on the docs a bit and merge this.

Reworking the docs will also require a bit of moving function definitions around – I want to get rid of the plan/ folder basically, but that should maybe not delay this PR.

@kellertuer kellertuer added the Ready-for-Review A label for pull requests that are feature-ready label Jul 16, 2026
Comment thread tutorials/HowToCallback.qmd Outdated

@mateuszbaran mateuszbaran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I think this looks good now (up to that one character 🙂 )

Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
@kellertuer

Copy link
Copy Markdown
Member Author

Nice. I am just leaving right now, but I could bump version and such tomorrow morning and then merge and register.

@kellertuer
kellertuer merged commit beb713f into master Jul 17, 2026
16 checks passed
@kellertuer
kellertuer deleted the kellertuer/Callbacks branch July 22, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready-for-Review A label for pull requests that are feature-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Callback in all states

2 participants