Opened 4 years ago

# Improve the output of repr_pretty for Polyhedron — at Version 2

Reported by: Owned by: jipilab major sage-8.4 geometry days93, IMA-PolyGeom vdelecroix, moritz, tscrim Jean-Philippe Labbé N/A u/jipilab/24837 7cf1a562e411bb1307b906c173d04f177d66fc0f #22572

Following #22572, we can improve the output of the pretty print:

    sage: Cube = polytopes.cube()
sage: TCube = Cube.truncation()
sage: Nice_repr = TCube.repr_pretty_Hrepresentation(separator='\n')
sage: print(Nice_repr)
1 >= x0
1 >= x1
3*x1 + 7 >= 3*x0 + 3*x2
x0 + 1 >= 0
x1 + 1 >= 0
3*x0 + 7 >= 3*x1 + 3*x2
3*x0 + 3*x1 + 7 >= 3*x2
3*x0 + 3*x2 + 7 >= 3*x1
3*x0 + 3*x1 + 3*x2 + 7 >= 0
x2 + 1 >= 0
1 >= x2
3*x1 + 3*x2 + 7 >= 3*x0
3*x2 + 7 >= 3*x0 + 3*x1
7 >= 3*x0 + 3*x1 + 3*x2


In the new version it gives:

    sage: print(TCube.Hrepresentation_str())
-x0 >= -1
-x1 >= -1
-3*x0 + 3*x1 - 3*x2 >= -7
x0 >= -1
x1 >= -1
3*x0 - 3*x1 - 3*x2 >= -7
3*x0 + 3*x1 - 3*x2 >= -7
3*x0 - 3*x1 + 3*x2 >= -7
3*x0 + 3*x1 + 3*x2 >= -7
x2 >= -1
-x2 >= -1
-3*x0 + 3*x1 + 3*x2 >= -7
-3*x0 - 3*x1 + 3*x2 >= -7
-3*x0 - 3*x1 - 3*x2 >= -7

sage: print(TCube.Hrepresentation_str(latex=True))
\begin{array}{rcl}
-x_{0} & \geq & -1 \\
-x_{1} & \geq & -1 \\
-3 \, x_{0} + 3 \, x_{1} - 3 \, x_{2} & \geq & -7 \\
x_{0} & \geq & -1 \\
x_{1} & \geq & -1 \\
3 \, x_{0} - 3 \, x_{1} - 3 \, x_{2} & \geq & -7 \\
3 \, x_{0} + 3 \, x_{1} - 3 \, x_{2} & \geq & -7 \\
3 \, x_{0} - 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
3 \, x_{0} + 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
x_{2} & \geq & -1 \\
-x_{2} & \geq & -1 \\
-3 \, x_{0} + 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
-3 \, x_{0} - 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
-3 \, x_{0} - 3 \, x_{1} - 3 \, x_{2} & \geq & -7
\end{array}


The style parameter allows to change the way to print the H-relations:

sage: P = polytopes.permutahedron(3)
sage: print(P.Hrepresentation_str(style='<='))
-x0 - x1 - x2 == -6
x1 + x2 <=  5
x2 <=  3
x1 <=  3
-x1 <= -1
-x1 - x2 <= -3
-x2 <= -1
sage: print(P.Hrepresentation_str(style='positive'))
x0 + x1 + x2 == 6
5 >= x1 + x2
3 >= x2
3 >= x1
x1 >= 1
x1 + x2 >= 3
x2 >= 1


In order to make the function more apparent, deprecation of the current function is perhaps a good idea and change the name to Hrepresentation_str.

### comment:1 Changed 4 years ago by jipilab

• Authors set to Jean-Philippe Labbé
• Branch set to u/jipilab/24837
• Commit set to 7cf1a562e411bb1307b906c173d04f177d66fc0f
• Dependencies set to #22572
• Description modified (diff)
• Status changed from new to needs_review

Once the tutorial is merged in #22572, we should change the "tips" page accordingly...

New commits:

 ​7cf1a56 first version

### comment:2 Changed 4 years ago by jipilab

• Description modified (diff)
Note: See TracTickets for help on using tickets.