projects
/
linpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update reference examples to match the tutorial
[linpy.git]
/
linpy
/
linexprs.py
diff --git
a/linpy/linexprs.py
b/linpy/linexprs.py
index
d2554a0
..
a0be583
100644
(file)
--- a/
linpy/linexprs.py
+++ b/
linpy/linexprs.py
@@
-247,26
+247,28
@@
class LinExpr:
"""
Test whether two linear expressions are equal.
"""
"""
Test whether two linear expressions are equal.
"""
- if isinstance(other, LinExpr):
- return self._coefficients == other._coefficients and \
- self._constant == other._constant
- return NotImplemented
-
- def __le__(self, other):
- from .polyhedra import Le
- return Le(self, other)
+ return self._coefficients == other._coefficients and \
+ self._constant == other._constant
+ @_polymorphic
def __lt__(self, other):
def __lt__(self, other):
- from .polyhedra import
Lt
- return
Lt(self, other
)
+ from .polyhedra import
Polyhedron
+ return
Polyhedron([], [other - self - 1]
)
+ @_polymorphic
+ def __le__(self, other):
+ from .polyhedra import Polyhedron
+ return Polyhedron([], [other - self])
+
+ @_polymorphic
def __ge__(self, other):
def __ge__(self, other):
- from .polyhedra import
Ge
- return
Ge(self, other
)
+ from .polyhedra import
Polyhedron
+ return
Polyhedron([], [self - other]
)
+ @_polymorphic
def __gt__(self, other):
def __gt__(self, other):
- from .polyhedra import
Gt
- return
Gt(self, other
)
+ from .polyhedra import
Polyhedron
+ return
Polyhedron([], [self - other - 1]
)
def scaleint(self):
"""
def scaleint(self):
"""
@@
-405,7
+407,7
@@
class LinExpr:
@classmethod
def fromsympy(cls, expr):
"""
@classmethod
def fromsympy(cls, expr):
"""
- Create a linear expression from a
symp
y expression. Raise TypeError is
+ Create a linear expression from a
SymP
y expression. Raise TypeError is
the sympy expression is not linear.
"""
import sympy
the sympy expression is not linear.
"""
import sympy
@@
-431,7
+433,7
@@
class LinExpr:
def tosympy(self):
"""
def tosympy(self):
"""
- Convert the linear expression to a
symp
y expression.
+ Convert the linear expression to a
SymP
y expression.
"""
import sympy
expr = 0
"""
import sympy
expr = 0