3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-22 05:43:39 +00:00

do not add row with free basic vars in grobner, more tracing

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2019-12-03 16:56:41 -08:00
parent 6752463a8c
commit 0b1023c2c7
7 changed files with 30 additions and 3 deletions

View file

@ -800,6 +800,11 @@ public:
m_r_solver.m_lower_bounds[j] == m_r_solver.m_upper_bounds[j]); m_r_solver.m_lower_bounds[j] == m_r_solver.m_upper_bounds[j]);
} }
bool column_is_free(unsigned j) const {
return m_column_types()[j] == column_type::free_column;
}
const impq & lower_bound(unsigned j) const { const impq & lower_bound(unsigned j) const {
lp_assert(m_column_types()[j] == column_type::fixed || lp_assert(m_column_types()[j] == column_type::fixed ||
m_column_types()[j] == column_type::boxed || m_column_types()[j] == column_type::boxed ||

View file

@ -1693,6 +1693,10 @@ bool lar_solver::column_is_fixed(unsigned j) const {
return m_mpq_lar_core_solver.column_is_fixed(j); return m_mpq_lar_core_solver.column_is_fixed(j);
} }
bool lar_solver::column_is_free(unsigned j) const {
return m_mpq_lar_core_solver.column_is_free(j);
}
// below is the initialization functionality of lar_solver // below is the initialization functionality of lar_solver
bool lar_solver::strategy_is_undecided() const { bool lar_solver::strategy_is_undecided() const {

View file

@ -151,6 +151,7 @@ public:
bool is_term(var_index j) const; bool is_term(var_index j) const;
bool column_is_fixed(unsigned j) const; bool column_is_fixed(unsigned j) const;
bool column_is_free(unsigned j) const;
public: public:
// init region // init region

View file

@ -141,8 +141,10 @@ nex * common::nexvar(const rational & coeff, lpvar j, nex_creator& cn, bool fixe
for (lpvar k : m.vars()) { for (lpvar k : m.vars()) {
if (fixed_as_scalars && c().var_is_fixed(k)) { if (fixed_as_scalars && c().var_is_fixed(k)) {
auto & b = c().m_lar_solver.get_lower_bound(k).x; auto & b = c().m_lar_solver.get_lower_bound(k).x;
if (b.is_zero()) if (b.is_zero()) {
TRACE("nla_grobner", tout << "[" << k << "] is fixed to zero\n";);
return nullptr; return nullptr;
}
e->coeff() *= b; e->coeff() *= b;
continue; continue;
} }

View file

@ -642,6 +642,10 @@ bool core:: var_is_fixed(lpvar j) const {
return m_lar_solver.column_is_fixed(j); return m_lar_solver.column_is_fixed(j);
} }
bool core:: var_is_free(lpvar j) const {
return m_lar_solver.column_is_free(j);
}
std::ostream & core::print_ineq(const ineq & in, std::ostream & out) const { std::ostream & core::print_ineq(const ineq & in, std::ostream & out) const {
m_lar_solver.print_term_as_indices(in.m_term, out); m_lar_solver.print_term_as_indices(in.m_term, out);
out << " " << lconstraint_kind_string(in.m_cmp) << " " << in.m_rs; out << " " << lconstraint_kind_string(in.m_cmp) << " " << in.m_rs;

View file

@ -287,6 +287,7 @@ public:
bool var_is_fixed_to_val(lpvar j, const rational& v) const; bool var_is_fixed_to_val(lpvar j, const rational& v) const;
bool var_is_fixed(lpvar j) const; bool var_is_fixed(lpvar j) const;
bool var_is_free(lpvar j) const;
bool find_canonical_monic_of_vars(const svector<lpvar>& vars, lpvar & i) const; bool find_canonical_monic_of_vars(const svector<lpvar>& vars, lpvar & i) const;
bool is_canonical_monic(lpvar) const; bool is_canonical_monic(lpvar) const;

View file

@ -34,11 +34,19 @@ bool nla_grobner::internalize_gb_eq(equation* ) {
void nla_grobner::add_var_and_its_factors_to_q_and_collect_new_rows(lpvar j, std::queue<lpvar> & q) { void nla_grobner::add_var_and_its_factors_to_q_and_collect_new_rows(lpvar j, std::queue<lpvar> & q) {
SASSERT(!c().active_var_set_contains(j)); SASSERT(!c().active_var_set_contains(j));
TRACE("grobner", tout << "j = " << j << ", "; c().print_var(j, tout) << "\n";);
const auto& matrix = c().m_lar_solver.A_r(); const auto& matrix = c().m_lar_solver.A_r();
c().insert_to_active_var_set(j); c().insert_to_active_var_set(j);
const auto & core_slv = c().m_lar_solver.m_mpq_lar_core_solver;
for (auto & s : matrix.m_columns[j]) { for (auto & s : matrix.m_columns[j]) {
unsigned row = s.var(); unsigned row = s.var();
if (m_rows.contains(row)) continue; if (m_rows.contains(row)) continue;
lpvar basic_in_row = core_slv.m_r_basis[row];
if (c().var_is_free(basic_in_row)) {
TRACE("grobner", tout << "ignore the row " << row << " with the free basic var\n";);
continue; // mimic the behavior of the legacy solver
}
m_rows.insert(row); m_rows.insert(row);
for (auto& rc : matrix.m_rows[row]) { for (auto& rc : matrix.m_rows[row]) {
if (c().active_var_set_contains(rc.var())) if (c().active_var_set_contains(rc.var()))
@ -159,6 +167,7 @@ void nla_grobner::init() {
find_nl_cluster(); find_nl_cluster();
c().clear_and_resize_active_var_set(); c().clear_and_resize_active_var_set();
TRACE("grobner", tout << "m_rows.size() = " << m_rows.size() << "\n";);
for (unsigned i : m_rows) { for (unsigned i : m_rows) {
add_row(i); add_row(i);
} }
@ -730,7 +739,7 @@ bool nla_grobner::done() const {
|| ||
canceled() canceled()
|| ||
m_reported > 10 m_reported > 100000
|| ||
m_conflict) { m_conflict) {
TRACE("grobner", tout << "done()\n";); TRACE("grobner", tout << "done()\n";);
@ -777,6 +786,7 @@ bool nla_grobner::try_to_modify_eqs(ptr_vector<equation>& eqs, unsigned& next_we
void nla_grobner::grobner_lemmas() { void nla_grobner::grobner_lemmas() {
c().lp_settings().stats().m_grobner_calls++; c().lp_settings().stats().m_grobner_calls++;
init(); init();
ptr_vector<equation> eqs; ptr_vector<equation> eqs;