X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/b4bd8f7aa081b9296c6089310d286c3b7359a5cc..a16251fd5fb481e97f05fd488ad718ba2147396b:/linpy/polyhedra.py diff --git a/linpy/polyhedra.py b/linpy/polyhedra.py index a720b74..bfc7efe 100644 --- a/linpy/polyhedra.py +++ b/linpy/polyhedra.py @@ -281,9 +281,33 @@ class Polyhedron(Domain): def __repr__(self): strings = [] for equality in self.equalities: - strings.append('Eq({}, 0)'.format(equality)) + left, right, swap = 0, 0, False + for i, (symbol, coefficient) in enumerate(equality.coefficients()): + if coefficient > 0: + left += coefficient * symbol + else: + right -= coefficient * symbol + if i == 0: + swap = True + if equality.constant > 0: + left += equality.constant + else: + right -= equality.constant + if swap: + left, right = right, left + strings.append('{} == {}'.format(left, right)) for inequality in self.inequalities: - strings.append('Ge({}, 0)'.format(inequality)) + left, right = 0, 0 + for symbol, coefficient in inequality.coefficients(): + if coefficient < 0: + left -= coefficient * symbol + else: + right += coefficient * symbol + if inequality.constant < 0: + left -= inequality.constant + else: + right += inequality.constant + strings.append('{} <= {}'.format(left, right)) if len(strings) == 1: return strings[0] else: