Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the output of repr_pretty_Hrepresentation for Polyhedron #24837

Closed
jplab opened this issue Feb 26, 2018 · 37 comments
Closed

Improve the output of repr_pretty_Hrepresentation for Polyhedron #24837

jplab opened this issue Feb 26, 2018 · 37 comments

Comments

@jplab
Copy link

jplab commented Feb 26, 2018

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

CC: @videlec @mo271 @tscrim

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

@jplab jplab added this to the sage-8.2 milestone Feb 26, 2018
@jplab
Copy link
Author

jplab commented Feb 28, 2018

Dependencies: #22572

@jplab
Copy link
Author

jplab commented Feb 28, 2018

comment:1

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


New commits:

7cf1a56first version

@jplab
Copy link
Author

jplab commented Feb 28, 2018

Commit: 7cf1a56

@jplab
Copy link
Author

jplab commented Feb 28, 2018

Branch: u/jipilab/24837

@jplab
Copy link
Author

jplab commented Feb 28, 2018

Author: Jean-Philippe Labbé

@jplab

This comment has been minimized.

@jplab

This comment has been minimized.

@jplab jplab changed the title Improve the output of repr_pretty for Polyhedron Improve the output of repr_pretty_Hrepresentation for Polyhedron Feb 28, 2018
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 6, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

132c27aMerge branch 'develop' into 24837

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 6, 2018

Changed commit from 7cf1a56 to 132c27a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 2, 2018

Changed commit from 132c27a to 3fea478

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 2, 2018

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

231cd56deleted trailing whitespace
f685c64fixed some typos in lectures.rst
7f5e125fixed typos in polyhedra_quickref.rst
bd6c356LateX -> LaTeX in polytope_tikz.rst
b1ce45bSeveral other corrections
d526f70renamed tutorial files
d7896f8Merge branch 'develop' into 22572
597b802Merge branch sage8.2.rc1 into 22572
066c7a5Merge branch tutorial into 24837
3fea478Adapted tutorial

@jplab
Copy link
Author

jplab commented Apr 2, 2018

Changed keywords from days93 to days93, IMA-PolyGeom

@mo271
Copy link
Contributor

mo271 commented Apr 10, 2018

Changed branch from u/jipilab/24837 to u/moritz/24837

@mo271
Copy link
Contributor

mo271 commented Apr 10, 2018

Reviewer: Moritz Firsching

@mo271
Copy link
Contributor

mo271 commented Apr 10, 2018

Changed commit from 3fea478 to f98b24a

@mo271
Copy link
Contributor

mo271 commented Apr 10, 2018

comment:8

There was one doctest failing and a bit whitespace left. Other than that I think this is good to go. Set it on positive review on my behalf if you agree!


New commits:

f98b24afix a doctest and remove trailing whitespace

@jplab
Copy link
Author

jplab commented Apr 10, 2018

comment:9

The last bot test looks good. I'm setting it to positive review.

@vbraun
Copy link
Member

vbraun commented May 6, 2018

comment:11

Merge conflict

@jplab
Copy link
Author

jplab commented Jul 11, 2018

comment:13

Ping!

@tscrim
Copy link
Collaborator

tscrim commented Jul 11, 2018

Changed reviewer from Moritz Firsching to Moritz Firsching, Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Jul 11, 2018

comment:14

Two trivial failures; see patchbot for details:

sage -t --long --warn-long 49.3 src/doc/en/thematic_tutorials/geometry/tips.rst  # 2 doctests failed

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2018

Changed commit from e6ba9cc to 736f60f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

736f60ffixed doctests

@jplab
Copy link
Author

jplab commented Jul 12, 2018

comment:16

Should now work...

@jplab
Copy link
Author

jplab commented Jul 12, 2018

comment:17

There are two pyflakes warnings about the usage of QQ and RDF.

Question: if they are used in doctests, that's not necessary to import them, correct?

If so, I'd just remove them...

@tscrim
Copy link
Collaborator

tscrim commented Jul 12, 2018

comment:18

Replying to @jplab:

There are two pyflakes warnings about the usage of QQ and RDF.

Question: if they are used in doctests, that's not necessary to import them, correct?

If so, I'd just remove them...

Please do. What is imported in a file and what used in doctests, which is the global namespace, are essentially independent. Once you remove them, you can set a positive review on my behalf.

@jplab
Copy link
Author

jplab commented Jul 13, 2018

comment:19

Replying to @tscrim:

Replying to @jplab:

There are two pyflakes warnings about the usage of QQ and RDF.

Question: if they are used in doctests, that's not necessary to import them, correct?

If so, I'd just remove them...

Please do. What is imported in a file and what used in doctests, which is the global namespace, are essentially independent. Once you remove them, you can set a positive review on my behalf.

Sounds good! I just wanted to make sure...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 13, 2018

Changed commit from 736f60f to b1ae583

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 13, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

b1ae583Removed unnecessary import

@jplab
Copy link
Author

jplab commented Jul 13, 2018

comment:21

Done! Thanks for the review!

@videlec
Copy link
Contributor

videlec commented Aug 3, 2018

comment:22

update milestone 8.3 -> 8.4

@videlec videlec modified the milestones: sage-8.3, sage-8.4 Aug 3, 2018
@vbraun
Copy link
Member

vbraun commented Aug 5, 2018

Changed branch from u/jipilab/24837 to b1ae583

@dkrenn
Copy link
Contributor

dkrenn commented Aug 27, 2018

Changed commit from b1ae583 to none

@dkrenn
Copy link
Contributor

dkrenn commented Aug 27, 2018

comment:24

There is a follow-up ticket #26141 concerning the code quality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants