mirror of
https://github.com/Z3Prover/z3
synced 2025-08-20 10:10:21 +00:00
Lpbounds (#4492)
* remove inheritance from bound propagation Signed-off-by: Lev Nachmanson <levnach@hotmail.com> * less inheritance Signed-off-by: Lev Nachmanson <levnach@hotmail.com> * less inheritance Signed-off-by: Lev Nachmanson <levnach@hotmail.com> * fix the build Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
29ce22cfb1
commit
742be83503
9 changed files with 185 additions and 211 deletions
|
@ -328,9 +328,6 @@ class theory_lra::imp {
|
|||
enode* get_enode(expr* e) const { return ctx().get_enode(e); }
|
||||
expr* get_owner(theory_var v) const { return get_enode(v)->get_owner(); }
|
||||
|
||||
lp::lar_solver& lp(){ return *m_solver.get(); }
|
||||
const lp::lar_solver& lp() const { return *m_solver.get(); }
|
||||
|
||||
void init_solver() {
|
||||
if (m_solver) return;
|
||||
|
||||
|
@ -969,6 +966,9 @@ public:
|
|||
std::for_each(m_internalize_states.begin(), m_internalize_states.end(), delete_proc<internalize_state>());
|
||||
}
|
||||
|
||||
lp::lar_solver& lp(){ return *m_solver.get(); }
|
||||
const lp::lar_solver& lp() const { return *m_solver.get(); }
|
||||
|
||||
void init() {
|
||||
if (m_solver) return;
|
||||
|
||||
|
@ -2311,10 +2311,34 @@ public:
|
|||
// }
|
||||
// }
|
||||
|
||||
bool bound_is_interesting(unsigned vi, lp::lconstraint_kind kind, const rational & bval) {
|
||||
theory_var v = lp().local_to_external(vi);
|
||||
if (v == null_theory_var) {
|
||||
return false;
|
||||
}
|
||||
if (m_bounds.size() <= static_cast<unsigned>(v) || m_unassigned_bounds[v] == 0) {
|
||||
return false;
|
||||
}
|
||||
for (lp_api::bound* b : m_bounds[v]) {
|
||||
if (ctx().get_assignment(b->get_bv()) == l_undef &&
|
||||
null_literal != is_bound_implied(kind, bval, *b)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void consume(rational const& v, lp::constraint_index j) {
|
||||
set_evidence(j, m_core, m_eqs);
|
||||
m_explanation.add_pair(j, v);
|
||||
}
|
||||
|
||||
|
||||
void propagate_bounds_with_lp_solver() {
|
||||
if (!should_propagate())
|
||||
return;
|
||||
local_bound_propagator bp(*this);
|
||||
|
||||
lp::lp_bound_propagator<imp> bp(*this);
|
||||
|
||||
lp().propagate_bounds_for_touched_rows(bp);
|
||||
|
||||
|
@ -2348,26 +2372,6 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct local_bound_propagator: public lp::lp_bound_propagator {
|
||||
imp & m_imp;
|
||||
local_bound_propagator(imp& i) : lp_bound_propagator(*i.m_solver), m_imp(i) {}
|
||||
|
||||
bool bound_is_interesting(unsigned j, lp::lconstraint_kind kind, const rational & v) override {
|
||||
return m_imp.bound_is_interesting(j, kind, v);
|
||||
}
|
||||
|
||||
void add_eq(lpvar u, lpvar v, lp::explanation const& e) {
|
||||
m_imp.add_eq(u, v, e);
|
||||
}
|
||||
|
||||
void consume(rational const& v, lp::constraint_index j) override {
|
||||
m_imp.set_evidence(j, m_imp.m_core, m_imp.m_eqs);
|
||||
m_imp.m_explanation.add_pair(j, v);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void propagate_lp_solver_bound(lp::implied_bound& be) {
|
||||
lpvar vi = be.m_j;
|
||||
theory_var v = lp().local_to_external(vi);
|
||||
|
@ -2400,7 +2404,7 @@ public:
|
|||
first = false;
|
||||
reset_evidence();
|
||||
m_explanation.clear();
|
||||
local_bound_propagator bp(*this);
|
||||
lp::lp_bound_propagator<imp> bp(*this);
|
||||
lp().explain_implied_bound(be, bp);
|
||||
}
|
||||
CTRACE("arith", m_unassigned_bounds[v] == 0, tout << "missed bound\n";);
|
||||
|
@ -4024,7 +4028,9 @@ theory_var theory_lra::add_objective(app* term) {
|
|||
expr_ref theory_lra::mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val) {
|
||||
return m_imp->mk_ge(fm, v, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
template class lp::lp_bound_propagator<smt::theory_lra::imp>;
|
||||
template void lp::lar_solver::propagate_bounds_for_touched_rows<smt::theory_lra::imp>(lp::lp_bound_propagator<smt::theory_lra::imp>&);
|
||||
template void lp::lar_solver::explain_implied_bound<smt::theory_lra::imp>(lp::implied_bound&, lp::lp_bound_propagator<smt::theory_lra::imp>&);
|
||||
template void lp::lar_solver::calculate_implied_bounds_for_row<smt::theory_lra::imp>(unsigned int, lp::lp_bound_propagator<smt::theory_lra::imp>&);
|
||||
template void lp::lar_solver::propagate_bounds_on_terms<smt::theory_lra::imp>(lp::lp_bound_propagator<smt::theory_lra::imp>&);
|
||||
|
|
|
@ -24,7 +24,9 @@ Revision History:
|
|||
|
||||
namespace smt {
|
||||
class theory_lra : public theory, public theory_opt {
|
||||
public:
|
||||
class imp;
|
||||
private:
|
||||
imp* m_imp;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue