3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-07-28 18:03:13 -07:00
commit 1cb3f7c792
27 changed files with 340 additions and 272 deletions

View file

@ -50,7 +50,6 @@ public:
// main function to check that the solution provided by lar_solver is valid for integral values,
// or provide a way of how it can be adjusted.
lia_move check(lar_term& t, mpq& k, explanation& ex, bool & upper);
lia_move check_(lar_term& t, mpq& k, explanation& ex, bool & upper);
bool move_non_basic_column_to_bounds(unsigned j);
lia_move check_wrapper(lar_term& t, mpq& k, explanation& ex);
bool is_base(unsigned j) const;

View file

@ -540,11 +540,13 @@ lp_status lar_solver::maximize_term(unsigned ext_j,
if (m_int_solver->is_base(j)) {
if (!remove_from_basis(j)) { // consider a special version of remove_from_basis that would not remove inf_int columns
m_mpq_lar_core_solver.m_r_x = backup;
term_max = prev_value;
return lp_status::FEASIBLE; // it should not happen
}
}
m_int_solver->patch_nbasic_column(j, false);
if (!column_value_is_integer(j)) {
term_max = prev_value;
m_mpq_lar_core_solver.m_r_x = backup;
return lp_status::FEASIBLE;
}

View file

@ -247,6 +247,8 @@ public:
void calculate_implied_bounds_for_row(unsigned i, bound_propagator & bp);
unsigned adjust_column_index_to_term_index(unsigned j) const;
var_index local2external(var_index idx) const { return m_var_register.local_to_external(idx); }
void propagate_bounds_on_a_term(const lar_term& t, bound_propagator & bp, unsigned term_offset);

View file

@ -28,4 +28,25 @@ enum class lia_move {
undef,
unsat
};
inline std::string lia_move_to_string(lia_move m) {
switch (m) {
case lia_move::sat:
return "sat";
case lia_move::branch:
return "branch";
case lia_move::cut:
return "cut";
case lia_move::conflict:
return "conflict";
case lia_move::continue_with_check:
return "continue_with_check";
case lia_move::undef:
return "undef";
case lia_move::unsat:
return "unsat";
default:
lp_assert(false);
};
return "strange";
}
}

View file

@ -24,11 +24,12 @@ namespace nra {
lp::lar_solver& s;
reslimit& m_limit;
params_ref m_params;
u_map<polynomial::var> m_lp2nl; // map from lar_solver variables to nlsat::solver variables
u_map<polynomial::var> m_lp2nl; // map from lar_solver variables to nlsat::solver variables
scoped_ptr<nlsat::solver> m_nlsat;
scoped_ptr<scoped_anum> m_zero;
vector<mon_eq> m_monomials;
unsigned_vector m_monomials_lim;
mutable std::unordered_map<lp::var_index, rational> m_variable_values; // current model
mutable std::unordered_map<lp::var_index, rational> m_variable_values; // current model
imp(lp::lar_solver& s, reslimit& lim, params_ref const& p):
s(s),
@ -90,6 +91,7 @@ namespace nra {
lbool check(lp::explanation_t& ex) {
SASSERT(need_check());
m_nlsat = alloc(nlsat::solver, m_limit, m_params, false);
m_zero = alloc(scoped_anum, am());
m_lp2nl.reset();
vector<nlsat::assumption, false> core;
@ -208,12 +210,17 @@ namespace nra {
if (!m_lp2nl.find(v, r)) {
r = m_nlsat->mk_var(is_int(v));
m_lp2nl.insert(v, r);
TRACE("arith", tout << "v" << v << " := x" << r << "\n";);
}
return r;
}
nlsat::anum const& value(lp::var_index v) const {
return m_nlsat->value(m_lp2nl.find(v));
polynomial::var pv;
if (m_lp2nl.find(v, pv))
return m_nlsat->value(pv);
else
return *m_zero;
}
nlsat::anum_manager& am() {