mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
rebase with z3prover
Signed-off-by: Lev <levnach@hotmail.com>
This commit is contained in:
parent
4ca0ca3ce8
commit
d301a9c403
8 changed files with 77 additions and 92 deletions
|
@ -69,8 +69,8 @@ class gomory::imp {
|
|||
m_ex.push_justification(column_upper_bound_constraint(j));
|
||||
}
|
||||
m_t.add_coeff_var(new_a, j);
|
||||
lcm_den = lcm(lcm_den, denominator(new_a));
|
||||
TRACE("gomory_cut_detail", tout << "new_a = " << new_a << ", k = " << m_k << ", lcm_den = " << lcm_den << "\n";);
|
||||
m_lcm_den = lcm(m_lcm_den, denominator(new_a));
|
||||
TRACE("gomory_cut_detail", tout << "new_a = " << new_a << ", k = " << m_k << ", lcm_den = " << m_lcm_den << "\n";);
|
||||
}
|
||||
|
||||
void real_case_in_gomory_cut(const mpq & a, unsigned j) {
|
||||
|
@ -98,8 +98,8 @@ class gomory::imp {
|
|||
m_k.addmul(new_a, upper_bound(j).x); // k += upper_bound(j).x * new_a;
|
||||
m_ex.push_justification(column_upper_bound_constraint(j));
|
||||
}
|
||||
TRACE("gomory_cut_detail_real", tout << a << "*v" << x_j << " k: " << m_k << "\n";);
|
||||
m_t.add_coeff_var(new_a, x_j);
|
||||
TRACE("gomory_cut_detail_real", tout << a << "*v" << j << " k: " << m_k << "\n";);
|
||||
m_t.add_coeff_var(new_a, j);
|
||||
}
|
||||
|
||||
lia_move report_conflict_from_gomory_cut() {
|
||||
|
|
|
@ -118,21 +118,6 @@ constraint_index int_solver::column_upper_bound_constraint(unsigned j) const {
|
|||
return m_lar_solver->get_column_upper_bound_witness(j);
|
||||
}
|
||||
|
||||
bool int_solver::current_solution_is_inf_on_cut() const {
|
||||
const auto & x = m_lar_solver->m_mpq_lar_core_solver.m_r_x;
|
||||
impq v = m_t->apply(x);
|
||||
mpq sign = *m_upper ? one_of_type<mpq>() : -one_of_type<mpq>();
|
||||
CTRACE("current_solution_is_inf_on_cut", v * sign <= (*m_k) * sign,
|
||||
tout << "m_upper = " << *m_upper << std::endl;
|
||||
tout << "v = " << v << ", k = " << (*m_k) << std::endl;
|
||||
);
|
||||
return v * sign > (*m_k) * sign;
|
||||
}
|
||||
|
||||
constraint_index int_solver::column_lower_bound_constraint(unsigned j) const {
|
||||
return m_lar_solver->get_column_lower_bound_witness(j);
|
||||
}
|
||||
|
||||
bool int_solver::current_solution_is_inf_on_cut() const {
|
||||
const auto & x = m_lar_solver->m_mpq_lar_core_solver.m_r_x;
|
||||
impq v = m_t.apply(x);
|
||||
|
@ -144,6 +129,10 @@ bool int_solver::current_solution_is_inf_on_cut() const {
|
|||
return v * sign > m_k * sign;
|
||||
}
|
||||
|
||||
constraint_index int_solver::column_lower_bound_constraint(unsigned j) const {
|
||||
return m_lar_solver->get_column_lower_bound_witness(j);
|
||||
}
|
||||
|
||||
lia_move int_solver::mk_gomory_cut( unsigned inf_col, const row_strip<mpq> & row) {
|
||||
|
||||
lp_assert(column_is_int_inf(inf_col));
|
||||
|
@ -186,11 +175,9 @@ typedef monomial mono;
|
|||
// this will allow to enable and disable tracking of the pivot rows
|
||||
struct check_return_helper {
|
||||
lar_solver * m_lar_solver;
|
||||
const lia_move & m_r;
|
||||
bool m_track_pivoted_rows;
|
||||
check_return_helper(lar_solver* ls, const lia_move& r) :
|
||||
check_return_helper(lar_solver* ls) :
|
||||
m_lar_solver(ls),
|
||||
m_r(r),
|
||||
m_track_pivoted_rows(ls->get_track_pivoted_rows())
|
||||
{
|
||||
TRACE("pivoted_rows", tout << "pivoted rows = " << ls->m_mpq_lar_core_solver.m_r_solver.m_pivoted_rows->size() << std::endl;);
|
||||
|
@ -389,8 +376,8 @@ lia_move int_solver::make_hnf_cut() {
|
|||
|
||||
if (r == lia_move::cut) {
|
||||
TRACE("hnf_cut",
|
||||
m_lar_solver->print_term(*m_t, tout << "cut:");
|
||||
tout << " <= " << *m_k << std::endl;
|
||||
m_lar_solver->print_term(m_t, tout << "cut:");
|
||||
tout << " <= " << m_k << std::endl;
|
||||
for (unsigned i : m_hnf_cutter.constraints_for_explanation()) {
|
||||
m_lar_solver->print_constraint(i, tout);
|
||||
}
|
||||
|
@ -433,7 +420,7 @@ lia_move int_solver::check() {
|
|||
|
||||
CHECK_RET(run_gcd_test());
|
||||
|
||||
check_return_helper pc(m_lar_solver, r);
|
||||
check_return_helper pc(m_lar_solver);
|
||||
|
||||
if (settings().m_int_pivot_fixed_vars_from_basis)
|
||||
m_lar_solver->pivot_fixed_vars_from_basis();
|
||||
|
@ -611,8 +598,8 @@ bool int_solver::gcd_test_for_row(static_matrix<mpq, numeric_pair<mpq>> & A, uns
|
|||
void int_solver::add_to_explanation_from_fixed_or_boxed_column(unsigned j) {
|
||||
constraint_index lc, uc;
|
||||
m_lar_solver->get_bound_constraint_witnesses_for_column(j, lc, uc);
|
||||
m_ex->push_justification(lc);
|
||||
m_ex->push_justification(uc);
|
||||
m_ex.push_justification(lc);
|
||||
m_ex.push_justification(uc);
|
||||
}
|
||||
void int_solver::fill_explanation_from_fixed_columns(const row_strip<mpq> & row) {
|
||||
for (const auto & c : row) {
|
||||
|
@ -1009,13 +996,13 @@ lia_move int_solver::create_branch_on_column(int j) {
|
|||
TRACE("check_main_int", tout << "branching" << std::endl;);
|
||||
lp_assert(m_t.is_empty());
|
||||
lp_assert(j != -1);
|
||||
m_t->add_coeff_var(mpq(1), m_lar_solver->adjust_column_index_to_term_index(j));
|
||||
m_t.add_coeff_var(mpq(1), m_lar_solver->adjust_column_index_to_term_index(j));
|
||||
if (is_free(j)) {
|
||||
m_upper = true;
|
||||
m_k = mpq(0);
|
||||
} else {
|
||||
m_upper = left_branch_is_more_narrow_than_right(j);
|
||||
m_k = *m_upper? floor(get_value(j)) : ceil(get_value(j));
|
||||
m_k = m_upper? floor(get_value(j)) : ceil(get_value(j));
|
||||
}
|
||||
|
||||
TRACE("int_solver", tout << "branching v" << j << " = " << get_value(j) << "\n";
|
||||
|
|
|
@ -77,7 +77,8 @@ struct vars_equivalence {
|
|||
unsigned size() const { return m_map.size(); }
|
||||
|
||||
void add_equivalence_maybe(const lp::lar_term *t, lpci c0, lpci c1) {
|
||||
if (t->size() != 2 || ! t->m_v.is_zero())
|
||||
SASSERT(false); // check for new terms
|
||||
if (t->size() != 2 || t->size() != 3)
|
||||
return;
|
||||
bool seen_minus = false;
|
||||
bool seen_plus = false;
|
||||
|
@ -489,7 +490,8 @@ struct solver::imp {
|
|||
}
|
||||
lp::lar_term t;
|
||||
t.add_coeff_var(rational(1), m_monomials[i_mon].var());
|
||||
t.m_v = -rs;
|
||||
SASSERT(false); // figure out the change!!!!!!
|
||||
// t.m_v = -rs;
|
||||
ineq in(kind, t);
|
||||
m_lemma->push_back(in);
|
||||
TRACE("nla_solver", print_explanation_and_lemma(tout););
|
||||
|
@ -1274,6 +1276,9 @@ struct solver::imp {
|
|||
|
||||
return l_undef;
|
||||
}
|
||||
void test() {
|
||||
std::cout << "test called\n";
|
||||
}
|
||||
}; // end of imp
|
||||
|
||||
void solver::add_monomial(lpvar v, unsigned sz, lpvar const* vs) {
|
||||
|
@ -1286,9 +1291,6 @@ lbool solver::check(lp::explanation & ex, lemma& l) {
|
|||
return m_imp->check(ex, l);
|
||||
}
|
||||
|
||||
|
||||
}; // end of imp
|
||||
|
||||
void solver::add_monomial(lpvar v, unsigned sz, lpvar const* vs) {
|
||||
m_imp->add(v, sz, vs);
|
||||
}
|
||||
|
@ -1315,4 +1317,12 @@ solver::~solver() {
|
|||
dealloc(m_imp);
|
||||
}
|
||||
|
||||
void solver::test() {
|
||||
lp::lar_solver s;
|
||||
reslimit l;
|
||||
params_ref p;
|
||||
imp i(s, l, p);
|
||||
i.test();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,5 +45,6 @@ public:
|
|||
void pop(unsigned scopes);
|
||||
bool need_check();
|
||||
lbool check(lp::explanation&, lemma&);
|
||||
static void test();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue