mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 04:03:39 +00:00
disable uhle from lookahead solver
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
75bf942237
commit
eca250933d
|
@ -36,40 +36,36 @@ public:
|
||||||
void next() { m_val = m_stream.get(); }
|
void next() { m_val = m_stream.get(); }
|
||||||
bool eof() const { return ch() == EOF; }
|
bool eof() const { return ch() == EOF; }
|
||||||
unsigned line() const { return m_line; }
|
unsigned line() const { return m_line; }
|
||||||
void skip_whitespace();
|
void skip_whitespace() {
|
||||||
void skip_space();
|
while ((ch() >= 9 && ch() <= 13) || ch() == 32) {
|
||||||
void skip_line();
|
if (ch() == 10) ++m_line;
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void skip_space() {
|
||||||
|
while (ch() != 10 && ((ch() >= 9 && ch() <= 13) || ch() == 32))
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
void skip_line() {
|
||||||
|
while(true) {
|
||||||
|
if (eof()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch() == '\n') {
|
||||||
|
++m_line;
|
||||||
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
bool parse_token(char const* token);
|
bool parse_token(char const* token);
|
||||||
int parse_int();
|
int parse_int();
|
||||||
unsigned parse_unsigned();
|
unsigned parse_unsigned();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void opt_stream_buffer::skip_whitespace() {
|
|
||||||
while ((ch() >= 9 && ch() <= 13) || ch() == 32) {
|
|
||||||
if (ch() == 10) ++m_line;
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void opt_stream_buffer::skip_space() {
|
|
||||||
while (ch() != 10 && ((ch() >= 9 && ch() <= 13) || ch() == 32)) {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void opt_stream_buffer::skip_line() {
|
|
||||||
while(true) {
|
|
||||||
if (eof()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ch() == '\n') {
|
|
||||||
++m_line;
|
|
||||||
next();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool opt_stream_buffer::parse_token(char const* token) {
|
bool opt_stream_buffer::parse_token(char const* token) {
|
||||||
skip_whitespace();
|
skip_whitespace();
|
||||||
|
@ -314,4 +310,183 @@ void parse_opb(opt::context& opt, std::istream& is, unsigned_vector& h) {
|
||||||
opb.parse();
|
opb.parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
class lp_stream_buffer : opt_stream_buffer {
|
||||||
|
public:
|
||||||
|
lp_stream_buffer(std::istream & s):
|
||||||
|
opt_stream_buffer(s)
|
||||||
|
{}
|
||||||
|
|
||||||
|
char lower(char c) {
|
||||||
|
return ('A' <= c && c <= 'Z') ? c - 'A' + 'a' : c;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parse_token_nocase(char const* token) {
|
||||||
|
skip_whitespace();
|
||||||
|
char const* t = token;
|
||||||
|
while (lower(ch()) == *t) {
|
||||||
|
next();
|
||||||
|
++t;
|
||||||
|
}
|
||||||
|
return 0 == *t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class lp_tokenizer {
|
||||||
|
opt_stream_buffer& in;
|
||||||
|
public:
|
||||||
|
lp_tokenizer(opt_stream_buffer& in):
|
||||||
|
in(in)
|
||||||
|
{}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class lp_parse {
|
||||||
|
opt::context& opt;
|
||||||
|
lp_tokenizer& tok;
|
||||||
|
public:
|
||||||
|
lp_parse(opt::context& opt, lp_stream_buffer& in): opt(opt), tok(is) {}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
objective();
|
||||||
|
subject_to();
|
||||||
|
bounds();
|
||||||
|
general();
|
||||||
|
binary();
|
||||||
|
}
|
||||||
|
|
||||||
|
void objective() {
|
||||||
|
m_objective.m_is_max = minmax();
|
||||||
|
m_objective.m_name = try_name();
|
||||||
|
m_objective.m_expr = expr();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool minmax() {
|
||||||
|
if (try_accept("minimize"))
|
||||||
|
return false;
|
||||||
|
if (try_accept("min"))
|
||||||
|
return false;
|
||||||
|
if (try_accept("maximize"))
|
||||||
|
return true;
|
||||||
|
if (try_accept("max"))
|
||||||
|
return true;
|
||||||
|
error("expected min or max objective");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool try_accept(char const* token) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool indicator(symbol& var, bool& val) {
|
||||||
|
if (!try_variable(var)) return false;
|
||||||
|
check(in.parse_token("="));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def indicator(self):
|
||||||
|
v = self.variable()
|
||||||
|
self.accept("=")
|
||||||
|
val = self.try_accept("1")
|
||||||
|
if val is None:
|
||||||
|
val = self.accept("0")
|
||||||
|
self.accept("->")
|
||||||
|
return (var, val)
|
||||||
|
|
||||||
|
def try_indicator(self):
|
||||||
|
try:
|
||||||
|
return self.indicator()
|
||||||
|
with:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def constraints(self):
|
||||||
|
return [c for c in self._constraints()]
|
||||||
|
|
||||||
|
def _constraints(self):
|
||||||
|
while True:
|
||||||
|
c = self.try_constraint()
|
||||||
|
if c in None:
|
||||||
|
return
|
||||||
|
yield c
|
||||||
|
|
||||||
|
def try_constraint(self):
|
||||||
|
try:
|
||||||
|
return self.constraint()
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def constraint(self):
|
||||||
|
name = self.try_label()
|
||||||
|
guard = self.try_guard()
|
||||||
|
e = self.expr()
|
||||||
|
op = self.relation()
|
||||||
|
rhs = self.numeral()
|
||||||
|
return (name, guard, e, ops, rhs)
|
||||||
|
|
||||||
|
def expr(self):
|
||||||
|
return [t for t in self.terms()]
|
||||||
|
|
||||||
|
def terms(self):
|
||||||
|
while True:
|
||||||
|
t = self.term()
|
||||||
|
if t is None:
|
||||||
|
return None
|
||||||
|
yield t
|
||||||
|
|
||||||
|
def term(self):
|
||||||
|
sign = self.sign()
|
||||||
|
coeff = self.coeff()
|
||||||
|
v = self.variable()
|
||||||
|
return (sign*coeff, v)
|
||||||
|
|
||||||
|
def sign(self):
|
||||||
|
if self.try_accept("-"):
|
||||||
|
return -1
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def coeff(self):
|
||||||
|
tok = self.peek()
|
||||||
|
if tok is int:
|
||||||
|
self.next()
|
||||||
|
return (int) tok
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def relation(self):
|
||||||
|
if self.try_accept("<="):
|
||||||
|
return "<="
|
||||||
|
if self.try_accept(">="):
|
||||||
|
return ">="
|
||||||
|
if self.try_accept("=<"):
|
||||||
|
return "<="
|
||||||
|
if self.try_accept("=>"):
|
||||||
|
return ">="
|
||||||
|
if self.try_accept("="):
|
||||||
|
return "="
|
||||||
|
return None
|
||||||
|
|
||||||
|
def subject_to(self):
|
||||||
|
if self.accept("subject") and self.accept("to"):
|
||||||
|
return
|
||||||
|
if self.accept("such") and self.accept("that"):
|
||||||
|
return
|
||||||
|
if self.accept("st"):
|
||||||
|
return
|
||||||
|
if self.accept("s"):
|
||||||
|
self.try_accept(".")
|
||||||
|
self.accept("t")
|
||||||
|
self.accept(".")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void parse_lp(opt::context& opt, std::istream& is) {
|
||||||
|
lp_stream_buffer _is(is);
|
||||||
|
lp_parse lp(opt, _is);
|
||||||
|
lp.parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -150,27 +150,6 @@ namespace sat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void asymm_branch::operator()(big& big) {
|
|
||||||
s.propagate(false);
|
|
||||||
if (s.m_inconsistent)
|
|
||||||
return;
|
|
||||||
report rpt(*this);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < m_asymm_branch_rounds; ++i) {
|
|
||||||
unsigned elim = m_elim_literals;
|
|
||||||
big.reinit();
|
|
||||||
process(&big, s.m_clauses);
|
|
||||||
process(&big, s.m_learned);
|
|
||||||
process_bin(big);
|
|
||||||
unsigned num_elim = m_elim_literals - elim;
|
|
||||||
IF_VERBOSE(1, verbose_stream() << "(sat-asymm-branch-step :elim " << num_elim << ")\n";);
|
|
||||||
if (num_elim == 0)
|
|
||||||
break;
|
|
||||||
if (num_elim > 1000)
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
s.propagate(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void asymm_branch::operator()(bool force) {
|
void asymm_branch::operator()(bool force) {
|
||||||
++m_calls;
|
++m_calls;
|
||||||
|
@ -196,11 +175,11 @@ namespace sat {
|
||||||
++counter;
|
++counter;
|
||||||
change = false;
|
change = false;
|
||||||
if (m_asymm_branch_sampled) {
|
if (m_asymm_branch_sampled) {
|
||||||
big big(s.m_rand, true);
|
big big(s.m_rand);
|
||||||
if (process(big, true)) change = true;
|
if (process(big, true)) change = true;
|
||||||
}
|
}
|
||||||
if (m_asymm_branch_sampled) {
|
if (m_asymm_branch_sampled) {
|
||||||
big big(s.m_rand, false);
|
big big(s.m_rand);
|
||||||
if (process(big, false)) change = true;
|
if (process(big, false)) change = true;
|
||||||
}
|
}
|
||||||
if (m_asymm_branch) {
|
if (m_asymm_branch) {
|
||||||
|
@ -431,11 +410,10 @@ namespace sat {
|
||||||
bool asymm_branch::process_sampled(big& big, clause & c) {
|
bool asymm_branch::process_sampled(big& big, clause & c) {
|
||||||
scoped_detach scoped_d(s, c);
|
scoped_detach scoped_d(s, c);
|
||||||
sort(big, c);
|
sort(big, c);
|
||||||
if (!big.learned() && !c.is_learned() && uhte(big, c)) {
|
if (uhte(big, c)) {
|
||||||
// TBD: mark clause as learned.
|
// don't touch hidden tautologies.
|
||||||
++m_hidden_tautologies;
|
// ATE takes care of them.
|
||||||
scoped_d.del_clause();
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return uhle(scoped_d, big, c);
|
return uhle(scoped_d, big, c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,6 @@ namespace sat {
|
||||||
|
|
||||||
void operator()(bool force);
|
void operator()(bool force);
|
||||||
|
|
||||||
void operator()(big& big);
|
|
||||||
|
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
static void collect_param_descrs(param_descrs & d);
|
static void collect_param_descrs(param_descrs & d);
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,8 @@ Revision History:
|
||||||
|
|
||||||
namespace sat {
|
namespace sat {
|
||||||
|
|
||||||
big::big(random_gen& rand, bool binary):
|
big::big(random_gen& rand):
|
||||||
m_rand(rand) {
|
m_rand(rand) {
|
||||||
m_binary = binary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void big::init(solver& s, bool learned) {
|
void big::init(solver& s, bool learned) {
|
||||||
|
@ -141,7 +140,6 @@ namespace sat {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned big::reduce_tr(solver& s) {
|
unsigned big::reduce_tr(solver& s) {
|
||||||
if (!m_binary && learned()) return 0;
|
|
||||||
unsigned num_lits = s.num_vars() * 2;
|
unsigned num_lits = s.num_vars() * 2;
|
||||||
unsigned idx = 0;
|
unsigned idx = 0;
|
||||||
unsigned elim = 0;
|
unsigned elim = 0;
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace sat {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
big(random_gen& rand, bool binary);
|
big(random_gen& rand);
|
||||||
/**
|
/**
|
||||||
\brief initialize a BIG from a solver.
|
\brief initialize a BIG from a solver.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,7 +76,6 @@ namespace sat {
|
||||||
m_unit_walk_threads = p.unit_walk_threads();
|
m_unit_walk_threads = p.unit_walk_threads();
|
||||||
m_lookahead_simplify = p.lookahead_simplify();
|
m_lookahead_simplify = p.lookahead_simplify();
|
||||||
m_lookahead_simplify_bca = p.lookahead_simplify_bca();
|
m_lookahead_simplify_bca = p.lookahead_simplify_bca();
|
||||||
m_lookahead_simplify_asymm_branch = p.lookahead_simplify_asymm_branch();
|
|
||||||
if (p.lookahead_reward() == symbol("heule_schur"))
|
if (p.lookahead_reward() == symbol("heule_schur"))
|
||||||
m_lookahead_reward = heule_schur_reward;
|
m_lookahead_reward = heule_schur_reward;
|
||||||
else if (p.lookahead_reward() == symbol("heuleu"))
|
else if (p.lookahead_reward() == symbol("heuleu"))
|
||||||
|
|
|
@ -94,7 +94,6 @@ namespace sat {
|
||||||
bool m_unit_walk;
|
bool m_unit_walk;
|
||||||
bool m_lookahead_simplify;
|
bool m_lookahead_simplify;
|
||||||
bool m_lookahead_simplify_bca;
|
bool m_lookahead_simplify_bca;
|
||||||
bool m_lookahead_simplify_asymm_branch;
|
|
||||||
cutoff_t m_lookahead_cube_cutoff;
|
cutoff_t m_lookahead_cube_cutoff;
|
||||||
double m_lookahead_cube_fraction;
|
double m_lookahead_cube_fraction;
|
||||||
unsigned m_lookahead_cube_depth;
|
unsigned m_lookahead_cube_depth;
|
||||||
|
|
|
@ -2306,16 +2306,12 @@ namespace sat {
|
||||||
roots[v] = p;
|
roots[v] = p;
|
||||||
VERIFY(get_parent(p) == p);
|
VERIFY(get_parent(p) == p);
|
||||||
VERIFY(get_parent(~p) == ~p);
|
VERIFY(get_parent(~p) == ~p);
|
||||||
IF_VERBOSE(0, verbose_stream() << p << " " << q << "\n";);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IF_VERBOSE(1, verbose_stream() << "(sat-lookahead :equivalences " << to_elim.size() << ")\n";);
|
IF_VERBOSE(1, verbose_stream() << "(sat-lookahead :equivalences " << to_elim.size() << ")\n";);
|
||||||
elim_eqs elim(m_s);
|
elim_eqs elim(m_s);
|
||||||
elim(roots, to_elim);
|
elim(roots, to_elim);
|
||||||
|
|
||||||
if (get_config().m_lookahead_simplify_asymm_branch) {
|
|
||||||
big_asymm_branch(learned);
|
|
||||||
}
|
|
||||||
if (learned && get_config().m_lookahead_simplify_bca) {
|
if (learned && get_config().m_lookahead_simplify_bca) {
|
||||||
add_hyper_binary();
|
add_hyper_binary();
|
||||||
}
|
}
|
||||||
|
@ -2324,29 +2320,6 @@ namespace sat {
|
||||||
m_lookahead.reset();
|
m_lookahead.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
\brief extract binary implication graph from learned binary clauses and use it
|
|
||||||
for strengthening clauses.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void lookahead::big_asymm_branch(bool learned) {
|
|
||||||
unsigned num_lits = m_s.num_vars() * 2;
|
|
||||||
unsigned idx = 0;
|
|
||||||
big big(m_s.m_rand, false);
|
|
||||||
big.init_adding_edges(m_s.num_vars(), learned);
|
|
||||||
for (auto const& lits : m_binary) {
|
|
||||||
literal u = get_parent(to_literal(idx++));
|
|
||||||
if (u == null_literal) continue;
|
|
||||||
for (literal v : lits) {
|
|
||||||
v = get_parent(v);
|
|
||||||
if (v != null_literal)
|
|
||||||
big.add_edge(u, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
big.done_adding_edges();
|
|
||||||
asymm_branch ab(m_s, m_s.m_params);
|
|
||||||
ab(big);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief reduction based on binary implication graph
|
\brief reduction based on binary implication graph
|
||||||
|
@ -2372,7 +2345,7 @@ namespace sat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
big big(m_s.m_rand, false);
|
big big(m_s.m_rand);
|
||||||
big.init(m_s, true);
|
big.init(m_s, true);
|
||||||
svector<std::pair<literal, literal>> candidates;
|
svector<std::pair<literal, literal>> candidates;
|
||||||
|
|
||||||
|
|
|
@ -555,8 +555,6 @@ namespace sat {
|
||||||
|
|
||||||
void add_hyper_binary();
|
void add_hyper_binary();
|
||||||
|
|
||||||
void big_asymm_branch(bool learned);
|
|
||||||
|
|
||||||
double psat_heur();
|
double psat_heur();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -51,7 +51,6 @@ def_module_params('sat',
|
||||||
('lookahead.preselect', BOOL, False, 'use pre-selection of subset of variables for branching'),
|
('lookahead.preselect', BOOL, False, 'use pre-selection of subset of variables for branching'),
|
||||||
('lookahead_simplify', BOOL, False, 'use lookahead solver during simplification'),
|
('lookahead_simplify', BOOL, False, 'use lookahead solver during simplification'),
|
||||||
('lookahead_simplify.bca', BOOL, True, 'add learned binary clauses as part of lookahead simplification'),
|
('lookahead_simplify.bca', BOOL, True, 'add learned binary clauses as part of lookahead simplification'),
|
||||||
('lookahead_simplify.asymm_branch', BOOL, True, 'apply asymmetric branch simplification with lookahead simplifier'),
|
|
||||||
('lookahead.global_autarky', BOOL, False, 'prefer to branch on variables that occur in clauses that are reduced'),
|
('lookahead.global_autarky', BOOL, False, 'prefer to branch on variables that occur in clauses that are reduced'),
|
||||||
('lookahead.reward', SYMBOL, 'march_cu', 'select lookahead heuristic: ternary, heule_schur (Heule Schur), heuleu (Heule Unit), unit, or march_cu')))
|
('lookahead.reward', SYMBOL, 'march_cu', 'select lookahead heuristic: ternary, heule_schur (Heule Schur), heuleu (Heule Unit), unit, or march_cu')))
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace sat {
|
||||||
|
|
||||||
scc::scc(solver & s, params_ref const & p):
|
scc::scc(solver & s, params_ref const & p):
|
||||||
m_solver(s),
|
m_solver(s),
|
||||||
m_big(s.m_rand, true) {
|
m_big(s.m_rand) {
|
||||||
reset_statistics();
|
reset_statistics();
|
||||||
updt_params(p);
|
updt_params(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ namespace sat {
|
||||||
}
|
}
|
||||||
register_clauses(s.m_clauses);
|
register_clauses(s.m_clauses);
|
||||||
|
|
||||||
if (bce_enabled() || bca_enabled() || ate_enabled()) {
|
if (!learned && (bce_enabled() || bca_enabled() || ate_enabled())) {
|
||||||
elim_blocked_clauses();
|
elim_blocked_clauses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue