sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.34k stars 452 forks source link

Polyhedron.affine_hull: more output options #27366

Closed dkrenn closed 3 years ago

dkrenn commented 5 years ago

At the moment when calling .affine_hull, either the polyhedron or the affine map can be returned. If both needed, parts need to be recomputed, so we extend the parameters to allow returning both at the same time.

Moreover, we also allow to additionally return the section map, i.e., the right inverse of the projection map. This is a preparation for #27365 and #31659.

Depends on #30551

CC: @jplab @videlec @kliem

Component: geometry

Keywords: polytope

Author: Daniel Krenn, Matthias Koeppe, Jonathan Kliem

Branch/Commit: eee1aad

Reviewer: Matthias Koeppe, Jonathan Kliem

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

dkrenn commented 5 years ago

Branch: u/dkrenn/affine-hull-more

dkrenn commented 5 years ago

Commit: 2075a6b

dkrenn commented 5 years ago

New commits:

1ca3e2cTrac #27329: actually use **kwds as promised in docs
4efdb48Trac #27329: insert 3 whitespaces (PEP8)
74470e2Trac #27329: insert an additional doctest enhancing the readability of
9bedce6Trac #27366: new output parameters for affine_hull
2075a6bTrac #27366: use new parameter-options in .volume
dkrenn commented 5 years ago

Dependencies: #27329

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

e9ed7eeTrac #27366: fixup (lines forgotten to commit in ~2)
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 2075a6b to e9ed7ee

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from e9ed7ee to 0cf6bc5

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

0cf6bc5Trac #27366: docstring fixup
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 0cf6bc5 to 2bbfdc2

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

f8cb228Trac #27366 factor out parametric_form
8fa37dfTrac #27366 use new .parametric_form
294fbe1Trac #27366 output affine_map
6cf71c7Trac #27366 update .volume (to new parameter set)
477923bTrac #27366 compute coordinate images
2bbfdc2Trac #27366: update docs
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

3c09477Trac #27366: fix no-variables-bug-wrong-parent bug
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 2bbfdc2 to 3c09477

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

82ad45bTrac #27366: cache affine hull
3bdea15Trac #27366: reintegrate parametric form and solve dimension bug
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 3c09477 to 3bdea15

embray commented 5 years ago
comment:9

