Repository navigation
More robust termination for active set solver - #4
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 newActiveSetMinimiserwrapper. - 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 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the
active_setoptimizer insrc/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:
KKT Termination and Projected Gradient Norm:
gnorm_projtoActiveSetStateto 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:
_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:
_rescale_adam_statefunction to better handle optax chains by supporting both tuples and lists, and clarified its docstring.max_constraints_to_releaseand improved the initialization logic for offsets and scales. [1] [2]Dependency and Import Management:
optimistixandoptax._src.linesearchto support optimizer functionality. [1] [2]