mirror of
https://github.com/Z3Prover/z3
synced 2025-08-17 00:32:16 +00:00
updates
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
ba0ec79375
commit
1c7cb87900
3 changed files with 118 additions and 120 deletions
|
@ -56,13 +56,13 @@ namespace sat {
|
|||
|
||||
// data structure for a term in objective function
|
||||
struct ob_term {
|
||||
bool_var var_id; // variable id, begin with 1
|
||||
bool_var var_id; // variable id, begin with 1
|
||||
int coefficient; // non-zero integer
|
||||
};
|
||||
|
||||
// data structure for a term in constraint
|
||||
struct term {
|
||||
bool_var var_id; // variable id, begin with 1
|
||||
bool_var var_id; // variable id, begin with 1
|
||||
bool sense; // 1 for positive, 0 for negative
|
||||
//int coefficient; // all constraints are cardinality: coefficient=1
|
||||
};
|
||||
|
@ -70,25 +70,17 @@ namespace sat {
|
|||
|
||||
// objective function: maximize
|
||||
svector<ob_term> ob_constraint; // the objective function *constraint*, sorted in decending order
|
||||
|
||||
|
||||
// terms arrays
|
||||
vector<svector<term> > constraint_term; // constraint_term[i][j] means the j'th term of constraint i
|
||||
|
||||
// parameters of the instance
|
||||
unsigned num_vars() const { return m_vars.size() - 1; } // var index from 1 to num_vars
|
||||
unsigned num_constraints() const { return constraint_term.size(); } // constraint index from 1 to num_constraint
|
||||
|
||||
|
||||
|
||||
// information about the variable
|
||||
int_vector coefficient_in_ob_constraint; // initialized to be 0
|
||||
// int_vector sscore; // slack score
|
||||
|
||||
struct var_info {
|
||||
bool m_conf_change; // whether its configure changes since its last flip
|
||||
bool m_in_goodvar_stack;
|
||||
int m_score;
|
||||
int m_slack_score;
|
||||
int m_time_stamp; // the flip time stamp
|
||||
int m_cscc; // how many times its constraint state configure changes since its last flip
|
||||
int_vector m_watch[2];
|
||||
var_info():
|
||||
m_conf_change(true),
|
||||
|
@ -109,17 +101,42 @@ namespace sat {
|
|||
|
||||
inline bool already_in_goodvar_stack(unsigned v) const { return m_vars[v].m_in_goodvar_stack; }
|
||||
inline bool conf_change(unsigned v) const { return m_vars[v].m_conf_change; }
|
||||
inline int time_stamp(bool_var v) const { return m_vars[v].m_time_stamp; }
|
||||
inline int cscc(bool_var v) const { return m_vars[v].m_cscc; }
|
||||
inline void inc_cscc(bool_var v) { m_vars[v].m_cscc++; }
|
||||
|
||||
unsigned num_vars() const { return m_vars.size() - 1; } // var index from 1 to num_vars
|
||||
|
||||
|
||||
int_vector time_stamp; // the flip time stamp
|
||||
int_vector cscc; // how many times its constraint state configure changes since its last flip
|
||||
vector<bool_var_vector> var_neighbor; // all of its neighborhoods variable
|
||||
|
||||
/* TBD: other scores */
|
||||
|
||||
struct constraint {
|
||||
unsigned m_k;
|
||||
int m_slack;
|
||||
svector<literal> m_literals;
|
||||
constraint(unsigned k) : m_k(k), m_slack(0) {}
|
||||
unsigned size() const { return m_literals.size(); }
|
||||
literal const& operator[](unsigned idx) const { return m_literals[idx]; }
|
||||
};
|
||||
|
||||
vector<constraint> m_constraints;
|
||||
|
||||
// terms arrays
|
||||
// vector<svector<term> > constraint_term; // constraint_term[i][j] means the j'th term of constraint i
|
||||
|
||||
inline bool is_pos(literal t) const { return !t.sign(); }
|
||||
|
||||
// parameters of the instance
|
||||
unsigned num_constraints() const { return m_constraints.size(); } // constraint index from 1 to num_constraint
|
||||
|
||||
// information about the constraints
|
||||
int_vector constraint_k; // the right side k of a constraint
|
||||
int_vector constraint_slack; // =constraint_k[i]-true_terms[i], if >=0 then sat
|
||||
//int_vector nb_slack; // constraint_k - ob_var(same in ob) - none_ob_true_terms_count. if < 0: some ob var might be flipped to false, result in an ob decreasing
|
||||
//bool_vector has_true_ob_terms;
|
||||
// int_vector constraint_k; // the right side k of a constraint
|
||||
// int_vector constraint_slack; // =constraint_k[i]-true_terms[i], if >=0 then sat
|
||||
|
||||
// int_vector nb_slack; // constraint_k - ob_var(same in ob) - none_ob_true_terms_count. if < 0: some ob var might be flipped to false, result in an ob decreasing
|
||||
// bool_vector has_true_ob_terms;
|
||||
|
||||
// unsat constraint stack
|
||||
int_vector m_unsat_stack; // store all the unsat constraits
|
||||
|
@ -129,28 +146,26 @@ namespace sat {
|
|||
int_vector goodvar_stack;
|
||||
|
||||
// information about solution
|
||||
bool_vector cur_solution; // the current solution
|
||||
int objective_value; // the objective function value corresponds to the current solution
|
||||
bool_vector best_solution; // the best solution so far
|
||||
bool_vector cur_solution; // the current solution
|
||||
int objective_value; // the objective function value corresponds to the current solution
|
||||
bool_vector best_solution; // the best solution so far
|
||||
int best_objective_value = -1; // the objective value corresponds to the best solution so far
|
||||
// for non-known instance, set as maximal
|
||||
int best_known_value = INT_MAX; // best known value for this instance
|
||||
int best_known_value = INT_MAX; // best known value for this instance
|
||||
|
||||
// cutoff
|
||||
int cutoff_time = 1; // seconds
|
||||
unsigned max_steps = 2000000000; // < 2147483647
|
||||
int cutoff_time = 1; // seconds
|
||||
unsigned max_steps = 2000000000; // < 2147483647
|
||||
clock_t start, stop;
|
||||
double best_time;
|
||||
|
||||
// for tuning
|
||||
int s_id = 0; // strategy id
|
||||
int s_id = 0; // strategy id
|
||||
|
||||
|
||||
void init();
|
||||
|
||||
void reinit();
|
||||
void reinit_orig();
|
||||
|
||||
void init_cur_solution();
|
||||
void init_slack();
|
||||
void init_scores();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue