-
Notifications
You must be signed in to change notification settings - Fork 3
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
multiple solutions #70
Comments
The answer is that currently, the library only returns the first solution. The C code could probably be adapted reasonably easily to return all solutions. but I haven't done it yet. you are right that this should be made clear in the readme |
@parmentelat I am planning to add the functionality to this package, is there any chance that you would be interested in participating in this effort? I believe I am able to carry out this work but any level of help would be really appreciated - testing the new version against reasonably large problems is a good example of something that would be very helpful. Also tagging @johnrudge in case he would like to be involved. |
yes sure I can contribute, in the form of tests for sure, and maybe more even if my C is a little rusty ;) |
may I suggest that you call the new wip function |
Yes, you are right, this would be better |
hi there which is 20-60 times slower than this C one - that was expected - but that returns all solutions as a generator, which can be more flexible when tackling large problems for the tests/ area I have mimicked and extended the contributions that I made in the present repo, it is maybe something where we could cooperate; in particular I might be recording there all the solutions to the pentominoes-derived problems (chessboard with an additional 2x2, and 5x12, for starters) still for the record, I had toyed with the idea of going for Rust instead, but could not find a decent way to expose a generator, which was my primary goal, hence the choice of Python |
Thanks for this.
I think it would be a great idea to pool testing resources - although I'm
not yet sure of the best way of doing this. Perhaps there should be a pypi
package with test cases which would be a dev-only dependency of both
packages?
I see there as being at least two types of test cases: those where we want
to check a (possibly complex) set of solutions, and those where we just
want to make sure the solver does not crash or cause an exception. The
latter could include various edge cases like problems with only one row,
very large number of solutions, etc. The former would require at least some
code which deals with differences in how the solutions are produced, for
example the same solutions in a different order.
I haven't had time to work on this recently, but I probably can put
together a hacky version of get_all_solutions which works, but which might
be 2 times slower then it could be. This still might be interesting to you
if your next best alternative is 20 times slower?
Are you interested in using a generator because you want to reduce use of
RAM by processing some solutions before you generate the next ones? I
haven't checked that exact-cover performs correctly in this way, but it is
definitely something I will try and add.
…On Wed, 10 Jan 2024, 09:11 parmentelat, ***@***.***> wrote:
hi there
for the record, I have been toying with this algorithm too and wrote a
pure Python implementation:
https://github.com/parmentelat/exact-cover-py
https://pypi.org/project/exact-cover-py/
which is 20-60 times slower than this C one - that was expected - but that
returns all solutions as a generator, which can be more flexible when
tackling large problems
for the tests/ area I have mimicked and extended the contributions that I
made in the present repo, it is maybe something where we could cooperate;
in particular I might be recording there all the solutions to the
pentominoes-derived problems (chessboard with an additional 2x2, and 5x12,
for starters)
still for the record, I had toyed with the idea of going for Rust instead,
but could not find a decent way to expose a generator, which was my primary
goal, hence the choice of Python
—
Reply to this email directly, view it on GitHub
<#70 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGTQCGDDUZJB3V4G4ED3KTYNZLNNAVCNFSM6AAAAAA6KATGBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBUGQ2TIOBXGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Maybe you have a good reason why you can't use a C++ implementation in a python package? And therefore an improvement to exact_cover would not be interesting to you. If this is related to any problems building exact_cover, let me know. It might be something fixable, or perhaps you could be helped by adding binary distributions for different systems? Eg we have a package for ARM architecture in a repository for that. |
I was more thinking of sharing a wide enough range of problems and their solutions..
my angle here is purely abstract; the reasons why I have gone for a Python version are, in no particular order :
so as you see, I have taken this as a pretext for playing with this topic, my concerns are purely intellectual and theoretical, and not that much practical... ; typically all this will end as an assignment for some of my students ;-) now if you do implement a get_all_solutions() function, I'll be happy to share my current set of test problems so that we can double check our respective results :-) ps. to answer your other question, I can't remember exactly what I did, but I no longer face any build problem, at least this is workable |
Like @parmentelat , I've had a go at coding up my own exact cover solver from scratch. My efforts are here: |
hi @parmentelat, @johnrudge. Version 1.4.0a1 is now on pypi and has a working implementation of get_all_solutions. The function returns a set of tuples. Any feedback welcome! I will promote the prerelease version to a real version when I've updated the documentation. |
fixed by #78 |
Thanks @jwg4 for adding this to the package. I've had a quick play, and I think it works fine, but at the moment it seems rather slow. On an example I've been playing with (attached above) it runs around 70 times slower than the |
Thanks a lot for taking a look @johnrudge ! I'll look into this example and see if there's a reason it's so slow. I'm also keen to see the details of xcover and how it works. |
@jwg4 if you'll allow it I might add in these samples more of your own inputs (the sudoku-based ones for example). tell me how that sounds sorry but for now these samples are only regular boolean problems with no secondary items nor colors.. I'd like to thank you as well because I was not aware of these developments :) I have learned a lot about numba in the process, which was my main topic of interest; regardless, as of now here's a benchmarking between the 3 libs, as produced by a utility in exact-cover-samples/ |
probably related to #17 and #18:
my understanding from reading the readme, and because
get_exact_cover()
is the only symbol exposed in theexact_cover
package, is that we can only ask for one solutionis that correct, or is there any way we can iterate on them all ?
in any case, the readme might deserve a few words about that imho :)
The text was updated successfully, but these errors were encountered: