python-constraint / python-constraint

Constraint Solving Problem resolver for Python
BSD 2-Clause "Simplified" License
440 stars 64 forks source link

Enable speedup somehow (maybe multi-threaded/multi-core?) #23

Open nmz787 opened 8 years ago

nmz787 commented 8 years ago

In my test use-case, I find setting up the problem takes very very long. I guess I have a lot of variables and/or constraints... what I mean by 'setting up takes very very long' is that I am using all FunctionConstraint objects, and I set a break-point in my IDE debugger inside one of those functions. I can wait a very long time in the debugger (debugger is normally much slower than not debugging) and pause the execution... and I generally find the point where I paused was in the library-method forwardCheck. I haven't looked into the library code at all, because I am testing non-Python SAT solvers... but if these prove not viable, I really would like to use python-constraint because the ability to use the FunctionConstraint makes things VERY intuitive. Thanks, let me know how I can help.

s-celles commented 8 years ago

I'm just the guy who packaged in an more recent way python-constraint, add unit tests, continuous integration, Python 3 support, code coverage...

but I'm not sure I can help on this.

Maybe @niemeyer can ?

Anyway any PR that can improve speed should be accepted if it doesn't break unit tests.

A first step could be to provide a quite long problem to solve (around 1 minute) and add nose-timer https://github.com/mahmoudimus/nose-timer (or other solution like vbench http://pydata.github.io/vbench/ or airspeed velocity (asv) https://github.com/spacetelescope/asv ) so we will be able to measure performance improvements

YLTsai0609 commented 5 years ago

Any progress now? I also used this package to do my works. Due to the nice constraint class and understandable solver class( show the method like backtracking, forward tracking, and mrv herustic) Or any suggestion to other package which is flexible to build up my own package? @scls19fr many thanks!

s-celles commented 5 years ago

For numerical intensive calculations, maybe Python is not the best tool... (especially as we are not using cython, numba...)

An other approach could be to create and or use such a CSP solver written using language such as Go or Julia

Go have https://developers.google.com/optimization/cp/ and https://github.com/crillab/gophersat

Julia have http://www.juliaopt.org/ (it may be worth to ask questions at https://discourse.julialang.org/c/domain/opt )