mirror of
https://github.com/Z3Prover/z3
synced 2025-08-23 11:37:54 +00:00
wip - integrating arithmetic local search
This commit is contained in:
parent
1b0c76e3f0
commit
d22e4aa525
7 changed files with 280 additions and 169 deletions
|
@ -30,6 +30,7 @@ Author:
|
|||
#include "math/polynomial/algebraic_numbers.h"
|
||||
#include "math/polynomial/polynomial.h"
|
||||
#include "sat/smt/sat_th.h"
|
||||
#include "sat/sat_ddfw.h"
|
||||
|
||||
namespace euf {
|
||||
class solver;
|
||||
|
@ -197,6 +198,14 @@ namespace arith {
|
|||
typedef unsigned var_t;
|
||||
typedef unsigned atom_t;
|
||||
|
||||
struct config {
|
||||
double cb = 0.0;
|
||||
unsigned L = 20;
|
||||
unsigned t = 45;
|
||||
unsigned max_no_improve = 500000;
|
||||
double sp = 0.0003;
|
||||
};
|
||||
|
||||
struct stats {
|
||||
unsigned m_num_flips = 0;
|
||||
};
|
||||
|
@ -237,26 +246,49 @@ namespace arith {
|
|||
unsigned m_breaks = 0;
|
||||
};
|
||||
|
||||
solver& s;
|
||||
ast_manager& m;
|
||||
unsigned m_max_arith_steps = 0;
|
||||
stats m_stats;
|
||||
vector<atom_info> m_atoms;
|
||||
vector<var_info> m_vars;
|
||||
struct clause {
|
||||
unsigned m_weight = 1;
|
||||
rational m_dts = rational::one();
|
||||
};
|
||||
|
||||
solver& s;
|
||||
ast_manager& m;
|
||||
sat::ddfw* m_bool_search = nullptr;
|
||||
unsigned m_max_arith_steps = 0;
|
||||
unsigned m_best_min_unsat = UINT_MAX;
|
||||
stats m_stats;
|
||||
config m_config;
|
||||
scoped_ptr_vector<atom_info> m_atoms;
|
||||
vector<var_info> m_vars;
|
||||
vector<clause> m_clauses;
|
||||
|
||||
indexed_uint_set& unsat() { return m_bool_search->unsat_set(); }
|
||||
unsigned num_clauses() const { return m_bool_search->num_clauses(); }
|
||||
sat::clause& get_clause(unsigned idx) { return *get_clause_info(idx).m_clause; }
|
||||
sat::clause const& get_clause(unsigned idx) const { return *get_clause_info(idx).m_clause; }
|
||||
sat::ddfw::clause_info& get_clause_info(unsigned idx) { return m_bool_search->get_clause_info(idx); }
|
||||
sat::ddfw::clause_info const& get_clause_info(unsigned idx) const { return m_bool_search->get_clause_info(idx); }
|
||||
|
||||
atom_info* atom(sat::literal lit) const { return m_atoms[lit.index()]; }
|
||||
rational& dts(unsigned idx) { return m_clauses[idx].m_dts; }
|
||||
bool flip();
|
||||
void log() {}
|
||||
bool flip_unsat() { return false; }
|
||||
bool flip_clauses() { return false; }
|
||||
bool flip_dscore() { return false; }
|
||||
// bool flip_dscore(clause const&);
|
||||
// bool flip(clause const&);
|
||||
bool flip_unsat();
|
||||
bool flip_clauses();
|
||||
bool flip_dscore();
|
||||
bool flip_dscore(unsigned cl);
|
||||
bool flip(unsigned cl);
|
||||
rational dtt(ineq const& ineq) const { return dtt(ineq.m_args_value, ineq); }
|
||||
rational dtt(rational const& args, ineq const& ineq) const;
|
||||
rational dtt(ineq const& ineq, var_t v, rational const& new_value) const;
|
||||
// rational dts(clause const& cl, var_t v, rational const& new_value) const;
|
||||
// rational dts(clause const& cl) const;
|
||||
rational dts(unsigned cl, var_t v, rational const& new_value) const;
|
||||
rational dts(unsigned cl) const;
|
||||
bool cm(ineq const& ineq, var_t v, rational& new_value);
|
||||
int cm_score(var_t v, rational const& new_value);
|
||||
void update(var_t v, rational const& new_value);
|
||||
void paws();
|
||||
rational dscore(var_t v, rational const& new_value) const;
|
||||
void save_best_values() {}
|
||||
|
||||
rational value(var_t v) const { return m_vars[v].m_value; }
|
||||
public:
|
||||
|
@ -265,6 +297,7 @@ namespace arith {
|
|||
void set_bounds_begin();
|
||||
void set_bounds_end(unsigned num_literals);
|
||||
void set_bounds(enode* n);
|
||||
void set(sat::ddfw* d) { m_bool_search = d; }
|
||||
};
|
||||
|
||||
sls m_local_search;
|
||||
|
@ -590,6 +623,7 @@ namespace arith {
|
|||
void set_bounds_end(unsigned num_literals) override { m_local_search.set_bounds_end(num_literals); }
|
||||
void set_bounds(enode* n) override { m_local_search.set_bounds(n); }
|
||||
void local_search(bool_vector& phase) override { m_local_search(phase); }
|
||||
void set_bool_search(sat::ddfw* ddfw) override { m_local_search.set(ddfw); }
|
||||
|
||||
// bounds and equality propagation callbacks
|
||||
lp::lar_solver& lp() { return *m_solver; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue