-
Notifications
You must be signed in to change notification settings - Fork 134
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
Implement equality for toric varieties #4509
Conversation
The only computationally complex part is computing the rays of the toric varieties, which are usually already computed anyway.
@paemurru seems to have an increased interest in this feature/functionality. After several discussions more (the last of which I recall did take place before Christmas among @lkastner @paemurru and myself), it was agreed that one could implement such a method - provided interest and time. It seems that @paemurru found both! (Thank you!) |
@paemurru given the failed required test, I assume this is WIP. Please ping me once ready for review. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4509 +/- ##
==========================================
- Coverage 84.55% 84.40% -0.15%
==========================================
Files 672 672
Lines 88833 89139 +306
==========================================
+ Hits 75109 75236 +127
- Misses 13724 13903 +179
|
What is this needed for? |
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
@HereAround Those three test failures are from nightly, those are not required or relevant here! This is not a WIP, that tag can be removed |
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
@joschmitt One thing that changed is that I wrote a fast equality check |
It is not fast, since it still potentially involves double description computation. This is why I am asking for a use case. Because in the long run we will have users using this check and then complain about Oscar being slow. Most of the time this equality check can be avoided by studying the underlying mathematics. For example we were able to avoid a lot of equality checks of polyhedra in the git fans that way. Often one is in the situation where one fan is already refining the other fan, e.g. for blow ups. Adding this operator makes this check convenient and seemingly cheap. It is not. |
Also remove `f_vector`.
All the "famous toric varieties" in the documentation already have rays computed, so this does not involve double description computation for them. For any kind of blowups or refining of fans by adding a ray, again the rays are already computed. Often one works with the Cox ring, so the rays need to be computed. I cannot think of a use case where the rays are not already computed. Would you prefer it if it first checked whether the rays are already computed and if not, it would return an error? |
Should be ready to merge now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot say anything about the concrete implementations. But two comments regarding the docstrings below
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
Is it clear (and maybe checked?) that the polyhedral fans for these varieties are pointed ( |
@benlorenz According to the book of Cox–Little–Schenck, polyhedral fans are pointed. At least according to the documentation, toric geometry in OSCAR follows the book of Cox. I am not sure if this is actually checked in the constructor (it should be!) |
test/AlgebraicGeometry/ToricVarieties/normal_toric_varieties.jl
Outdated
Show resolved
Hide resolved
Co-authored-by: Benjamin Lorenz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't see why exactly this is necessary but the code seems reasonable now. Probably similar to computing Groebner bases when comparing ideals. So I think we can keep it like this.
But it would still be good to add input checks for toric varieties to make sure the fans are pointed, probably in a separate PR. This is not required for general polyhedral fans in Oscar.
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
src/AlgebraicGeometry/ToricVarieties/NormalToricVarieties/constructors.jl
Outdated
Show resolved
Hide resolved
General comment (along our dicussions on slack): The expectation is that the new equality check could be potentially slow in case polymake has not computed the rays of the toric variety. Let us be careful and reflect this in your changes. I see two ways: Option 1: Option 2: "RAYS" in Polymake.list_properties(Oscar.pm_object(polyhedral_fan(v)) In case this returns Note that option 2 requires that you align the hash-function accordingly. In this regard, option 1 is likely easier. So I am leaning towards option 1. But if you prefer option 2, that is also fine with me. Another useful thing - since we are concerned about the performance of the equality (and hash) operation - could be to subject one CI-test to a time requirement. Here is an in-use example testset: @testset "Speed test for Stanley-Reisner ideal (at most a few seconds)" begin
success = false
for i in 1:5
ntv5 = normal_toric_variety(polarize(polyhedron(Polymake.polytope.rand_sphere(5, 60; seed=42))))
stats = @timed stanley_reisner_ideal(ntv5)
duration = stats.time - stats.gctime
if duration < 10
success = true
break
else
@warn "Stanley-Reisner ideal took $duration > 10 seconds (i=$i)"
end
end
@test success == true
ntv5 = normal_toric_variety(polarize(polyhedron(Polymake.polytope.rand_sphere(5, 60; seed=42))))
@test ngens(stanley_reisner_ideal(ntv5)) == 1648
end Presumably, any of the tests for == that you wrote should complete in less than 2 (?) seconds? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments above @paemurru . Please address those, and then this PR should be good to be merged. Thank you!
Also add polymake code to check whether rays are computed into the documentation.
I chose Option 1. The slowness in the case the rays have not been computed is already documented and appears in the documentation. Just in case, also mentioned the polymake code to check for this. About the CI test with a time requirement: this seems a bit overkill to me. It could happen that it spends a lot of time garbage collecting some previous tests or compiling some functions not before used. And besides, this function here is not that important for time-considerations. There are far more important functions in OSCAR in terms of speed-criticality that have no timed tests whatsoever (saturation, smoothness tests, your own FTheoryTools methods). So I am hesitant to add these here. |
Added speed test as @HereAround suggested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @paemurru . Looks good to me!
The only computationally expensive part is computing the rays of the toric varieties, which are usually already computed anyway.