mirror of
https://github.com/Z3Prover/z3
synced 2025-08-05 10:50:24 +00:00
adding skeleton for local search
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
77aac8d96f
commit
747ff19aba
4 changed files with 226 additions and 12 deletions
|
@ -281,7 +281,7 @@ namespace sat {
|
|||
}
|
||||
|
||||
//
|
||||
// lit1 => lit2.
|
||||
// lit1 => lit2.n
|
||||
// if lit2 is a node, put lit1 above lit2
|
||||
//
|
||||
|
||||
|
@ -351,23 +351,34 @@ namespace sat {
|
|||
}
|
||||
}
|
||||
|
||||
lbool backtrack(literal_vector& trail) {
|
||||
if (inconsistent()) {
|
||||
if (trail.empty()) return l_false;
|
||||
pop();
|
||||
assign(~trail.back());
|
||||
trail.pop_back();
|
||||
return l_true;
|
||||
}
|
||||
return l_undef;
|
||||
}
|
||||
|
||||
lbool search() {
|
||||
literal_vector trail;
|
||||
|
||||
#define BACKTRACK \
|
||||
if (inconsistent()) { \
|
||||
if (trail.empty()) return l_false; \
|
||||
pop(); \
|
||||
assign(~trail.back()); \
|
||||
trail.pop_back(); \
|
||||
continue; \
|
||||
} \
|
||||
|
||||
while (true) {
|
||||
s.checkpoint();
|
||||
BACKTRACK;
|
||||
switch (backtrack(trail)) {
|
||||
case l_true: continue;
|
||||
case l_false: return l_false;
|
||||
case l_undef: break;
|
||||
}
|
||||
|
||||
literal l = choose();
|
||||
BACKTRACK;
|
||||
switch (backtrack(trail)) {
|
||||
case l_true: continue;
|
||||
case l_false: return l_false;
|
||||
case l_undef: break;
|
||||
}
|
||||
if (l == null_literal) {
|
||||
return l_true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue