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

Compute (degree bounded) minimal model of cdga's #27045

Closed
miguelmarco opened this issue Jan 11, 2019 · 66 comments
Closed

Compute (degree bounded) minimal model of cdga's #27045

miguelmarco opened this issue Jan 11, 2019 · 66 comments

Comments

@miguelmarco
Copy link
Contributor

This ticket compute the i-minimal model of a cdg-algebra.

It also implements the cohomology algebra up to a given degree.

CC: @jhpalmieri @tscrim

Component: algebra

Author: Miguel Marco, Victor Manero

Branch: 612cfb3

Reviewer: Travis Scrimshaw

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

@miguelmarco miguelmarco added this to the sage-8.6 milestone Jan 11, 2019
@miguelmarco
Copy link
Contributor Author

@miguelmarco
Copy link
Contributor Author

New commits:

25cbd8bImproved cohomology_generators to give only a minimal set of generators
5b53d66Added `_im_gens_` method for NCPolynomial_plural
81cb6d5Implement minimal model of cdga's

@miguelmarco
Copy link
Contributor Author

Commit: 81cb6d5

@embray
Copy link
Contributor

embray commented Jan 15, 2019

comment:3

Retarging tickets optimistically to the next milestone. If you are responsible for this ticket (either its reporter or owner) and don't believe you are likely to complete this ticket before the next release (8.7) please retarget this ticket's milestone to sage-pending or sage-wishlist.

@embray embray modified the milestones: sage-8.6, sage-8.7 Jan 15, 2019
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 22, 2019

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

bbab0baSimplify variable names

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 22, 2019

Changed commit from 81cb6d5 to bbab0ba

@jhpalmieri
Copy link
Member

comment:6

I don't know how close this is to review, but this version of cohomology_generators is much slower than the old one.

Old one:

sage: A3.<a,x,y> = GradedCommutativeAlgebra(GF(3), degrees=(1,2,2))
sage: B3 = A3.cdg_algebra(differential={y: a*x})
sage: %timeit B3.cohomology_generators(30)
1 loop, best of 3: 187 ms per loop
sage: A.<a,x,y> = GradedCommutativeAlgebra(QQ, degrees=(1,2,2))
sage: B = A.cdg_algebra(differential={y: a*x})
sage: %timeit B.cohomology_generators(40)
1 loop, best of 3: 553 ms per loop

New one:

sage: A3.<a,x,y> = GradedCommutativeAlgebra(GF(3), degrees=(1,2,2))
sage: B3 = A3.cdg_algebra(differential={y: a*x})
sage: %timeit B3.cohomology_generators(30)
1 loop, best of 3: 2.3 s per loop
sage: A.<a,x,y> = GradedCommutativeAlgebra(QQ, degrees=(1,2,2))
sage: B = A.cdg_algebra(differential={y: a*x})
sage: %timeit B.cohomology_generators(40)
1 loop, best of 3: 6.32 s per loop

@miguelmarco
Copy link
Contributor Author

comment:7

I am still working on it (I plan to add too the computation of the cohomology algebra, and maybe a test for formality, although I have to consider if that should go on the same ticket or not).

I didn't notice such a big difference in the timimgs, but maybe that is because I only tested up to relitvely low degrees. Anyways, I don't think it would make sense to keep the old implementation since it doesn't grant to give the right answer (in the sense of not giving a minimal set of generators). I will try to think of another aproach that still grants to give a minimal set of generators, but doesn't get so slow.

BTW, if you would like to review this, I could try to get it to the "needs review" point today or tomorrow, and leave the rest of the work for other tickets.

@jhpalmieri
Copy link
Member

comment:8

If the new version gives different answers from the old one, you should add some doctests to demonstrate this, and in particular the advantages of the new one.

Don't hurry this on my account; it is not always predictable when I will have time to review a ticket.

@tscrim
Copy link
Collaborator

tscrim commented Jan 23, 2019

comment:9

Another option (and my preference) would be to have an algorithm option since they give different results (with different speeds).

I can try to review this when it is ready.

@miguelmarco
Copy link
Contributor Author

comment:10

My point is that the previous method gave an answer that is "wrong", in the sense of giving a generating system that has redundant elements. If one wants just a generating system, one can use all the cohomology classes up to the given degree. So it only makes sense to provide a specific method to compute a reduced system if it is indeed minimal. Hence the change.

I will add a doctest with an example where the given answer is different from the previous method.

@miguelmarco
Copy link
Contributor Author

comment:11

