Skip to content

Commit ae83e18

Browse files
Transurgeonclaude
andauthored
Make is_linearizable_convex/is_linearizable_concave abstract on Expre… (#153)
* Make is_linearizable_convex/is_linearizable_concave abstract on Expression Enforce implementation in all Expression subclasses by uncommenting @abc.abstractmethod decorators. Add missing implementations to indicator (convex, not concave) and PartialProblem (delegates to is_convex/is_concave). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * remove is_smooth from max --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6ea1333 commit ae83e18

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

cvxpy/atoms/max.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ def is_atom_log_log_concave(self) -> bool:
114114
"""
115115
return False
116116

117-
def is_smooth(self):
118-
"""max is not a smooth function of its args"""
119-
return False
120-
121117
def is_incr(self, idx) -> bool:
122118
"""Is the composition non-decreasing in argument idx?
123119
"""

cvxpy/expressions/expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ def is_concave(self) -> bool:
348348
"""
349349
raise NotImplementedError()
350350

351-
#@abc.abstractmethod
351+
@abc.abstractmethod
352352
def is_linearizable_convex(self) -> bool:
353353
"""Is the expression convex after linearizing all smooth subexpressions?
354354
"""
355355
raise NotImplementedError()
356356

357-
#@abc.abstractmethod
357+
@abc.abstractmethod
358358
def is_linearizable_concave(self) -> bool:
359359
"""Is the expression concave after linearizing all smooth subexpressions?
360360
"""

cvxpy/transforms/indicator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ def is_concave(self) -> bool:
5757
"""
5858
return False
5959

60+
def is_linearizable_convex(self) -> bool:
61+
return True
62+
63+
def is_linearizable_concave(self) -> bool:
64+
return False
65+
6066
def is_log_log_convex(self) -> bool:
6167
return False
6268

cvxpy/transforms/partial_optimize.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ def is_concave(self) -> bool:
144144
return self.args[0].is_dcp() and \
145145
type(self.args[0].objective) == Maximize
146146

147+
def is_linearizable_convex(self) -> bool:
148+
return self.is_convex()
149+
150+
def is_linearizable_concave(self) -> bool:
151+
return self.is_concave()
152+
147153
def is_dpp(self, context: str = 'dcp') -> bool:
148154
"""The expression is a disciplined parameterized expression.
149155
"""

0 commit comments

Comments
 (0)