mirror of
https://github.com/Z3Prover/z3
synced 2025-04-08 18:31:49 +00:00
add init_model, global m_delta, get_value, get_ivalue to push model maintainance into lar_solver #4740
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
ab199dedf9
commit
ee12e3fb52
File diff suppressed because it is too large
Load diff
|
@ -137,11 +137,8 @@ class lar_solver : public column_namer {
|
|||
|
||||
inline void clear_columns_with_changed_bounds() { m_columns_with_changed_bounds.clear(); }
|
||||
inline void increase_by_one_columns_with_changed_bounds() { m_columns_with_changed_bounds.increase_size_by_one(); }
|
||||
inline void insert_to_columns_with_changed_bounds(unsigned j) {
|
||||
m_columns_with_changed_bounds.insert(j);
|
||||
}
|
||||
inline void insert_to_columns_with_changed_bounds(unsigned j) { m_columns_with_changed_bounds.insert(j); }
|
||||
|
||||
|
||||
void update_column_type_and_bound_check_on_equal(unsigned j, lconstraint_kind kind, const mpq & right_side, constraint_index constr_index, unsigned&);
|
||||
void update_column_type_and_bound(unsigned j, lconstraint_kind kind, const mpq & right_side, constraint_index constr_index);
|
||||
void update_column_type_and_bound_with_ub(var_index j, lconstraint_kind kind, const mpq & right_side, constraint_index constr_index);
|
||||
|
@ -289,6 +286,11 @@ class lar_solver : public column_namer {
|
|||
void collect_rounded_rows_to_fix();
|
||||
void register_normalized_term(const lar_term&, lpvar);
|
||||
void deregister_normalized_term(const lar_term&);
|
||||
|
||||
mutable std::unordered_set<impq> m_set_of_different_pairs;
|
||||
mutable std::unordered_set<mpq> m_set_of_different_singles;
|
||||
mutable mpq m_delta;
|
||||
|
||||
public:
|
||||
const map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>>& fixed_var_table_int() const {
|
||||
return m_fixed_var_table_int;
|
||||
|
@ -520,6 +522,10 @@ public:
|
|||
std::ostream& print_constraint_indices_only(const lar_base_constraint * c, std::ostream & out) const;
|
||||
std::ostream& print_implied_bound(const implied_bound& be, std::ostream & out) const;
|
||||
std::ostream& print_values(std::ostream& out) const;
|
||||
bool init_model() const;
|
||||
mpq get_value(column_index const& j) const;
|
||||
mpq get_value(tv const& t) const;
|
||||
impq get_ivalue(tv const& t) const;
|
||||
void get_model(std::unordered_map<var_index, mpq> & variable_values) const;
|
||||
void get_rid_of_inf_eps();
|
||||
void get_model_do_not_care_about_diff_vars(std::unordered_map<var_index, mpq> & variable_values) const;
|
||||
|
@ -615,6 +621,7 @@ public:
|
|||
inline const vector<unsigned> & r_nbasis() const { return m_mpq_lar_core_solver.r_nbasis(); }
|
||||
inline bool column_is_real(unsigned j) const { return !column_is_int(j); }
|
||||
lp_status get_status() const;
|
||||
bool has_changed_columns() const { return !m_columns_with_changed_bounds.empty(); }
|
||||
void set_status(lp_status s);
|
||||
lp_status solve();
|
||||
void fill_explanation_from_crossed_bounds_column(explanation & evidence) const;
|
||||
|
@ -631,8 +638,8 @@ public:
|
|||
inline const static_matrix<mpq, impq> & A_r() const { return m_mpq_lar_core_solver.m_r_A; }
|
||||
// columns
|
||||
bool column_is_int(column_index const& j) const { return column_is_int((unsigned)j); }
|
||||
const impq& get_value(column_index const& j) const { return get_column_value(j); }
|
||||
const impq& get_column_value(unsigned j) const { return m_mpq_lar_core_solver.m_r_x[j]; }
|
||||
const impq& get_ivalue(column_index const& j) const { return get_column_value(j); }
|
||||
const impq& get_column_value(column_index const& j) const { return m_mpq_lar_core_solver.m_r_x[j]; }
|
||||
inline
|
||||
var_index external_to_local(unsigned j) const {
|
||||
var_index local_j;
|
||||
|
|
|
@ -36,6 +36,20 @@ typedef unsigned lpvar;
|
|||
const lpvar null_lpvar = UINT_MAX;
|
||||
const constraint_index null_ci = UINT_MAX;
|
||||
|
||||
class column_index {
|
||||
unsigned m_index;
|
||||
friend class lar_solver;
|
||||
friend class lar_term;
|
||||
friend nla::core;
|
||||
|
||||
operator unsigned() const { return m_index; }
|
||||
|
||||
public:
|
||||
column_index(unsigned j): m_index(j) {}
|
||||
unsigned index() const { return m_index; }
|
||||
bool is_null() const { return m_index == null_lpvar; }
|
||||
};
|
||||
|
||||
|
||||
// index that comes from term or variable.
|
||||
class tv {
|
||||
|
@ -49,6 +63,7 @@ public:
|
|||
|
||||
// retrieve the identifier associated with tv
|
||||
unsigned id() const { return unmask_term(m_index); }
|
||||
column_index column() const { SASSERT(is_var()); return column_index(id()); }
|
||||
|
||||
// retrieve the raw index.
|
||||
unsigned index() const { return m_index; }
|
||||
|
@ -74,20 +89,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class column_index {
|
||||
unsigned m_index;
|
||||
friend class lar_solver;
|
||||
friend class lar_term;
|
||||
friend nla::core;
|
||||
|
||||
operator unsigned() const { return m_index; }
|
||||
|
||||
public:
|
||||
column_index(unsigned j): m_index(j) {}
|
||||
unsigned index() const { return m_index; }
|
||||
bool is_null() const { return m_index == null_lpvar; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, lp::tv const& t) {
|
||||
|
|
|
@ -231,7 +231,6 @@ namespace euf {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void solver::get_antecedents(literal l, constraint& j, literal_vector& r, bool probing) {
|
||||
expr* e = nullptr;
|
||||
euf::enode* n = nullptr;
|
||||
|
|
|
@ -1474,6 +1474,7 @@ public:
|
|||
}
|
||||
else {
|
||||
auto I = m_variable_values.find(t2.index());
|
||||
std::cout << (I == E) << "\n";
|
||||
if (I != E)
|
||||
result += I->second * coeff;
|
||||
}
|
||||
|
@ -1619,7 +1620,7 @@ public:
|
|||
IF_VERBOSE(12, verbose_stream() << "final-check " << lp().get_status() << "\n");
|
||||
lbool is_sat = l_true;
|
||||
SASSERT(lp().ax_is_correct());
|
||||
if (lp().get_status() != lp::lp_status::OPTIMAL) {
|
||||
if (lp().get_status() != lp::lp_status::OPTIMAL || lp().has_changed_columns()) {
|
||||
is_sat = make_feasible();
|
||||
}
|
||||
final_check_status st = FC_DONE;
|
||||
|
|
Loading…
Reference in a new issue