News for hackers. Stuff that matters.
Re:Constraint Programming (2020) by default-kramer on Sunday April 16, 2023 @11:33PM (#35596593)
I'm guessing the library python-constraint is basically just brute-forcing all possible combinations, at least when a regular python function is used as a constraint? Barring some crazy introspection, it would have to, right? And if I'm right, I don't understand why you would use a library rather than just loop over x, y, and z the old-fashioned way.
Re:Constraint Programming (2020) by cjalmeida on Sunday April 16, 2023 @11:54PM (#35596691)
It’s bit smarter than that. There are a couple of tricks to make the search more informed. There are a couple introductory articles to CSP that are more in depth than TFA.
Re:Constraint Programming (2020) by ben-schaaf on Sunday April 16, 2023 @11:56PM (#35596700)
From the docs it's using proper backtracking solvers. It doesn't need introspection to do this, just a python object that "records" its operations, eg:

    def __mul__(self, other):
        return Multiplication(self, other)
Re:Constraint Programming (2020) by default-kramer on Monday April 17, 2023 @05:45PM (#35607047)
Cool trick! I don't know enough Python to have thought of this myself.
Re:Constraint Programming (2020) by Avshalom on Monday April 17, 2023 @05:09AM (#35598366)
Aside from the solver being a little smarter. Just syntactically, it might be fine with x,y,z but brute force looping over a,b,c,d...w,x,y,z is gonna take a really really wide monitor.