You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
remove redundant nonsmooth methods, add types and docs (#158)
* Address review comments: remove redundant nonsmooth methods, add types, docs
- Remove is_atom_nonsmooth_convex/is_atom_nonsmooth_concave from base Atom
class and 10 atom subclasses; use existing is_atom_convex/is_atom_concave
in DNLP composition rules instead
- Add type annotations and docstrings to NLPsolver, Bounds, and Oracles
in nlp_solver.py
- Document Variable.sample_bounds with class-level type annotation and
docstring
- Revert GENERAL_PROJECTION_TOL back to 1e-10 (was loosened for removed
IPOPT derivative checker)
- Update CLAUDE.md atom classification docs to reflect simplified API
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Move sample_bounds docs from #: comments into Variable class docstring
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,7 +159,7 @@ Adding a new diff engine atom requires:
159
159
160
160
The diff engine supports CVXPY `Parameter` objects: `C_problem` registers parameters with the C engine and `update_params()` re-pushes values without rebuilding the expression tree. Sparse parameter values are fused into sparse matmul operations.
161
161
162
-
`DerivativeChecker` in `nlp_solver.py` provides finite-difference verification of gradients, Jacobians, and Hessians during development.
162
+
`DerivativeChecker` in `cvxpy/tests/nlp_tests/derivative_checker.py` provides finite-difference verification of gradients, Jacobians, and Hessians during development.
163
163
164
164
Key files in `cvxpy/reductions/solvers/nlp_solvers/diff_engine/`:
165
165
-`converters.py` - Converts CVXPY expression AST to C diff engine trees. Contains `ATOM_CONVERTERS` dict mapping ~40 atom types to C constructors. Includes optimizations like sparse parameter matmul fusion.
@@ -182,17 +182,17 @@ Convention: all arrays are flattened in **Fortran order** ('F') for column-major
182
182
1. Create a canonicalizer in `cvxpy/reductions/dnlp2smooth/canonicalizers/`
183
183
2. The canonicalizer converts non-smooth atoms to smooth equivalents using auxiliary variables
184
184
3. Register in `canonicalizers/__init__.py` by adding to `SMOOTH_CANON_METHODS` dict
185
-
4.Classify the atom using the three-way atom-level API (see below)
185
+
4.If the atom is smooth, override `is_atom_smooth()` to return `True`(see classification below)
186
186
187
-
### DNLP Atom Classification (Three-way)
187
+
### DNLP Atom Classification
188
188
189
-
Each atom implements exactly one of three atom-level methods:
189
+
Atoms are classified as smooth or non-smooth. Non-smooth atoms reuse the existing `is_atom_convex()`/`is_atom_concave()`methods for the DNLP composition rules—no separate method is needed.
190
190
191
191
| Category | Method | Examples |
192
192
|---|---|---|
193
193
|**Smooth**|`is_atom_smooth() → True`| exp, log, power, sin, prod, quad_form |
0 commit comments