-
-
Notifications
You must be signed in to change notification settings - Fork 654
Closed
Milestone
Description
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
.
Depends on #22572
Component: geometry
Keywords: days93, IMA-PolyGeom
Author: Jean-Philippe Labbé
Branch: b1ae583
Reviewer: Moritz Firsching, Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/24837