In particular, with the old method:

sage: A.<e1,e2,e3,e4> = GradedCommutativeAlgebra(QQ)
sage: d = A.differential({e1:e4*e3,e2:e4*e3})
sage: B = A.cdg_algebra(d)
sage: B.cohomology_generators(10)
{1: [e4, e3, -e1 + e2], 2: [e2*e4, e2*e3, e1*e4, e1*e3]}

whereas with the new:

sage: A.<e1,e2,e3,e4> = GradedCommutativeAlgebra(QQ)
sage: d = A.differential({e1:e4*e3,e2:e4*e3})
sage: B = A.cdg_algebra(d)
sage: B.cohomology_generators(10)
{1: [e4, e3, -e1 + e2], 2: [e2*e4, e2*e3]}

Note that e1*e4 = -e4*(-e1+e2) + e2*e4

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 23, 2019

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

f29f168Minor comment fix
270b5d3Add doctest for cohomology_generators

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 23, 2019

Changed commit from bbab0ba to 270b5d3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 24, 2019

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

a6db43cMinor fix to generator subindices

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 24, 2019

Changed commit from 270b5d3 to a6db43c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 9, 2019

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

713fca7Some optimizations

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 9, 2019

Changed commit from a6db43c to 713fca7

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 14, 2019

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

4d2d95fAdded `_im_gens_` method for NCPolynomial_plural
a51cf9dImplement minimal model of cdga's
f2e748dMerge branch 't/27045/compute__degree_bounded__minimal_model_of_cdga_s' into minimalmodel
3534f8bAdd method to compute the cohomology algebra
3ff9b4cSwitch from incorrect elimination based method to a linear algebra based for cohomology algebra
8ca775aTreat case where cohomology algebra is trivial
3a8660dAdd doctest for cohomology_generators
464771fMinor fix to generator subindices
256b491Merge branch 'minimalmodel' into t/27045/compute__degree_bounded__minimal_model_of_cdga_s
e6c7655Add method to check formality

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 14, 2019

Changed commit from 713fca7 to e6c7655

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2019

Changed commit from e6c7655 to 5a25d5e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2019

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

7ba5d05Cache minimal models to speed up computations
f55f993Fast check for formality in trivial case
5a25d5eAdd doctest for fast formality check

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 22, 2019

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

af07efbAdapt search through dict keys to python3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 22, 2019

Changed commit from 5a25d5e to af07efb

@miguelmarco
Copy link
Contributor Author

comment:30

Wouldn't the testing framework complain if the expected output differs from the actual one by some line breaks?

@miguelmarco
Copy link
Contributor Author

comment:31

Can you please take a nother look? I think it is pretty much ready.

@tscrim
Copy link
Collaborator

tscrim commented May 6, 2019

comment:32

Docbuild errors noted on the patchbot as per comment:29:

         - ``i`` -- integer (default: `3`); degree to which the result is
-        required to induce an isomorphism in cohomology, and the domain is
-        required to be minimal.
+          required to induce an isomorphism in cohomology, and the domain is
+          required to be minimal

and similar.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 6, 2019

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

3d67c5eFix documentation formatting

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 6, 2019

Changed commit from 7b65e36 to 3d67c5e

@miguelmarco
Copy link
Contributor Author

comment:34

I think I addressed the complains in the patchbot.


New commits:

3d67c5eFix documentation formatting

@tscrim
Copy link
Collaborator

tscrim commented May 7, 2019

comment:35

So the patchbots are reporting failures:

sage -t --long src/sage/rings/polynomial/multi_polynomial_ideal.py  # 6 doctests failed

The 3 main ones seem like they are trivial failures and just need to be updated. Two of the other failures I cannot reproduce, but could always just be marked by # random if they are an issue. The last one I cannot reproduce either, but is coming from the fact that toy:buchberger does not return a reduced Gröbner basis (and so is construction order dependent). I suspect these were just brittle tests beforehand.

@miguelmarco
Copy link
Contributor Author

comment:36

Hmmm, that's strange: I get an error message when testing myself:

sage -t  src/sage/rings/polynomial/multi_polynomial_ideal.py

...

**********************************************************************
File "src/sage/rings/polynomial/multi_polynomial_ideal.py", line 2947, in sage.rings.polynomial.multi_polynomial_ideal.NCPolynomialIdeal.elimination_ideal
Failed example:
    I.elimination_ideal([x, z])
Exception raised:
    Traceback (most recent call last):
      File "/home/mmarco/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 671, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/mmarco/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 1095, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.rings.polynomial.multi_polynomial_ideal.NCPolynomialIdeal.elimination_ideal[4]>", line 1, in <module>
        I.elimination_ideal([x, z])
      File "/home/mmarco/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 2024, in elimination_ideal
        return self._elimination_ideal_libsingular(variables)
      File "/home/mmarco/sage/local/lib/python2.7/site-packages/sage/libs/singular/standard_options.py", line 140, in wrapper
        return func(*args, **kwds)
      File "/home/mmarco/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 2051, in _elimination_ideal_libsingular
        Is = MPolynomialIdeal(R,self.groebner_basis())
      File "sage/structure/element.pyx", line 489, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4611)
        return self.getattr_from_category(name)
      File "sage/structure/element.pyx", line 502, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4720)
        return getattr_from_other_class(self, cls, name)
      File "sage/cpython/getattr.pyx", line 394, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2607)
        raise AttributeError(dummy_error_message)
    AttributeError: 'NCPolynomialIdeal' object has no attribute 'groebner_basis'
**********************************************************************

But when I run that code inside an interactive session, it works as expected.

I wonder if some of the errors come from the fact that i am developping on a python 3 environment. Seems plausible, since most are due to orderings of the answers in dictionaries.

@tscrim
Copy link
Collaborator

tscrim commented May 7, 2019

comment:37

Hmm...I didn't think about testing it on Python3. Frédéric (and likely John as well) will be happy that this works on both versions. I cannot say why it doesn't work by using the doctest runner but is fine in an interactive session. Maybe something is being cached or getting put in the "wrong" order in some set/dict. I can probably look into this more tomorrow.

@miguelmarco
Copy link
Contributor Author

comment:38

Ok, if that is a big touble, we could remove the elimination_ideal method (it is not needed in the final implementation of cohomology_algebra, but it is probably good to have it anyways).

@tscrim
Copy link
Collaborator

tscrim commented May 8, 2019

comment:39

With Python3, I am getting the other 3 failures reported by the patchbot. So we can ignore those (I am guessing that is a Python3-based patchbot).

I still have no idea about the failure on your doctest run. Which version of Sage are you using to develop this?

I think we should either update the output to match (for the failing tests in elimination_ideal(), and I get the same output on both Python versions) or we just put nc-relations: {...} for them.

@miguelmarco
Copy link
Contributor Author

comment:40

Maybe I had something outdated on my sage install. After doing a full rebuild, I get no errors at all.

About the ordering issues in python 3, that is a common problen for all doctests that involve dictionaries... ¿what is the general policy about that?

@tscrim
Copy link
Collaborator

tscrim commented May 8, 2019

comment:41

It depends on what the issue is. In this case, it seems the added tests do not differ from Python2 and Python3 (at least on my machine), and from looking at the code, it is fed off to the SagePrettyPrinter, so it should be consistent (if it is not, then there is a bug further down). So I think just updating the doctest output is all we need to do.

@miguelmarco
Copy link
Contributor Author

comment:42

So, just to clarify: you also get errors in a python2 build?

After fully compiling a sage-python2 environment, I get no errors at all.

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2019

comment:43

Yes, that is correct. I get the same 3 errors about output order in multi_polynomial_ideal.py.

@miguelmarco
Copy link
Contributor Author

comment:44

That is strange, I get the same result as the doctests. Have you rebased to the last development version? Or mayb there is something machine dependent there?

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2019

comment:45

I am using 8.4.beta4, so then there is a machine dependency, which is really bad.

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2019

comment:46

Well, we can sidestep this problem by what I suggested in commnet:39 (as the nc-relations are not important for the doctest).

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 9, 2019

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

612cfb3Hide nc relations ordering in doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 9, 2019

Changed commit from 3d67c5e to 612cfb3

@miguelmarco
Copy link
Contributor Author

comment:48

If that is the only discrepancy, then I agree that is the best we can do right now. Maybe when we do the final switch to python 3 these glitches will stabilize, and get more predictable doctests.


New commits:

612cfb3Hide nc relations ordering in doctest

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2019

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2019

comment:49

I wish I did have a better understanding why it is not stable even across our machines, but this will do for now. Lo mira bien a mi.

@vbraun
Copy link
Member

vbraun commented May 14, 2019

@miguelmarco
Copy link
Contributor Author

Changed author from Miguel Marco to Miguel Marco, Victor Manero

@miguelmarco
Copy link
Contributor Author

Changed commit from 612cfb3 to none

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