Skip to content

Commit 4b8d0f9

Browse files
Transurgeonclaude
andauthored
Pr review quick wins (#143)
* Update diff_engine_core to v0.1.1 (#142) Includes: - Fix Windows build (#41) - Remove Python bindings (moved to DNLP repository) (#40) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * Address PR cvxpy#3108 review: quick fixes - Fix indentation in ipopt_nlpif.py cyipopt.Problem() constructor - Fix typo in problem.py docstring ("value ofro" -> "value of") - Rename Dnlp2Smooth to DNLP2Smooth for consistency with DGP2DCP/DQCP2DCP - Fix pnorm ESR condition: p >= 1 (was p > 1) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 80d36c9 commit 4b8d0f9

7 files changed

Lines changed: 21 additions & 17 deletions

File tree

CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
15
# CVXPY Development Guide
26

37
## Quick Reference
@@ -262,7 +266,7 @@ pytest cvxpy/tests/nlp_tests/
262266

263267
**Reduction chain for DNLP:**
264268
```
265-
Problem → CvxAttr2Constr → Dnlp2Smooth → NLPSolver (IPOPT/Knitro)
269+
Problem → CvxAttr2Constr → DNLP2Smooth → NLPSolver (IPOPT/Knitro)
266270
```
267271

268272
**Key components:**

cvxpy/atoms/pnorm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def is_atom_concave(self) -> bool:
179179
def is_atom_esr(self) -> bool:
180180
"""Is the atom esr?
181181
"""
182-
return self.p > 1
182+
return self.p >= 1
183183

184184
def is_atom_hsr(self) -> bool:
185185
"""Is the atom hsr?

cvxpy/problems/problem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from cvxpy.reductions import InverseData
3838
from cvxpy.reductions.chain import Chain
3939
from cvxpy.reductions.cvx_attr2constr import CvxAttr2Constr
40-
from cvxpy.reductions.dnlp2smooth.dnlp2smooth import Dnlp2Smooth
40+
from cvxpy.reductions.dnlp2smooth.dnlp2smooth import DNLP2Smooth
4141
from cvxpy.reductions.dqcp2dcp import dqcp2dcp
4242
from cvxpy.reductions.eval_params import EvalParams
4343
from cvxpy.reductions.flip_objective import FlipObjective
@@ -1235,7 +1235,7 @@ def _solve(self,
12351235
reductions = [FlipObjective()]
12361236
else:
12371237
reductions = []
1238-
reductions = reductions + [CvxAttr2Constr(reduce_bounds=False), Dnlp2Smooth()]
1238+
reductions = reductions + [CvxAttr2Constr(reduce_bounds=False), DNLP2Smooth()]
12391239
# instantiate based on user provided solver
12401240
# (default to Ipopt)
12411241
if solver is s.IPOPT or solver is None:
@@ -1625,7 +1625,7 @@ def unpack(self, solution) -> None:
16251625
def unpack_results(self, solution, chain: SolvingChain, inverse_data) -> None:
16261626
"""Updates the problem state given the solver results.
16271627
1628-
Updates problem.status, problem.value and value ofro
1628+
Updates problem.status, problem.value and value of
16291629
primal and dual variables.
16301630
16311631
Arguments

cvxpy/reductions/dnlp2smooth/dnlp2smooth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from cvxpy.reductions.inverse_data import InverseData
2525

2626

27-
class Dnlp2Smooth(Canonicalization):
27+
class DNLP2Smooth(Canonicalization):
2828
"""
2929
Reduce a disciplined nonlinear program to an equivalent smooth program
3030

cvxpy/reductions/solvers/nlp_solvers/ipopt_nlpif.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, sol
154154
verbose=verbose, use_hessian=use_hessian)
155155

156156
nlp = cyipopt.Problem(
157-
n=len(data["x0"]),
158-
m=len(data["cl"]),
159-
problem_obj=oracles,
160-
lb=data["lb"],
161-
ub=data["ub"],
162-
cl=data["cl"],
163-
cu=data["cu"],
157+
n=len(data["x0"]),
158+
m=len(data["cl"]),
159+
problem_obj=oracles,
160+
lb=data["lb"],
161+
ub=data["ub"],
162+
cl=data["cl"],
163+
cu=data["cu"],
164164
)
165165
# Set default IPOPT options, but use solver_opts if provided
166166
default_options = {

cvxpy/reductions/solvers/nlp_solvers/nlp_solver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ def __init__(self, problem):
275275
problem : cvxpy.Problem
276276
The CVXPY problem to check derivatives for.
277277
"""
278-
from cvxpy.reductions.dnlp2smooth.dnlp2smooth import Dnlp2Smooth
278+
from cvxpy.reductions.dnlp2smooth.dnlp2smooth import DNLP2Smooth
279279
from cvxpy.reductions.solvers.nlp_solvers.diff_engine import C_problem
280280

281281
self.original_problem = problem
282282

283-
# Apply Dnlp2Smooth to get canonicalized problem
284-
canon = Dnlp2Smooth().apply(problem)
283+
# Apply DNLP2Smooth to get canonicalized problem
284+
canon = DNLP2Smooth().apply(problem)
285285
self.canonicalized_problem = canon[0]
286286

287287
# Construct the C version

diff_engine_core

0 commit comments

Comments
 (0)