Closed CrashBurnRepeat closed 3 years ago
Hey @CrashBurnRepeat! Yes, I believe this is too large a problem instance to solve without using more specialized search techniques that implement constraint propagation. The standard SLD resolution algorithm doesn't do any of that constraint propagation, so it generally won't be able to solve problems of this size in a reasonable time. (In addition, based on my benchmarks, Julog is still considerably slower than SWI-Prolog, despite my recent performance improvements.) I believe it should still work if you give it a smaller problem to solve though -- maybe just color all the territories / provinces in Canada instead?
Also as a side note, it seems like there's no validity check with the resolve options, and any invalid option choice will just "fail" silently by using the default settings. Am I reading the code correctly for these cases?
Yes, invalid option names currently fail silently -- thanks for noticing. If you could file a separate issue for that, that'd be great!
Note that most modern variants of Prolog actually have support for constraint propagation via specialized libraries. E.g. the 4-color problem would typically be solved with the help of the clpfd
library in Prolog:
I believe it should still work if you give it a smaller problem to solve though -- maybe just color all the territories / provinces in Canada instead?
Yes, I ended up using the Midwest (plus Kentucky, just to add a few more interesting constraints). I even made a GIF of some of the solutions!
Thanks for the links for constraint satisfaction, and I'll go make a separate issue about options checking.
Nice GIF! :D Glad it worked there. Thanks for opening the other issue - will close this one.
Hi @ztangent,
I was recently trying to put together a demonstration of logical programming using the 4 color theorem to color a map of the US. Although the code is relatively simple, the logical expressions are quite large; they're show below:
When I first ran this without any options set in
resolve
, the solver failed to finish after about an hour, and considering the size of the search space (~4^51 I believe) this didn't seem unreasonable. I then hoped that settingmode=:any
andsearch=:dfs
would solve in a reasonable amount of time for a single solution, but I also had to halt the solver after a half an hour had passed.I wanted to see if this second attempt (trying to find any solution via depth-first search) is one you would have expected to finish in a "reasonable" amount of time, or if this is simply too large a problem even for those options.
Also as a side note, it seems like there's no validity check with the
resolve
options, and any invalid option choice will just "fail" silently by using the default settings. Am I reading the code correctly for these cases?Thanks as always!