forked from cvxpy/cvxpy
-
Notifications
You must be signed in to change notification settings - Fork 1
Simplify log/exp verification to check is_affine() and add tests #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Transurgeon
wants to merge
6
commits into
diffengine-setup
Choose a base branch
from
coeffextractor
base: diffengine-setup
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Member
Transurgeon
commented
Jan 20, 2026
- Simplify _verify_hess_vec_args and _verify_jacobian_args in log.py and exp.py to check self.args[0].is_affine() instead of requiring isinstance(Variable)
- Remove _hess_vec methods from both atoms (NLP solver handles derivatives via C diff engine)
- Fix _extract_affine_as_linear_op in converters.py to create column vector (n_vars, 1) instead of row vector for compatibility with C new_linear function
- Add comprehensive test suite for affine argument handling including gradient verification, Hessian structure tests, edge cases, and constraint tests
* Implement diag_vec Jacobian for NLP solving - Add _jacobian() and _hess_vec() methods to diag_vec atom for NLP support - Fix diagonal variable value propagation in CvxAttr2Constr reduction - Add tests for diagonal variables in NLP problems The diag_vec Jacobian maps input vector positions to diagonal matrix positions using the formula i*(n+1) for Fortran-order flattening. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Handle sparse value initialization for diag variables in NLP When a diag variable has its value stored as a sparse matrix (e.g., after solving), np.diag() fails on it. This adds a check for sparse values and uses .diagonal() to extract the diagonal elements correctly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
- Simplify _verify_hess_vec_args and _verify_jacobian_args in log.py and exp.py to check self.args[0].is_affine() instead of requiring isinstance(Variable) - Remove _hess_vec methods from both atoms (NLP solver handles derivatives via C diff engine) - Fix _extract_affine_as_linear_op in converters.py to create column vector (n_vars, 1) instead of row vector for compatibility with C new_linear function - Add comprehensive test suite for affine argument handling including gradient verification, Hessian structure tests, edge cases, and constraint tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Benchmarks that have stayed the same: |
Use is_affine() check instead of isinstance(Variable) so that any affine expression (e.g., 2*x + 3) passes through without creating unnecessary auxiliary variables and equality constraints. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Keep AFFINE_ARG_ATOMS special handling for coefficient extraction while incorporating latest diffengine-setup changes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add diag_vec to ATOM_CONVERTERS for cp.diag(vector) support - Add automatic reshape when linear_op flattens matrix expressions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.