mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
change the signature of int_solver::check by adding explanation* parameter
Signed-off-by: Lev <levnach@hotmail.com>
This commit is contained in:
parent
9dbb56fdfc
commit
54f447d118
9 changed files with 61 additions and 36 deletions
|
@ -26,7 +26,7 @@ namespace lp {
|
|||
class gomory::imp {
|
||||
lar_term & m_t; // the term to return in the cut
|
||||
mpq & m_k; // the right side of the cut
|
||||
explanation& m_ex; // the conflict explanation
|
||||
explanation* m_ex; // the conflict explanation
|
||||
unsigned m_inf_col; // a basis column which has to be an integer but has a non integral value
|
||||
const row_strip<mpq>& m_row;
|
||||
const int_solver& m_int_solver;
|
||||
|
@ -58,7 +58,7 @@ class gomory::imp {
|
|||
new_a = m_fj <= m_one_minus_f ? m_fj / m_one_minus_f : ((1 - m_fj) / m_f);
|
||||
lp_assert(new_a.is_pos());
|
||||
m_k.addmul(new_a, lower_bound(j).x);
|
||||
m_ex.push_justification(column_lower_bound_constraint(j));
|
||||
m_ex->push_justification(column_lower_bound_constraint(j));
|
||||
}
|
||||
else {
|
||||
lp_assert(at_upper(j));
|
||||
|
@ -66,7 +66,7 @@ class gomory::imp {
|
|||
new_a = - (m_fj <= m_f ? m_fj / m_f : ((1 - m_fj) / m_one_minus_f));
|
||||
lp_assert(new_a.is_neg());
|
||||
m_k.addmul(new_a, upper_bound(j).x);
|
||||
m_ex.push_justification(column_upper_bound_constraint(j));
|
||||
m_ex->push_justification(column_upper_bound_constraint(j));
|
||||
}
|
||||
m_t.add_coeff_var(new_a, j);
|
||||
m_lcm_den = lcm(m_lcm_den, denominator(new_a));
|
||||
|
@ -85,7 +85,7 @@ class gomory::imp {
|
|||
}
|
||||
m_k.addmul(new_a, lower_bound(j).x); // is it a faster operation than
|
||||
// k += lower_bound(j).x * new_a;
|
||||
m_ex.push_justification(column_lower_bound_constraint(j));
|
||||
m_ex->push_justification(column_lower_bound_constraint(j));
|
||||
}
|
||||
else {
|
||||
lp_assert(at_upper(j));
|
||||
|
@ -96,7 +96,7 @@ class gomory::imp {
|
|||
new_a = a / m_one_minus_f;
|
||||
}
|
||||
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));
|
||||
m_ex->push_justification(column_upper_bound_constraint(j));
|
||||
}
|
||||
TRACE("gomory_cut_detail_real", tout << a << "*v" << j << " k: " << m_k << "\n";);
|
||||
m_t.add_coeff_var(new_a, j);
|
||||
|
@ -314,7 +314,7 @@ public:
|
|||
return lia_move::cut;
|
||||
}
|
||||
|
||||
imp(lar_term & t, mpq & k, explanation& ex, unsigned basic_inf_int_j, const row_strip<mpq>& row, const int_solver& int_slv ) :
|
||||
imp(lar_term & t, mpq & k, explanation* ex, unsigned basic_inf_int_j, const row_strip<mpq>& row, const int_solver& int_slv ) :
|
||||
m_t(t),
|
||||
m_k(k),
|
||||
m_ex(ex),
|
||||
|
@ -331,7 +331,7 @@ lia_move gomory::create_cut() {
|
|||
return m_imp->create_cut();
|
||||
}
|
||||
|
||||
gomory::gomory(lar_term & t, mpq & k, explanation& ex, unsigned basic_inf_int_j, const row_strip<mpq>& row, const int_solver& s) {
|
||||
gomory::gomory(lar_term & t, mpq & k, explanation* ex, unsigned basic_inf_int_j, const row_strip<mpq>& row, const int_solver& s) {
|
||||
m_imp = alloc(imp, t, k, ex, basic_inf_int_j, row, s);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class gomory {
|
|||
class imp;
|
||||
imp *m_imp;
|
||||
public :
|
||||
gomory(lar_term & t, mpq & k, explanation& ex, unsigned basic_inf_int_j, const row_strip<mpq>& row, const int_solver& s);
|
||||
gomory(lar_term & t, mpq & k, explanation* ex, unsigned basic_inf_int_j, const row_strip<mpq>& row, const int_solver& s);
|
||||
lia_move create_cut();
|
||||
~gomory();
|
||||
};
|
||||
|
|
|
@ -186,7 +186,7 @@ public:
|
|||
|
||||
bool overflow() const { return m_overflow; }
|
||||
|
||||
lia_move create_cut(lar_term& t, mpq& k, explanation& ex, bool & upper, const vector<mpq> & x0) {
|
||||
lia_move create_cut(lar_term& t, mpq& k, explanation* ex, bool & upper, const vector<mpq> & x0) {
|
||||
// we suppose that x0 has at least one non integer element
|
||||
(void)x0;
|
||||
|
||||
|
|
|
@ -382,9 +382,9 @@ lia_move int_solver::make_hnf_cut() {
|
|||
);
|
||||
lp_assert(current_solution_is_inf_on_cut());
|
||||
settings().st().m_hnf_cuts++;
|
||||
m_ex.clear();
|
||||
m_ex->clear();
|
||||
for (unsigned i : m_hnf_cutter.constraints_for_explanation()) {
|
||||
m_ex.push_justification(i);
|
||||
m_ex->push_justification(i);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
@ -412,7 +412,8 @@ lia_move int_solver::check() {
|
|||
|
||||
m_t.clear();
|
||||
m_k.reset();
|
||||
m_ex.clear();
|
||||
m_ex = e;
|
||||
m_ex->clear();
|
||||
m_upper = false;
|
||||
lia_move r;
|
||||
|
||||
|
@ -596,8 +597,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) {
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
unsigned m_number_of_calls;
|
||||
lar_term m_t; // the term to return in the cut
|
||||
mpq m_k; // the right side of the cut
|
||||
explanation m_ex; // the conflict explanation
|
||||
explanation *m_ex; // the conflict explanation
|
||||
bool m_upper; // we have a cut m_t*x <= k if m_upper is true nad m_t*x >= k otherwise
|
||||
hnf_cutter m_hnf_cutter;
|
||||
// methods
|
||||
|
@ -49,10 +49,9 @@ 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();
|
||||
lia_move check(explanation *);
|
||||
lar_term const& get_term() const { return m_t; }
|
||||
mpq const& get_offset() const { return m_k; }
|
||||
explanation const& get_explanation() const { return m_ex; }
|
||||
bool is_upper() const { return m_upper; }
|
||||
lia_move check_wrapper(lar_term& t, mpq& k, explanation& ex);
|
||||
bool is_base(unsigned j) const;
|
||||
|
|
|
@ -831,12 +831,36 @@ struct solver::imp {
|
|||
m_expl->clear();
|
||||
m_lemma->clear();
|
||||
}
|
||||
|
||||
bool order_lemma_on_factor_equiv_and_other_mon_factor(unsigned i_f,
|
||||
unsigned o_i_mon, unsigned e_j, unsigned i_mon, const factorization& f, unsigned k, const rational& sign) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool order_lemma_on_factor_equiv_and_other_mon(unsigned o_i_mon, unsigned e_j, unsigned i_mon, const factorization& f, unsigned k, const rational& sign) {
|
||||
NOT_IMPLEMENTED_YET();
|
||||
if (o_i_mon == i_mon) return false;
|
||||
const monomial & o_m = m_monomials[o_i_mon];
|
||||
svector<lpvar> o_key;
|
||||
for (unsigned j : o_m) {
|
||||
if (j != e_j) {
|
||||
o_key.push_back(j);
|
||||
}
|
||||
}
|
||||
|
||||
rational o_sign(1);
|
||||
o_key = reduce_monomial_to_rooted(o_key, o_sign);
|
||||
auto it = m_rooted_monomials.find(o_key);
|
||||
if (it == m_rooted_monomials.end())
|
||||
return false;
|
||||
for (const index_with_sign& i_s : it->second) {
|
||||
if (order_lemma_on_factor_equiv_and_other_mon_factor(i_s.var(), o_i_mon, e_j, i_mon, f, k, sign * o_sign * i_s.sign()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// here e_j is equivalent to f[k],
|
||||
|
||||
// f is a factorization of m_monomials[i_mon]
|
||||
// here e_j is equivalent to f[k],
|
||||
bool order_lemma_on_factor_and_equiv(unsigned e_j, unsigned i_mon, const factorization& f, unsigned k, const rational& sign) {
|
||||
lpvar j = f[k];
|
||||
for (unsigned i : m_monomials_containing_var[j]) {
|
||||
|
|
|
@ -36,6 +36,8 @@ struct index_with_sign {
|
|||
bool operator==(const index_with_sign& b) {
|
||||
return m_i == b.m_i && m_sign == b.m_sign;
|
||||
}
|
||||
unsigned var() const { return m_i; }
|
||||
const rational& sign() const { return m_sign; }
|
||||
};
|
||||
|
||||
struct rat_hash {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue