Huge performance improvement when using the QF_FD logic #6348
Replies: 1 comment 1 reply
-
QF_FD uses transformations that convert arithmetic to Booleans/Bit-vectors/Cardinality constraints. It then uses a more efficient solver core. Z3's front-end allows arithmetic on Booleans. It is too tedious to always wrap them in an if-then-else when z3 can do it internally. Not sure about QF_BV the unsoundness. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I know it might sound strange to complain about a huge performance improvement, but I was just wondering if this is intended.
I'm solving the boolean n-queens problem in a variety of solvers to test their ALL-SAT performance. I use blocking clauses to implement ALL-SAT search in Z3.
As expected, CP solvers (specially ones based on MAC) absolutely dominate the challenge with their built-in DFS search.
Z3 was giving me a rather disappointing 11 seconds for a 10x10 board, even after explicitly using pseudo-boolean constraints.
But then I switched to the "QF_FD" logic explicitly (before I just let the solver pick), and now it takes 200ms, not quite Gecode but two orders of magnitude better is huge. Not only that, I get the excellent performance even if I don't use pseudo-boolean constraints explicitly, Z3 seems to detect it's a pseudo-boolean problem automatically somehow?
My question is, shouldn't the solver be able to detect that the problem is in the QF_FD logic automatically if every variable is a Boolean? It would be nice to not have to explicitly request it.
Note: I tried with QF_BV just out of curiosity and it gave incorrect results (1 extra solution) consistently for different board sizes. I was actually surprised it worked at all, I wasn't expecting z3::sum to work on Boolean variables without converting them to integers or bit vectors first using z3::ite(b, 1, 0) for example, at least not without QF_FD explicitly set.
EDIT: actually, on higher board sizes, using the PB constraints explicitly actually gives worse results somehow...
Beta Was this translation helpful? Give feedback.
All reactions