Ticket retargeted after milestone closed (if you don't believe this ticket is appropriate for the Sage 8.8 release please retarget manually)

embray commented 5 years ago
comment:10

Moving tickets from the Sage 8.8 milestone that have been actively worked on in the last six months to the next release milestone (optimistically).

fchapoton commented 5 years ago
comment:11

red branch, needs to be rebased on top of the latest beta

jplab commented 5 years ago

Changed keywords from none to polytope

embray commented 4 years ago
comment:14

Ticket retargeted after milestone closed

mkoeppe commented 4 years ago
comment:15

Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date.

mkoeppe commented 3 years ago
comment:17

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

mkoeppe commented 3 years ago

Changed branch from u/dkrenn/affine-hull-more to u/mkoeppe/affine-hull-more

mkoeppe commented 3 years ago

Changed commit from 3bdea15 to b407987

mkoeppe commented 3 years ago
comment:19

Merged with current develop.


New commits:

b407987Merge tag '9.3.rc2' into t/27366/affine-hull-more
mkoeppe commented 3 years ago
comment:20

Untested so far...

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

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

d25f7f3Fixup merge
7e0f31daffine_hull -> affine_hull_projection in doctests
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from b407987 to 7e0f31d

mkoeppe commented 3 years ago

Changed dependencies from #27329 to none

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

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

58e6dccMerge tag '9.3.rc3' into t/27366/affine-hull-more
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 7e0f31d to 58e6dcc

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

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

8414039Polyhedron_base.affine_hull_projection: Document a weaker guarantee of parametric_form
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 58e6dcc to 8414039

mkoeppe commented 3 years ago
comment:25

I plan to rework this so the output is a bit more straightforward.

We have affine_map, which is the projection that sends the affine hull (k-dimensional affine subspace of Rn) to Rk.

What's missing is simply its section map that sends back Rk to the affine hull.

I think both parametric_form and coordinate_images somehow represent this section map.

As the section map is affine linear, we should represent it in the same way as affine_map: A linear transformation and a shift.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

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

dba2763Polyhedron_base.affine_hull_projection: Replace 'affine_map' by 'projection_map', 'parametric_form'/'coordinate_images' by 'section_map'
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 8414039 to dba2763

mkoeppe commented 3 years ago

Changed author from Daniel Krenn to Daniel Krenn, Matthias Koeppe

mkoeppe commented 3 years ago
comment:27

For the non-orthogonal case, the section_map still needs to be computed.

But comments are already welcome

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from dba2763 to d49c313

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

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

d49c313Polyhedron_base.affine_hull_projection: section map for non-orthogonal case
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from d49c313 to d77181b

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

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

d77181bAdd doctest
mkoeppe commented 3 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,3 @@
 At the moment when calling `.affine_hull`, either the polyhedron or the affine map can be returned. If both needed, parts need to be recomputed, so we extend the parameters to allow returning both at the same time.

-Moreover, we also allow to additionally return some more (internal) data using during creating the affine map. This is a preparation for #27365.
+Moreover, we also allow to additionally return the section map, i.e., the right inverse of the projection map. This is a preparation for #27365 and #31659.
mkoeppe commented 3 years ago
comment:31

Still some issues with algebraic numbers:

sage: D = polytopes.dodecahedron()
sage: D.facets()[0].as_polyhedron().affine_hull_projection()                                                                       
A 2-dimensional polyhedron in (Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?)^2 defined as the convex hull of 5 vertices
sage: D.facets()[0].as_polyhedron().affine_hull_projection(return_all_data=True)  
TypeError: (-sqrt5 + 1, -2*sqrt5 + 4, 0) fails to convert into the map's domain Vector space of dimension 3 over Rational Field, but a `pushforward` method is not properly implemented
kliem commented 3 years ago
comment:32

I have a fix almost ready and added a test method.

However, there is going to be one more ticket in the dependency chain:

sage: D = polytopes.dodecahedron()                                                                                                                                                  
sage: D.change_ring(AA) == D                                                                                                                                                        
False
kliem commented 3 years ago
comment:33

The behavior is actually consistent with rings, I still don't like it.

Looks, like this is related to #4621:

sage: D = polytopes.dodecahedron()                                                                                                                                                  
sage: D.base_ring()                                                                                                                                                                 
Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?
sage: sqrt5 = D.base_ring().gens()[0]                                                                                                                                               
sage: sqrt5 == AA(sqrt5)                                                                                                                                                            
False
sage: 0*sqrt5 == AA(0)                                                                                                                                                              
False

This is extremely stupid. At least it should throw an error instead of giving a false negative. But its pointless to be fixed here.

Edit: I realized that equality checks should never throw an error. So it is really hard to do the right thing here. The base ring of algebraic polyhedra has a specified embedding into RLF, which makes it incomparable with AA.

kliem commented 3 years ago

Changed author from Daniel Krenn, Matthias Koeppe to Daniel Krenn, Matthias Koeppe, Jonathan Kliem

kliem commented 3 years ago
comment:34

Unfortunately, it is still at "needs work".

The test suite fails for polytopes.Birkhoff(3) terribly (the section map has incorrect rank).

It also fails for the 0-dimensional polyhedron, but maybe that is just the way it is.

It fails for unbounded polyhedron, in particular Polyhedron(rays=[[0, 1]]).

kliem commented 3 years ago

New commits:

ab10ce2correct base_rings for projection and section map and test suite method
69ceebcbase extend in test; only run defined tests
kliem commented 3 years ago

Changed branch from u/mkoeppe/affine-hull-more to u/gh-kliem/affine-hull-more

kliem commented 3 years ago

Changed commit from d77181b to 69ceebc