mirror of
https://github.com/Z3Prover/z3
synced 2026-07-04 22:36:10 +00:00
create separate file for expression based lookahead solver
This commit is contained in:
parent
f6e7dcff47
commit
d805322dfb
7 changed files with 896 additions and 798 deletions
|
|
@ -23,20 +23,12 @@ Author:
|
|||
#include "ast/arith_decl_plugin.h"
|
||||
#include "ast/sls/sls_context.h"
|
||||
#include "ast/sls/sls_arith_clausal.h"
|
||||
#include "ast/sls/sls_arith_lookahead.h"
|
||||
|
||||
namespace sls {
|
||||
|
||||
using theory_var = int;
|
||||
|
||||
enum arith_move_type {
|
||||
hillclimb,
|
||||
hillclimb_plateau,
|
||||
random_update,
|
||||
random_inc_dec
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, arith_move_type mt);
|
||||
|
||||
static const unsigned null_arith_var = UINT_MAX;
|
||||
|
||||
// local search portion for arithmetic
|
||||
|
|
@ -213,7 +205,9 @@ namespace sls {
|
|||
unsigned m_updates_max_size = 45;
|
||||
arith_util a;
|
||||
friend class arith_clausal<num_t>;
|
||||
friend class arith_lookahead<num_t>;
|
||||
arith_clausal<num_t> m_clausal_sls;
|
||||
arith_lookahead<num_t> m_lookahead_sls;
|
||||
svector<double> m_prob_break;
|
||||
indexed_uint_set m_bool_var_atoms;
|
||||
indexed_uint_set m_tmp_set;
|
||||
|
|
@ -325,72 +319,9 @@ namespace sls {
|
|||
std::ostream& display(std::ostream& out, add_def const& ad) const;
|
||||
std::ostream& display(std::ostream& out, mul_def const& md) const;
|
||||
|
||||
|
||||
|
||||
// for global lookahead search mode
|
||||
void global_search();
|
||||
struct bool_info {
|
||||
unsigned weight = 0;
|
||||
double score = 0;
|
||||
unsigned touched = 1;
|
||||
lbool value = l_undef;
|
||||
sat::bool_var_vector fixable_atoms;
|
||||
svector<var_t> fixable_vars;
|
||||
ptr_vector<expr> fixable_exprs;
|
||||
bool_info(unsigned w) : weight(w) {}
|
||||
};
|
||||
|
||||
vector<ptr_vector<app>> m_update_stack;
|
||||
expr_mark m_in_update_stack;
|
||||
svector<bool_info> m_bool_info;
|
||||
double m_best_score = 0, m_top_score = 0;
|
||||
unsigned m_min_depth = 0, m_max_depth = 0;
|
||||
num_t m_best_value;
|
||||
expr* m_best_expr = nullptr, * m_last_atom = nullptr, * m_last_expr = nullptr;
|
||||
expr_mark m_is_root;
|
||||
unsigned m_touched = 1;
|
||||
sat::bool_var_set m_fixed_atoms;
|
||||
uint64_t m_tabu_set = 0;
|
||||
unsigned m_global_search_count = 0;
|
||||
|
||||
bool in_tabu_set(expr* e, num_t const& n);
|
||||
void insert_tabu_set(expr* e, num_t const& n);
|
||||
bool_info& get_bool_info(expr* e);
|
||||
bool get_bool_value(expr* e);
|
||||
bool get_bool_value_rec(expr* e);
|
||||
void set_bool_value(expr* e, bool v) { get_bool_info(e).value = to_lbool(v); }
|
||||
bool get_basic_bool_value(app* e);
|
||||
void initialize_bool_assignment();
|
||||
|
||||
void finalize_bool_assignment();
|
||||
double old_score(expr* e) { return get_bool_info(e).score; }
|
||||
double new_score(expr* e);
|
||||
double new_score(expr* e, bool is_true);
|
||||
void set_score(expr* e, double s) { get_bool_info(e).score = s; }
|
||||
void rescore();
|
||||
void recalibrate_weights();
|
||||
void inc_weight(expr* e) { ++get_bool_info(e).weight; }
|
||||
void dec_weight(expr* e) { auto& i = get_bool_info(e); i.weight = i.weight > m_config.paws_init ? i.weight - 1 : m_config.paws_init; }
|
||||
unsigned get_weight(expr* e) { return get_bool_info(e).weight; }
|
||||
unsigned get_touched(expr* e) { return get_bool_info(e).touched; }
|
||||
void inc_touched(expr* e) { ++get_bool_info(e).touched; }
|
||||
void set_touched(expr* e, unsigned t) { get_bool_info(e).touched = t; }
|
||||
void insert_update_stack(expr* t);
|
||||
void insert_update_stack_rec(expr* t);
|
||||
void clear_update_stack();
|
||||
void lookahead_num(var_t v, num_t const& value);
|
||||
void update_args_value(var_t v, num_t const& new_value);
|
||||
bool can_update_num(var_t v, num_t const& delta);
|
||||
bool update_num(var_t v, num_t const& delta);
|
||||
void lookahead_bool(expr* e);
|
||||
double lookahead(expr* e, bool update_score);
|
||||
void add_lookahead(bool_info& i, expr* e);
|
||||
void add_lookahead(bool_info& i, sat::bool_var bv);
|
||||
ptr_vector<expr> const& get_fixable_exprs(expr* e);
|
||||
bool apply_move(expr* f, ptr_vector<expr> const& vars, arith_move_type t);
|
||||
expr* get_candidate_unsat();
|
||||
void check_restart();
|
||||
void ucb_forget();
|
||||
void update_args_value(var_t v, num_t const& new_value);
|
||||
public:
|
||||
arith_base(context& ctx);
|
||||
~arith_base() override {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue