From 906d52ca1c87f3475bfabd859e1db33af0bbf750 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Fri, 13 Mar 2020 11:31:52 -0700 Subject: [PATCH] accept term indices as columns in some lar_solver queries Signed-off-by: Lev Nachmanson --- src/math/lp/lar_solver.cpp | 2 ++ src/math/lp/lar_solver.h | 9 +++++++++ src/math/lp/nla_core.cpp | 3 +-- src/math/lp/nla_monotone_lemmas.cpp | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/math/lp/lar_solver.cpp b/src/math/lp/lar_solver.cpp index 34ec556b7..6f733da27 100644 --- a/src/math/lp/lar_solver.cpp +++ b/src/math/lp/lar_solver.cpp @@ -203,6 +203,8 @@ void lar_solver::calculate_implied_bounds_for_row(unsigned i, lp_bound_propagato } unsigned lar_solver::adjust_column_index_to_term_index(unsigned j) const { + if (is_term(j)) + return j; unsigned ext_var_or_term = m_var_register.local_to_external(j); return ext_var_or_term < m_terms_start_index ? j : ext_var_or_term; } diff --git a/src/math/lp/lar_solver.h b/src/math/lp/lar_solver.h index b142f3082..2cac79708 100644 --- a/src/math/lp/lar_solver.h +++ b/src/math/lp/lar_solver.h @@ -138,6 +138,9 @@ public: } const mpq& get_column_value_rational(unsigned j) const { + if (is_term(j)) { + j = m_var_register.external_to_local(j); + } return m_mpq_lar_core_solver.m_r_x[j].x; } @@ -565,10 +568,16 @@ public: } constraint_index get_column_upper_bound_witness(unsigned j) const { + if (is_term(j)) { + j = m_var_register.external_to_local(j); + } return m_columns_to_ul_pairs()[j].upper_bound_witness(); } constraint_index get_column_lower_bound_witness(unsigned j) const { + if (is_term(j)) { + j = m_var_register.external_to_local(j); + } return m_columns_to_ul_pairs()[j].lower_bound_witness(); } diff --git a/src/math/lp/nla_core.cpp b/src/math/lp/nla_core.cpp index e3adfd7fa..6f4a4993c 100644 --- a/src/math/lp/nla_core.cpp +++ b/src/math/lp/nla_core.cpp @@ -74,8 +74,7 @@ lp::lar_term core::subs_terms_to_columns(const lp::lar_term& t) const { } bool core::ineq_holds(const ineq& n) const { - lp::lar_term t = subs_terms_to_columns(n.term()); - return compare_holds(value(t), n.cmp(), n.rs()); + return compare_holds(value(n.term()), n.cmp(), n.rs()); } bool core::lemma_holds(const lemma& l) const { diff --git a/src/math/lp/nla_monotone_lemmas.cpp b/src/math/lp/nla_monotone_lemmas.cpp index 2d1dd7f57..2346af54c 100644 --- a/src/math/lp/nla_monotone_lemmas.cpp +++ b/src/math/lp/nla_monotone_lemmas.cpp @@ -90,7 +90,8 @@ void monotone::monotonicity_lemma(monic const& m) { } void monotone::monotonicity_lemma_gt(const monic& m, const rational& prod_val) { - TRACE("nla_solver", tout << "prod_val = " << prod_val << "\n";); + TRACE("nla_solver", tout << "prod_val = " << prod_val << "\n"; + tout << "m = "; c().print_monic_with_vars(m, tout);); add_empty_lemma(); for (lpvar j : m.vars()) { c().add_abs_bound(j, llc::GT);