Skip to content

More robust termination for active set solver - #4

Merged
ASKabalan merged 2 commits into
mainfrom
better-termination
May 27, 2026
Merged

ASKabalan merged 2 commits into
mainfrom
better-termination

Conversation

@ASKabalan

Copy link
Copy Markdown
Member

This pull request refactors and improves the active_set optimizer in src/cadre/active_set.py. The main changes focus on cleaning up comments and docstrings for clarity, improving KKT termination detection, and enhancing documentation and references to recent research. Additionally, some code logic is streamlined, and new features are added for better usability and maintainability.

Documentation, Comments, and References:

  • Cleaned up and clarified comments throughout the code, replacing in-line explanations with more concise or improved docstrings, and adding references to recent research (Kabalan et al. 2025, arXiv:2604.08463) for the AdaTopK active-set release rule and ADABK/AdaTopK active set. [1] [2]

KKT Termination and Projected Gradient Norm:

  • Added a new field gnorm_proj to ActiveSetState to track the physical-space projected gradient norm, which is used for proper KKT (Karush-Kuhn-Tucker) termination detection. The update function now computes both internal and physical-space projected gradient norms, using the latter for termination checks. [1] [2]

Code and Logic Simplification:

  • Removed verbose, redundant, or overly detailed comments from several functions (e.g., _leaf_pivot, _leaf_step, _leaf_add, _tree_top_k, _release_constraints, and step clamping logic), making the code more readable and maintainable without sacrificing clarity. [1] [2] [3] [4] [5]

Robustness and Usability Improvements:

  • Improved the _rescale_adam_state function to better handle optax chains by supporting both tuples and lists, and clarified its docstring.
  • Enhanced the default behavior for max_constraints_to_release and improved the initialization logic for offsets and scales. [1] [2]

Dependency and Import Management:

  • Added missing imports for optimistix and optax._src.linesearch to support optimizer functionality. [1] [2]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the active_set optimizer implementation and its solver wiring, with a focus on more robust KKT-based termination, clearer documentation, and improved test coverage for the ADABK solver family.

Changes:

  • Adds physical-space projected gradient norm tracking (gnorm_proj) and uses it for KKT-style termination via a new ActiveSetMinimiser wrapper.
  • Refactors ADABK solver construction into a dedicated factory (make_adabk_solver) and updates solver selection to use it.
  • Rewrites/expands active-set tests to cover constrained Rosenbrock, early KKT termination on a quadratic, and multi-seed comparisons vs L-BFGS on noisy Rosenbrock.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cadre/active_set.py Adds projected-gradient tracking and new Optimistix wrapper; introduces ADABK solver factory.
src/cadre/solvers.py Switches ADABK solver creation to make_adabk_solver and imports the new wrapper/factory.
src/cadre/minimize.py Removes min_steps from documented options and simplifies solver option forwarding.
tests/test_active_set_solver.py Replaces old direct optax usage with minimize()-based ADABK tests (KKT termination + noisy comparisons).
tests/test_active_set_convergence.py Converts prior script-like comparison into parametrized pytest convergence assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cadre/active_set.py Resolved
Comment thread src/cadre/active_set.py Resolved
Comment thread src/cadre/minimize.py
Comment on lines 278 to +280
_opts = options or {}
cooldown = _opts.get("cooldown", 20)
min_steps = _opts.get("min_steps", 10)
solver_kwargs = {k: v for k, v in _opts.items() if k not in ("cooldown", "min_steps")}
solver_kwargs = {k: v for k, v in _opts.items() if k != "cooldown"}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ASKabalan
ASKabalan merged commit b4a20a4 into main May 27, 2026
@ASKabalan
ASKabalan deleted the better-termination branch May 27, 2026 14:22
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