Update reference examples to match the tutorial
[linpy.git] / linpy / polyhedra.py
index a720b74..bfc7efe 100644 (file)
@@ -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: