From: Vivien Maisonneuve Date: Tue, 19 Aug 2014 15:58:12 +0000 (+0200) Subject: Improve comparison methods in LinExpr X-Git-Tag: 1.0~22 X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/commitdiff_plain/75b826058dcbdb53fea2ed5258b59e806b465449?ds=inline;hp=b4bd8f7aa081b9296c6089310d286c3b7359a5cc Improve comparison methods in LinExpr --- diff --git a/linpy/linexprs.py b/linpy/linexprs.py index 961502d..a0be583 100644 --- a/linpy/linexprs.py +++ b/linpy/linexprs.py @@ -247,26 +247,28 @@ class LinExpr: """ 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): - 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): - from .polyhedra import Ge - return Ge(self, other) + from .polyhedra import Polyhedron + return Polyhedron([], [self - other]) + @_polymorphic def __gt__(self, other): - from .polyhedra import Gt - return Gt(self, other) + from .polyhedra import Polyhedron + return Polyhedron([], [self - other - 1]) def scaleint(self): """