mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
fix gc of pb constraints
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
01418a06a3
commit
64ba2a9fc9
|
@ -117,6 +117,7 @@ namespace sat {
|
||||||
virtual void init_use_list(ext_use_list& ul) {}
|
virtual void init_use_list(ext_use_list& ul) {}
|
||||||
virtual bool is_blocked(literal l, ext_constraint_idx) { return false; }
|
virtual bool is_blocked(literal l, ext_constraint_idx) { return false; }
|
||||||
virtual bool check_model(model const& m) const { return true; }
|
virtual bool check_model(model const& m) const { return true; }
|
||||||
|
virtual void gc_vars(unsigned num_vars) {}
|
||||||
|
|
||||||
virtual bool extract_pb(std::function<void(unsigned sz, literal const* c, unsigned k)>& card,
|
virtual bool extract_pb(std::function<void(unsigned sz, literal const* c, unsigned k)>& card,
|
||||||
std::function<void(unsigned sz, literal const* c, unsigned const* coeffs, unsigned k)>& pb) {
|
std::function<void(unsigned sz, literal const* c, unsigned const* coeffs, unsigned k)>& pb) {
|
||||||
|
|
|
@ -471,6 +471,9 @@ namespace sat {
|
||||||
gc_clauses(m_learned);
|
gc_clauses(m_learned);
|
||||||
gc_clauses(m_clauses);
|
gc_clauses(m_clauses);
|
||||||
|
|
||||||
|
if (m_ext)
|
||||||
|
m_ext->gc_vars(max_var);
|
||||||
|
|
||||||
unsigned j = 0;
|
unsigned j = 0;
|
||||||
for (literal lit : m_trail) {
|
for (literal lit : m_trail) {
|
||||||
SASSERT(lvl(lit) == 0);
|
SASSERT(lvl(lit) == 0);
|
||||||
|
|
|
@ -1892,9 +1892,31 @@ namespace sat {
|
||||||
m_stats.m_num_gc += removed;
|
m_stats.m_num_gc += removed;
|
||||||
m_learned.shrink(new_sz);
|
m_learned.shrink(new_sz);
|
||||||
IF_VERBOSE(2, verbose_stream() << "(sat-gc :strategy " << st_name << " :deleted " << removed << ")\n";);
|
IF_VERBOSE(2, verbose_stream() << "(sat-gc :strategy " << st_name << " :deleted " << removed << ")\n";);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ba_solver::gc_vars(unsigned num_vars) {
|
||||||
|
gc_vars(num_vars, m_constraints);
|
||||||
|
gc_vars(num_vars, m_learned);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ba_solver::gc_vars(unsigned num_vars, ptr_vector<constraint>& cs) {
|
||||||
|
unsigned j = 0;
|
||||||
|
for (unsigned i = 0; i < cs.size(); ++i) {
|
||||||
|
auto* c = cs[i];
|
||||||
|
unsigned m = c->fold_max_var(0);
|
||||||
|
if (m >= num_vars) {
|
||||||
|
clear_watch(*c);
|
||||||
|
c->nullify_tracking_literal(*this);
|
||||||
|
c->deallocate(m_allocator);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cs[j++] = c;
|
||||||
|
}
|
||||||
|
cs.shrink(j);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
lbool ba_solver::add_assign(card& c, literal alit) {
|
lbool ba_solver::add_assign(card& c, literal alit) {
|
||||||
// literal is assigned to false.
|
// literal is assigned to false.
|
||||||
unsigned sz = c.size();
|
unsigned sz = c.size();
|
||||||
|
|
|
@ -187,6 +187,7 @@ namespace sat {
|
||||||
void cleanup_constraints();
|
void cleanup_constraints();
|
||||||
void cleanup_constraints(ptr_vector<constraint>& cs, bool learned);
|
void cleanup_constraints(ptr_vector<constraint>& cs, bool learned);
|
||||||
void remove_constraint(constraint& c, char const* reason);
|
void remove_constraint(constraint& c, char const* reason);
|
||||||
|
void gc_vars(unsigned num_vars, ptr_vector<constraint>& cs);
|
||||||
|
|
||||||
// constraints
|
// constraints
|
||||||
constraint& index2constraint(size_t idx) const { return *reinterpret_cast<constraint*>(constraint_base::from_index(idx)->mem()); }
|
constraint& index2constraint(size_t idx) const { return *reinterpret_cast<constraint*>(constraint_base::from_index(idx)->mem()); }
|
||||||
|
@ -424,6 +425,7 @@ namespace sat {
|
||||||
void find_mutexes(literal_vector& lits, vector<literal_vector> & mutexes) override;
|
void find_mutexes(literal_vector& lits, vector<literal_vector> & mutexes) override;
|
||||||
void pop_reinit() override;
|
void pop_reinit() override;
|
||||||
void gc() override;
|
void gc() override;
|
||||||
|
void gc_vars(unsigned num_vars) override;
|
||||||
bool is_extended_binary(ext_justification_idx idx, literal_vector & r) override;
|
bool is_extended_binary(ext_justification_idx idx, literal_vector & r) override;
|
||||||
void init_use_list(ext_use_list& ul) override;
|
void init_use_list(ext_use_list& ul) override;
|
||||||
bool is_blocked(literal l, ext_constraint_idx idx) override;
|
bool is_blocked(literal l, ext_constraint_idx idx) override;
|
||||||
|
|
|
@ -729,6 +729,11 @@ namespace euf {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void solver::gc_vars(unsigned num_vars) {
|
||||||
|
for (auto* e : m_solvers)
|
||||||
|
e->gc_vars(num_vars);
|
||||||
|
}
|
||||||
|
|
||||||
double solver::get_reward(literal l, ext_constraint_idx idx, sat::literal_occs_fun& occs) const {
|
double solver::get_reward(literal l, ext_constraint_idx idx, sat::literal_occs_fun& occs) const {
|
||||||
auto* ext = sat::constraint_base::to_extension(idx);
|
auto* ext = sat::constraint_base::to_extension(idx);
|
||||||
SASSERT(ext);
|
SASSERT(ext);
|
||||||
|
|
|
@ -304,6 +304,7 @@ namespace euf {
|
||||||
void init_use_list(sat::ext_use_list& ul) override;
|
void init_use_list(sat::ext_use_list& ul) override;
|
||||||
bool is_blocked(literal l, ext_constraint_idx) override;
|
bool is_blocked(literal l, ext_constraint_idx) override;
|
||||||
bool check_model(sat::model const& m) const override;
|
bool check_model(sat::model const& m) const override;
|
||||||
|
void gc_vars(unsigned num_vars) override;
|
||||||
|
|
||||||
// proof
|
// proof
|
||||||
bool use_drat() { return s().get_config().m_drat && (init_drat(), true); }
|
bool use_drat() { return s().get_config().m_drat && (init_drat(), true); }
|
||||||
|
|
Loading…
Reference in a new issue