X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/blobdiff_plain/198c368d0b24dc80b1139b2a7282cc50ef654e4d..ddefc755b0637b08a0a2788be3a0678b52942f5b:/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: