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

Polyhedron(backend='number_field') #34479

Closed
mkoeppe opened this issue Sep 2, 2022 · 45 comments
Closed

Polyhedron(backend='number_field') #34479

mkoeppe opened this issue Sep 2, 2022 · 45 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Sep 2, 2022

(from #33752)

We lift the conversion code that sends symbolic and AA elements to a suitable embedded number field and back from the backend normaliz and create a new backend number_field, which just runs backend field on the converted number field elements.

This results in rather general (but slow) polyhedral code for algebraic data in pure Python.

Depends on #34195

CC: @yuan-zhou @kliem @jplab @videlec @tscrim

Component: geometry

Author: Matthias Koeppe, Yuan Zhou

Branch/Commit: c729884

Reviewer: Matthias Koeppe, Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/34479

@mkoeppe mkoeppe added this to the sage-9.7 milestone Sep 2, 2022
@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 2, 2022

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

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

7ff3df5src/sage/geometry/polyhedron/{base,backend}_number_field.py: New, move some code here from backend_normaliz

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

Commit: 7ff3df5

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 2, 2022

Author: Matthias Koeppe, ...

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 2, 2022

Dependencies: #34195

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

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

278b93fsage.geometry: More # optional - sage.rings.number_field
0f12ac2src/sage/geometry/polyhedron/base0.py: Restore lost imports
74bc04bsrc/sage/geometry/polyhedron/base{3,6}.py: Muffle pyflakes warnings about unused imports
7db47e1src/sage/geometry/polyhedron/parent.py: Muffle pyflakes warning
6dd4f07src/sage/geometry/polyhedron/base.py: Remove unused import
1ede214src/sage/geometry/polyhedron/backend_normaliz.py: Add missing imports
341475csrc/sage/geometry/polyhedron/base_ZZ.py: Replace .all import
dd87ab9Merge tag '9.7.rc0' into t/34195/sage_geometry_polyhedron__more___optional___sage_rings_number_field
f12e71cMerge #34195
ffe0fdaFix remaining imports

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

Changed commit from 7ff3df5 to ffe0fda

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

Changed commit from ffe0fda to 4a84278

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

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

4a84278src/sage/geometry/polyhedron/parent.py: Add Polyhedra_number_field

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

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

58218d2src/sage/geometry/polyhedron/backend_number_field.py: Add stubs for methods in which conversion needs to be called

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 2, 2022

Changed commit from 4a84278 to 58218d2

@sheerluck
Copy link
Contributor

comment:10

assert polymake_base_field # to muffle pyflakes breaks polymake tests

My workaround is

     elif backend == 'polymake':
         base_field = base_ring.fraction_field()
         try:
-            from sage.interfaces.polymake import polymake
+            from sage.interfaces.polymake import polymake, PolymakeElement
             polymake_base_field = polymake(base_field)
+            assert isinstance(polymake_base_field, PolymakeElement)  # to muffle pyflakes
         except TypeError:

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 2, 2022

comment:11

Thanks for catching this. This is actually from #34195

@yuan-zhou
Copy link

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 9, 2022

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

805b8b7transform data to number field

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 9, 2022

Changed commit from 58218d2 to 805b8b7

@yuan-zhou
Copy link

Changed author from Matthias Koeppe, ... to Matthias Koeppe, Yuan Zhou

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

comment:15

Probably _compute_nmz_data_lists_and_field should be renamed

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

comment:16
     def _init_from_Vrepresentation(self, vertices, rays, lines,
-                                   minimize=True, verbose=False):
+                                   minimize=True, verbose=False, number_field=None):

Also this new parameter should probably not be called number_field but rather internal_base_ring or something like this.

That we use a number field for the computation is specific to the new subclass Polyhedron_number_field. (Later, another subclass could be using SymbolicValuesRing from #30234.)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

Changed commit from 805b8b7 to ad74e4d

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

New commits:

ad74e4dpolyopes.generalized_polyhedron: Restructure doctests, add backend='number_field' tests

@yuan-zhou
Copy link

comment:19

How about renaming it to _compute_data_lists_and_internal_base_ring?
Replying to Matthias Köppe:

Probably _compute_nmz_data_lists_and_field should be renamed

@yuan-zhou
Copy link

comment:20

Sounds good. I notice that backend_normaliz.py has a similar attribute self._normaliz_field = normaliz_field, which is not always a field. Do we need to change that too?

Replying to Matthias Köppe:

     def _init_from_Vrepresentation(self, vertices, rays, lines,
-                                   minimize=True, verbose=False):
+                                   minimize=True, verbose=False, number_field=None):

Also this new parameter should probably not be called number_field but rather internal_base_ring or something like this.

That we use a number field for the computation is specific to the new subclass Polyhedron_number_field. (Later, another subclass could be using SymbolicValuesRing from #30234.)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

comment:21

Replying to Yuan Zhou:

How about renaming it to _compute_data_lists_and_internal_base_ring?

Sounds good

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

comment:22

Replying to Yuan Zhou:

backend_normaliz.py has a similar attribute self._normaliz_field = normaliz_field, which is not always a field. Do we need to change that too?

Probably a good idea to rename it too

@yuan-zhou
Copy link

@yuan-zhou
Copy link

Changed commit from ad74e4d to 1a9dd70

@yuan-zhou
Copy link

comment:24

Renamed.


New commits:

8380bb1rename _compute_nmz_data_lists_and_field to _compute_data_lists_and_internal_base_ring
6b661a1rename number_field in the output of Polyhedron_base_number_field._compute_data_lists_and_internal_base_ring to internal_base_ring
278f6a7rename variables inside _compute_data_lists_and_internal_base_ring
1a9dd70rename normaliz_field to internal_base_ring

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 9, 2022

Changed commit from 1a9dd70 to 60516e7

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 9, 2022

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

60516e7fix a typo

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

Changed commit from 60516e7 to 3eb2cc3

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

comment:27

This works well


New commits:

3eb2cc3src/sage/geometry/polyhedron: Fix typos, reformat doctests

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 9, 2022

Reviewer: ..., Matthias Koeppe

@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 9, 2022
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 9, 2022

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

bc7aba3src/doc/en/reference/discrete_geometry/index.rst: Add backend_number_field

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 9, 2022

Changed commit from 3eb2cc3 to bc7aba3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 10, 2022

Changed commit from bc7aba3 to c729884

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 10, 2022

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

c729884src/sage/geometry/polyhedron/backend_number_field.py: Fix doc markup

@tscrim
Copy link
Collaborator

tscrim commented Sep 10, 2022

comment:31

I would be happy to mark it as a positive review once the patchbot comes back green. If anyone has any objections before that, please do so.

@tscrim
Copy link
Collaborator

tscrim commented Sep 10, 2022

Changed reviewer from ..., Matthias Koeppe to Matthias Koeppe, Travis Scrimshaw

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 26, 2022

comment:33

All green, Lint failures unrelated.

@vbraun
Copy link
Member

vbraun commented Sep 28, 2022

Changed branch from u/mkoeppe/polyhedron_backend__number_field__ to c729884

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

5 participants