3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-24 03:57:51 +00:00

simplify inequality propagation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-08-14 23:36:51 -07:00
commit 6af314c6d9
6 changed files with 126 additions and 209 deletions

View file

@ -29,6 +29,7 @@ Author:
#include "util/dependency.h"
#include "util/ref.h"
#include "util/params.h"
#include "util/union_find.h"
inline rational to_rational(uint64_t n) { return rational(n, rational::ui64()); }
inline unsigned trailing_zeros(unsigned short n) { return trailing_zeros((uint32_t)n); }
@ -183,8 +184,7 @@ namespace polysat {
var_heap m_to_patch;
vector<var_info> m_vars;
vector<row_info> m_rows;
vector<var_eq> m_var_eqs;
vector<numeral> m_fixed_vals;
bool m_bland = false ;
unsigned m_blands_rule_threshold = 1000;
unsigned m_num_repeated = 0;
@ -198,7 +198,14 @@ namespace polysat {
u_dependency_manager m_deps;
svector<trail_i> m_trail;
svector<var_t> m_row_trail;
// euqality propagation
union_find_default_ctx m_union_find_ctx;
union_find<> m_union_find;
vector<var_eq> m_var_eqs;
vector<numeral> m_fixed_vals;
map<numeral, fix_entry, typename manager::hash, typename manager::eq> m_value2fixed_var;
uint_set m_eq_rows;
// inequalities
svector<ineq> m_ineqs;
@ -206,11 +213,15 @@ namespace polysat {
uint_set m_touched_vars;
vector<unsigned_vector> m_var2ineqs;
// bound propagation
uint_set m_bound_rows;
public:
fixplex(params_ref const& p, reslimit& lim):
m_limit(lim),
M(m),
m_to_patch(1024) {
m_to_patch(1024),
m_union_find(m_union_find_ctx) {
updt_params(p);
}
@ -246,8 +257,6 @@ namespace polysat {
unsigned get_num_vars() const { return m_vars.size(); }
void reset();
// void propagate_eqs();
vector<var_eq> const& var_eqs() const { return m_var_eqs; }
void add_row(var_t base, unsigned num_vars, var_t const* vars, numeral const* coeffs);
@ -267,7 +276,9 @@ namespace polysat {
void ensure_var(var_t v);
bool patch();
bool propagate();
bool propagate_ineqs();
bool propagate_row_eqs();
bool propagate_row_bounds();
bool is_satisfied();
var_t select_smallest_var() { return m_to_patch.empty()?null_var:m_to_patch.erase_min(); }
@ -278,6 +289,8 @@ namespace polysat {
void lookahead_eq(row const& r1, numeral const& cx, var_t x, numeral const& cy, var_t y);
void get_offset_eqs(row const& r);
void fixed_var_eh(u_dependency* dep, var_t x);
var_t find(var_t x) { return m_union_find.find(x); }
void merge(var_t x, var_t y) { m_union_find.merge(x, y); }
void eq_eh(var_t x, var_t y, u_dependency* dep);
bool propagate_row(row const& r);
bool propagate_ineq(ineq const& i);
@ -312,7 +325,6 @@ namespace polysat {
bool row_is_integral(row const& r) const { return m_rows[r.id()].m_integral; }
void set_base_value(var_t x);
numeral solve_for(numeral const& row_value, numeral const& coeff);
bool is_feasible() const;
int get_num_non_free_dep_vars(var_t x_j, int best_so_far);
void add_patch(var_t v);
var_t select_var_to_fix();