mirror of
https://github.com/Z3Prover/z3
synced 2025-08-17 00:32:16 +00:00
parent
5d06fa2347
commit
3c1c3d5987
12 changed files with 103 additions and 31 deletions
|
@ -23,6 +23,8 @@
|
|||
#include "sat/sat_types.h"
|
||||
#include "sat/sat_config.h"
|
||||
#include "util/rlimit.h"
|
||||
#include "util/ema.h"
|
||||
#include "util/statistics.h"
|
||||
|
||||
namespace sat {
|
||||
|
||||
|
@ -33,18 +35,21 @@ namespace sat {
|
|||
int m_best_known_value;
|
||||
local_search_mode m_mode;
|
||||
bool m_phase_sticky;
|
||||
bool m_dbg_flips;
|
||||
public:
|
||||
local_search_config() {
|
||||
m_random_seed = 0;
|
||||
m_best_known_value = INT_MAX;
|
||||
m_mode = local_search_mode::wsat;
|
||||
m_phase_sticky = false;
|
||||
m_dbg_flips = false;
|
||||
}
|
||||
|
||||
unsigned random_seed() const { return m_random_seed; }
|
||||
unsigned best_known_value() const { return m_best_known_value; }
|
||||
local_search_mode mode() const { return m_mode; }
|
||||
bool phase_sticky() const { return m_phase_sticky; }
|
||||
bool dbg_flips() const { return m_dbg_flips; }
|
||||
|
||||
void set_random_seed(unsigned s) { m_random_seed = s; }
|
||||
void set_best_known_value(unsigned v) { m_best_known_value = v; }
|
||||
|
@ -53,6 +58,7 @@ namespace sat {
|
|||
m_mode = cfg.m_local_search_mode;
|
||||
m_random_seed = cfg.m_random_seed;
|
||||
m_phase_sticky = cfg.m_phase_sticky;
|
||||
m_dbg_flips = cfg.m_local_search_dbg_flips;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,6 +80,13 @@ namespace sat {
|
|||
int coefficient; // non-zero integer
|
||||
ob_term(bool_var v, int c): var_id(v), coefficient(c) {}
|
||||
};
|
||||
|
||||
struct stats {
|
||||
unsigned m_num_flips;
|
||||
unsigned m_num_restarts;
|
||||
void reset() { memset(this, 0, sizeof(*this)); }
|
||||
stats() { reset(); }
|
||||
};
|
||||
|
||||
struct var_info {
|
||||
bool m_value; // current solution
|
||||
|
@ -89,6 +102,8 @@ namespace sat {
|
|||
bool_var_vector m_neighbors; // neighborhood variables
|
||||
coeff_vector m_watch[2];
|
||||
literal_vector m_bin[2];
|
||||
unsigned m_flips;
|
||||
ema m_slow_break;
|
||||
var_info():
|
||||
m_value(true),
|
||||
m_bias(50),
|
||||
|
@ -97,7 +112,9 @@ namespace sat {
|
|||
m_in_goodvar_stack(false),
|
||||
m_score(0),
|
||||
m_slack_score(0),
|
||||
m_cscc(0)
|
||||
m_cscc(0),
|
||||
m_flips(0),
|
||||
m_slow_break(1e-5)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -115,6 +132,8 @@ namespace sat {
|
|||
literal const* end() const { return m_literals.end(); }
|
||||
};
|
||||
|
||||
stats m_stats;
|
||||
|
||||
local_search_config m_config;
|
||||
|
||||
// objective function: maximize
|
||||
|
@ -145,7 +164,6 @@ namespace sat {
|
|||
|
||||
inline void set_best_unsat();
|
||||
/* TBD: other scores */
|
||||
|
||||
|
||||
vector<constraint> m_constraints;
|
||||
|
||||
|
@ -293,6 +311,8 @@ namespace sat {
|
|||
|
||||
model& get_model() { return m_model; }
|
||||
|
||||
void collect_statistics(statistics& st) const;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue