3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

local changes

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-09-25 16:37:15 -07:00
parent 82922d92f7
commit ced2029ae9
12 changed files with 69 additions and 64 deletions

View file

@ -1619,11 +1619,14 @@ namespace sat {
double ba_solver::get_reward(card const& c, literal_occs_fun& literal_occs) const {
unsigned k = c.k(), slack = 0;
double to_add = 0;
bool do_add = get_config().m_lookahead_reward == heule_schur_reward;
double to_add = do_add ? 0: 1;
for (literal l : c) {
switch (value(l)) {
case l_true: --k; if (k == 0) return 0; break;
case l_undef: to_add += literal_occs(l); ++slack; break;
case l_true: --k; if (k == 0) return 0;
case l_undef:
if (do_add) to_add += literal_occs(l);
++slack; break;
case l_false: break;
}
}
@ -1633,14 +1636,19 @@ namespace sat {
double ba_solver::get_reward(pb const& c, literal_occs_fun& occs) const {
unsigned k = c.k(), slack = 0;
double to_add = 0;
bool do_add = get_config().m_lookahead_reward == heule_schur_reward;
double to_add = do_add ? 0 : 1;
double undefs = 0;
for (wliteral wl : c) {
literal l = wl.second;
unsigned w = wl.first;
switch (value(l)) {
case l_true: if (k <= w) return 0; k -= w; break;
case l_undef: to_add += occs(l); ++undefs; slack += w; break; // TBD multiplier factor on this
case l_true: if (k <= w) return 0;
case l_undef:
if (do_add) to_add += occs(l);
++undefs;
slack += w;
break; // TBD multiplier factor on this
case l_false: break;
}
}

View file

@ -87,7 +87,22 @@ namespace sat {
m_lookahead_simplify = p.lookahead_simplify();
m_lookahead_cube = p.lookahead_cube();
m_lookahead_search = p.lookahead_search();
m_lookahead_reward = p.lookahead_reward();
if (p.lookahead_reward() == symbol("hs")) {
m_lookahead_reward = heule_schur_reward;
}
else if (p.lookahead_reward() == symbol("heuleu")) {
m_lookahead_reward = heule_unit_reward;
}
else if (p.lookahead_reward() == symbol("ternary")) {
m_lookahead_reward = ternary_reward;
}
else if (p.lookahead_reward() == symbol("unit")) {
m_lookahead_reward = unit_literal_reward;
}
else {
throw sat_param_exception("invalid reward type supplied: accepted heuristics are 'ternary', 'heuleu', 'unit' or 'heule_schur'");
}
m_lookahead_cube_fraction = p.lookahead_cube_fraction();
m_lookahead_cube_cutoff = p.lookahead_cube_cutoff();

View file

@ -57,6 +57,13 @@ namespace sat {
PB_TOTALIZER
};
enum reward_t {
ternary_reward,
unit_literal_reward,
heule_schur_reward,
heule_unit_reward
};
struct config {
unsigned long long m_max_memory;
phase_selection m_phase;
@ -78,7 +85,7 @@ namespace sat {
bool m_lookahead_cube;
unsigned m_lookahead_cube_cutoff;
double m_lookahead_cube_fraction;
symbol m_lookahead_reward;
reward_t m_lookahead_reward;
unsigned m_simplify_mult1;
double m_simplify_mult2;

View file

@ -1299,7 +1299,7 @@ namespace sat {
case watched::EXT_CONSTRAINT: {
SASSERT(m_s.m_ext);
bool keep = m_s.m_ext->propagate(l, it->get_ext_constraint_idx());
if (m_search_mode == lookahead_mode::lookahead1) {
if (m_search_mode == lookahead_mode::lookahead1 && !m_inconsistent) {
lookahead_literal_occs_fun literal_occs_fn(*this);
m_lookahead_reward += m_s.m_ext->get_reward(l, it->get_ext_constraint_idx(), literal_occs_fn);
}
@ -2065,21 +2065,7 @@ namespace sat {
}
void lookahead::init_config() {
if (m_s.m_config.m_lookahead_reward == symbol("hs")) {
m_config.m_reward_type = heule_schur_reward;
}
else if (m_s.m_config.m_lookahead_reward == symbol("heuleu")) {
m_config.m_reward_type = heule_unit_reward;
}
else if (m_s.m_config.m_lookahead_reward == symbol("ternary")) {
m_config.m_reward_type = ternary_reward;
}
else if (m_s.m_config.m_lookahead_reward == symbol("unit")) {
m_config.m_reward_type = unit_literal_reward;
}
else {
warning_msg("Reward type not recognized");
}
m_config.m_reward_type = m_s.m_config.m_lookahead_reward;
m_config.m_cube_cutoff = m_s.m_config.m_lookahead_cube_cutoff;
m_config.m_cube_fraction = m_s.m_config.m_lookahead_cube_fraction;
}

View file

@ -66,13 +66,6 @@ namespace sat {
friend class ccc;
friend class ba_solver;
enum reward_t {
ternary_reward,
unit_literal_reward,
heule_schur_reward,
heule_unit_reward
};
struct config {
double m_dl_success;
double m_alpha;

View file

@ -1060,10 +1060,12 @@ namespace sat {
it.next();
}
ext_constraint_list const& ext_list = s.m_ext_use_list.get(~l);
for (ext_constraint_idx idx : ext_list) {
if (!s.s.m_ext->is_blocked(l, idx)) {
return false;
if (s.s.m_ext) {
ext_constraint_list const& ext_list = s.m_ext_use_list.get(~l);
for (ext_constraint_idx idx : ext_list) {
if (!s.s.m_ext->is_blocked(l, idx)) {
return false;
}
}
}
return true;