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

Reimplement IntegerLists using Polyhedron.integral_points() #17920

Open
jdemeyer opened this issue Mar 9, 2015 · 93 comments
Open

Reimplement IntegerLists using Polyhedron.integral_points() #17920

jdemeyer opened this issue Mar 9, 2015 · 93 comments

Comments

@jdemeyer
Copy link

jdemeyer commented Mar 9, 2015

This fixes #17548.

It also adds new features to IntegerLists:

  1. Negative integers are allowed (but the default still is min_part=0).

  2. There does not need to be a fixed sum, one can do for example IntegerLists(max_part=2) for all lists of integers <= 2. One can also give a lower/upper bound for the sum.

Note that the current implementation requires, for a given length, that there are only finitely many lists of that length. This limitation could be lifted in the future.

Depends on #17937
Depends on #18087

CC: @nathanncohen @anneschilling @tscrim @nthiery

Component: combinatorics

Author: Jeroen Demeyer

Branch/Commit: u/jdemeyer/ticket/17920 @ 621d467

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

@jdemeyer jdemeyer added this to the sage-6.6 milestone Mar 9, 2015
@jdemeyer
Copy link
Author

jdemeyer commented Mar 9, 2015

comment:2

The Sage MILP solvers cannot enumerate all solutions => closing as invalid.

@jdemeyer jdemeyer removed this from the sage-6.6 milestone Mar 9, 2015
@jdemeyer jdemeyer closed this as completed Mar 9, 2015
@jdemeyer jdemeyer changed the title Reimplement IntegerLists using MILP Reimplement IntegerLists using Polyhedron.integral_points() Mar 10, 2015
@jdemeyer jdemeyer added this to the sage-6.6 milestone Mar 10, 2015
@jdemeyer jdemeyer reopened this Mar 10, 2015
@jdemeyer
Copy link
Author

Branch: u/jdemeyer/ticket/17920

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Mar 12, 2015

Commit: 492696f

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Mar 12, 2015

comment:5

I do not understand what this is... Did you copy/paste the original file? It seems that you copy/pasted the original files and made some modifications to it O_o

Nathann


New commits:

492696fReimplement IntegerLists using Polyhedron.integral_points()

@jdemeyer
Copy link
Author

comment:6

Yes, that's what I did. Anyway, this is still very much work in progress...

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Mar 12, 2015

comment:7

Yes, that's what I did. Anyway, this is still very much work in progress...

Oh, okay!

Nathann

@jdemeyer
Copy link
Author

Dependencies: #17937

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 12, 2015

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

eb6ba85Fix integral_points() for polyhedra in 0 dimensions
5896b11Reimplement IntegerLists using Polyhedron.integral_points()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 12, 2015

Changed commit from 492696f to 5896b11

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 13, 2015

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

c835117Reimplement IntegerLists using Polyhedron.integral_points()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 13, 2015

Changed commit from 5896b11 to c835117

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 14, 2015

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

755b67aReimplement IntegerLists using Polyhedron.integral_points()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 14, 2015

Changed commit from c835117 to 755b67a

@jdemeyer
Copy link
Author

comment:12

This now seems to work reasonably well. Not yet ready, but good enough for example to compare with the existing implementation. That's how I found all the bugs at #17548.

Due to the polyhedra overhead, it is generally (a lot) slower than the existing code.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Mar 14, 2015

comment:13

Replying to @jdemeyer:

This now seems to work reasonably well. Not yet ready, but good enough for example to compare with the existing implementation. That's how I found all the bugs at #17548.

Due to the polyhedra overhead, it is generally (a lot) slower than the existing code.

Is it worth changing this branch so that it changes the existing code instead of adding a new file ? As you said: let's be correct first, then fast.

Nathann

@jdemeyer
Copy link
Author

comment:14

My code does not yet support all (undocumented!) features of the old IntegerListsLex, so we cannot yet replace IntegerListsLex.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 14, 2015

Changed commit from 755b67a to 674a518

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 14, 2015

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

674a518Reimplement IntegerLists using Polyhedron.integral_points()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 14, 2015

Changed commit from 674a518 to 4e5dbae

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 14, 2015

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

4e5dbaeReimplement IntegerLists using Polyhedron.integral_points()

@jdemeyer
Copy link
Author

comment:17

This now implements Compositions using my new IntegerListsLex (is the lex ordering really important? I guess not, it's for sure nowhere documented). However, doing the same for Partitions leads to all kinds of breakage and I don't understand why.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 25, 2015

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

62b56baImprove IntegerLists_polyhedron; sort Partitions by default

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 25, 2015

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

5096e5fFix documentation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 25, 2015

Changed commit from 62b56ba to 5096e5f

@jdemeyer
Copy link
Author

jdemeyer commented Apr 5, 2015

Changed dependencies from #17937 to #17937, #18087

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 5, 2015

Changed commit from 5096e5f to 621d467

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 5, 2015

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

c9dce18Remove sig_on() from __dealloc__
621d467Merge commit 'c9dce18385fd59755cbcced5f1804bf60b19df07' into t/17920/ticket/17920

@vbraun
Copy link
Member

vbraun commented Apr 12, 2015

comment:73

Whats your plan with the code here? It might be useful to check. Thoughts?

@tscrim
Copy link
Collaborator

tscrim commented Apr 12, 2015

comment:74

This code is useful as it works in more general context than the new IntegerListsLex as it allows entries in ZZ (instead of just NN) and when lex ordering doesn't hit every element in finite time. Plus I like alternative algorithms for testing, and this is faster in certain cases currently as well. I just need to find some time to review this.

@nthiery
Copy link
Contributor

nthiery commented Apr 12, 2015

comment:75

Indeed, we want this code in Sage! I promised Jeroen I would rebase his code, and work on the review. This could be a good sprint for Sage Days 67. But yes this certainly is not a blocker anymore for 6.6.

@jdemeyer
Copy link
Author

comment:76

Needs to be rebased in any case. I might also try to make it work in all cases of infinite iterator (currently, I still require that there are only finitely many lists of every given length).

@jdemeyer
Copy link
Author

comment:77

I would actually like to redesign IntegerListsLex and IntegerLists_polyhedron such that they share code: they could be the same class but with a different implementation for __iter__ and __contains__.

@videlec
Copy link
Contributor

videlec commented Apr 13, 2015

comment:78

Replying to @jdemeyer:

I would actually like to redesign IntegerListsLex and IntegerLists_polyhedron such that they share code: they could be the same class but with a different implementation for __iter__ and __contains__.

+1

why not several iterators on the same class? (with a reasonable one by default in __iter__).

@jdemeyer
Copy link
Author

comment:79

Replying to @videlec:

Replying to @jdemeyer:

I would actually like to redesign IntegerListsLex and IntegerLists_polyhedron such that they share code: they could be the same class but with a different implementation for __iter__ and __contains__.

+1

why not several iterators on the same class? (with a reasonable one by default in __iter__).

Well, it will be something along those lines. But I haven't thought too much about the actual design.

@jdemeyer
Copy link
Author

comment:80

Replying to @nthiery:

I promised Jeroen I would rebase his code

Thanks for the offer, but that will not be needed (in any case, it's just merging with -X theirs essentially)

@nthiery
Copy link
Contributor

nthiery commented Apr 13, 2015

comment:81

Replying to @jdemeyer:

Replying to @videlec:

Replying to @jdemeyer:

I would actually like to redesign IntegerListsLex and IntegerLists_polyhedron such that they share code: they could be the same class but with a different implementation for __iter__ and __contains__.

+1

why not several iterators on the same class? (with a reasonable one by default in __iter__).

Well, it will be something along those lines. But I haven't thought too much about the actual design.

+1 to sharing code between the classes; in fact I had put a mental
note on doing this when I offered to do the merge :-)

Having a class that can handle any set of constraints, even if it does
only containment check, would be useful. We would need this in
particular to properly refactor integer vectors.

I am not sure whether we want a single class, or two classes:

class IntegerLists:
    __iter__ -> __iter__ on the polyhedron

class IntegerListsLex(IntegerLists):

With the second one having the additional specification that the
enumeration shall be lexicographic.

Thoughts?

Cheers,
Nicolas

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

10 participants