3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-09 09:21:56 +00:00

Centralize and document TRACE tags using X-macros (#7657)

* Introduce X-macro-based trace tag definition
- Created trace_tags.def to centralize TRACE tag definitions
- Each tag includes a symbolic name and description
- Set up enum class TraceTag for type-safe usage in TRACE macros

* Add script to generate Markdown documentation from trace_tags.def
- Python script parses trace_tags.def and outputs trace_tags.md

* Refactor TRACE_NEW to prepend TraceTag and pass enum to is_trace_enabled

* trace: improve trace tag handling system with hierarchical tagging

- Introduce hierarchical tag-class structure: enabling a tag class activates all child tags
- Unify TRACE, STRACE, SCTRACE, and CTRACE under enum TraceTag
- Implement initial version of trace_tag.def using X(tag, tag_class, description)
  (class names and descriptions to be refined in a future update)

* trace: replace all string-based TRACE tags with enum TraceTag
- Migrated all TRACE, STRACE, SCTRACE, and CTRACE macros to use enum TraceTag values instead of raw string literals

* trace : add cstring header

* trace : Add Markdown documentation generation from trace_tags.def via mk_api_doc.py

* trace : rename macro parameter 'class' to 'tag_class' and remove Unicode comment in trace_tags.h.

* trace : Add TODO comment for future implementation of tag_class activation

* trace : Disable code related to tag_class until implementation is ready (#7663).
This commit is contained in:
LeeYoungJoon 2025-05-28 22:31:25 +09:00 committed by GitHub
parent d766292dab
commit 0a93ff515d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
583 changed files with 8698 additions and 7299 deletions

View file

@ -300,7 +300,7 @@ namespace lp {
const auto& row = this->m_row;
auto explain = [row, bound_j, coeff_before_j_is_pos, is_lower_bound, strict, lar]() {
(void) strict;
TRACE("bound_analyzer", tout << "explain_bound_on_var_on_coeff, bound_j = " << bound_j << ", coeff_before_j_is_pos = " << coeff_before_j_is_pos << ", is_lower_bound = " << is_lower_bound << ", strict = " << strict << "\n";);
TRACE(bound_analyzer, tout << "explain_bound_on_var_on_coeff, bound_j = " << bound_j << ", coeff_before_j_is_pos = " << coeff_before_j_is_pos << ", is_lower_bound = " << is_lower_bound << ", strict = " << strict << "\n";);
int bound_sign = (is_lower_bound ? 1 : -1);
int j_sign = (coeff_before_j_is_pos ? 1 : -1) * bound_sign;

View file

@ -58,12 +58,12 @@ public:
void run(nex *e) {
TRACE("nla_cn", tout << *e << "\n";);
TRACE(nla_cn, tout << *e << "\n";);
SASSERT(m_nex_creator.is_simplified(*e));
m_e = e;
#ifdef Z3DEBUG
m_e_clone = m_nex_creator.clone(m_e);
TRACE("nla_cn", tout << "m_e_clone = " << * m_e_clone << "\n";);
TRACE(nla_cn, tout << "m_e_clone = " << * m_e_clone << "\n";);
#endif
vector<nex**> front;
@ -72,7 +72,7 @@ public:
static nex** pop_front(vector<nex**>& front) {
nex** c = front.back();
TRACE("nla_cn", tout << **c << "\n";);
TRACE(nla_cn, tout << **c << "\n";);
front.pop_back();
return c;
}
@ -80,7 +80,7 @@ public:
nex* extract_common_factor(nex* e) {
nex_sum* c = to_sum(e);
TRACE("nla_cn", tout << "c=" << *c << "\n"; tout << "occs:"; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
TRACE(nla_cn, tout << "c=" << *c << "\n"; tout << "occs:"; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
unsigned size = c->size();
bool have_factor = false;
for (const auto & p : m_nex_creator.occurences_map()) {
@ -100,7 +100,7 @@ public:
}
static bool has_common_factor(const nex_sum* c) {
TRACE("nla_cn", tout << "c=" << *c << "\n";);
TRACE(nla_cn, tout << "c=" << *c << "\n";);
auto & ch = *c;
auto common_vars = get_vars_of_expr(ch[0]);
for (lpvar j : common_vars) {
@ -110,7 +110,7 @@ public:
divides_the_rest = false;
}
if (divides_the_rest) {
TRACE("nla_cn_common_factor", tout << c << "\n";);
TRACE(nla_cn_common_factor, tout << c << "\n";);
return true;
}
}
@ -118,26 +118,26 @@ public:
}
bool proceed_with_common_factor(nex** c, vector<nex**>& front) {
TRACE("nla_cn", tout << "c=" << **c << "\n";);
TRACE(nla_cn, tout << "c=" << **c << "\n";);
nex* f = extract_common_factor(*c);
if (f == nullptr) {
TRACE("nla_cn", tout << "no common factor\n"; );
TRACE(nla_cn, tout << "no common factor\n"; );
return false;
}
TRACE("nla_cn", tout << "common factor f=" << *f << "\n";);
TRACE(nla_cn, tout << "common factor f=" << *f << "\n";);
nex* c_over_f = m_nex_creator.mk_div(**c, *f);
c_over_f = m_nex_creator.simplify(c_over_f);
TRACE("nla_cn", tout << "c_over_f = " << *c_over_f << std::endl;);
TRACE(nla_cn, tout << "c_over_f = " << *c_over_f << std::endl;);
nex_mul* cm;
*c = cm = m_nex_creator.mk_mul(f, c_over_f);
TRACE("nla_cn", tout << "common factor=" << *f << ", c=" << **c << "\ne = " << *m_e << "\n";);
TRACE(nla_cn, tout << "common factor=" << *f << ", c=" << **c << "\ne = " << *m_e << "\n";);
explore_expr_on_front_elem((*cm)[1].ee(), front);
return true;
}
static void push_to_front(vector<nex**>& front, nex** e) {
TRACE("nla_cn", tout << **e << "\n";);
TRACE(nla_cn, tout << **e << "\n";);
front.push_back(e);
}
@ -159,7 +159,7 @@ public:
}
void explore_expr_on_front_elem_vars(nex** c, vector<nex**>& front, const svector<lpvar> & vars) {
TRACE("nla_cn", tout << "save c=" << **c << "; front:"; print_front(front, tout) << "\n";);
TRACE(nla_cn, tout << "save c=" << **c << "; front:"; print_front(front, tout) << "\n";);
nex* copy_of_c = *c;
auto copy_of_front = copy_front(front);
int alloc_size = m_nex_creator.size();
@ -173,11 +173,11 @@ public:
explore_of_expr_on_sum_and_var(c, j, front);
if (m_done)
return;
TRACE("nla_cn", tout << "before restore c=" << **c << "\nm_e=" << *m_e << "\n";);
TRACE(nla_cn, tout << "before restore c=" << **c << "\nm_e=" << *m_e << "\n";);
*c = copy_of_c;
restore_front(copy_of_front, front);
pop_allocated(alloc_size);
TRACE("nla_cn", tout << "after restore c=" << **c << "\nm_e=" << *m_e << "\n";);
TRACE(nla_cn, tout << "after restore c=" << **c << "\nm_e=" << *m_e << "\n";);
}
}
@ -202,7 +202,7 @@ public:
}
}
remove_singular_occurences();
TRACE("nla_cn_details", tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
TRACE(nla_cn_details, tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
}
void fill_vars_from_occurences_map(svector<lpvar>& vars) {
@ -210,7 +210,7 @@ public:
vars.push_back(p.first);
m_random_bit = m_random() % 2;
TRACE("nla_cn", tout << "m_random_bit = " << m_random_bit << "\n";);
TRACE(nla_cn, tout << "m_random_bit = " << m_random_bit << "\n";);
std::sort(vars.begin(), vars.end(), [this](lpvar j, lpvar k)
{
auto it_j = m_nex_creator.occurences_map().find(j);
@ -247,15 +247,15 @@ public:
if (proceed_with_common_factor_or_get_vars_to_factor_out(c, vars, front))
return;
TRACE("nla_cn", tout << "m_e=" << *m_e << "\nc=" << **c << ", c vars=";
TRACE(nla_cn, tout << "m_e=" << *m_e << "\nc=" << **c << ", c vars=";
print_vector(vars, tout) << "; front:"; print_front(front, tout) << "\n";);
if (vars.empty()) {
if (front.empty()) {
TRACE("nla_cn", tout << "got the cn form: =" << *m_e << "\n";);
TRACE(nla_cn, tout << "got the cn form: =" << *m_e << "\n";);
m_done = m_call_on_result(m_e) || ++m_reported > 100;
#ifdef Z3DEBUG
TRACE("nla_cn", tout << "m_e_clone " << *m_e_clone << "\n";);
TRACE(nla_cn, tout << "m_e_clone " << *m_e_clone << "\n";);
SASSERT(nex_creator::equal(m_e, m_e_clone));
#endif
} else {
@ -276,13 +276,13 @@ public:
// c is the sub expressiond which is going to be changed from sum to the cross nested form
// front will be explored more
void explore_of_expr_on_sum_and_var(nex** c, lpvar j, vector<nex**> front) {
TRACE("nla_cn", tout << "m_e=" << *m_e << "\nc=" << **c << "\nj = " << nex_creator::ch(j) << "\nfront="; print_front(front, tout) << "\n";);
TRACE(nla_cn, tout << "m_e=" << *m_e << "\nc=" << **c << "\nj = " << nex_creator::ch(j) << "\nfront="; print_front(front, tout) << "\n";);
if (!split_with_var(*c, j, front))
return;
TRACE("nla_cn", tout << "after split c=" << **c << "\nfront="; print_front(front, tout) << "\n";);
TRACE(nla_cn, tout << "after split c=" << **c << "\nfront="; print_front(front, tout) << "\n";);
if (front.empty()) {
#ifdef Z3DEBUG
TRACE("nla_cn", tout << "got the cn form: =" << *m_e << ", clone = " << *m_e_clone << "\n";);
TRACE(nla_cn, tout << "got the cn form: =" << *m_e << ", clone = " << *m_e_clone << "\n";);
#endif
m_done = m_call_on_result(m_e) || ++m_reported > 100;
#ifdef Z3DEBUG
@ -316,7 +316,7 @@ public:
it->second.m_power = std::min(it->second.m_power, jp);
}
}
TRACE("nla_cn_details", tout << "occs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
TRACE(nla_cn_details, tout << "occs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
}
void remove_singular_occurences() {
@ -348,7 +348,7 @@ public:
}
}
remove_singular_occurences();
TRACE("nla_cn_details", tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
TRACE(nla_cn_details, tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
vector<std::pair<lpvar, occ>> ret;
for (auto & p : m_nex_creator.occurences_map())
ret.push_back(p);
@ -373,12 +373,12 @@ public:
}
// all factors of j go to a, the rest to b
void pre_split(nex_sum * e, lpvar j, nex_sum const*& a, nex const*& b) {
TRACE("nla_cn_details", tout << "e = " << * e << ", j = " << m_nex_creator.ch(j) << std::endl;);
TRACE(nla_cn_details, tout << "e = " << * e << ", j = " << m_nex_creator.ch(j) << std::endl;);
SASSERT(m_nex_creator.is_simplified(*e));
nex_creator::sum_factory sf(m_nex_creator);
m_b_split_vec.clear();
for (nex const* ce: *e) {
TRACE("nla_cn_details", tout << "ce = " << *ce << "\n";);
TRACE(nla_cn_details, tout << "ce = " << *ce << "\n";);
if (is_divisible_by_var(ce, j)) {
sf += m_nex_creator.mk_div(*ce , j);
} else {
@ -386,22 +386,22 @@ public:
}
}
a = sf.mk();
TRACE("nla_cn_details", tout << "a = " << *a << "\n";);
TRACE(nla_cn_details, tout << "a = " << *a << "\n";);
SASSERT(a->size() >= 2 && m_b_split_vec.size());
a = to_sum(m_nex_creator.simplify_sum(const_cast<nex_sum*>(a)));
if (m_b_split_vec.size() == 1) {
b = m_b_split_vec[0];
TRACE("nla_cn_details", tout << "b = " << *b << "\n";);
TRACE(nla_cn_details, tout << "b = " << *b << "\n";);
} else {
SASSERT(m_b_split_vec.size() > 1);
b = m_nex_creator.mk_sum(m_b_split_vec);
TRACE("nla_cn_details", tout << "b = " << *b << "\n";);
TRACE(nla_cn_details, tout << "b = " << *b << "\n";);
}
}
void update_front_with_split_with_non_empty_b(nex* &e, lpvar j, vector<nex**> & front, nex_sum const* a, nex const* b) {
TRACE("nla_cn_details", tout << "b = " << *b << "\n";);
TRACE(nla_cn_details, tout << "b = " << *b << "\n";);
e = m_nex_creator.mk_sum(m_nex_creator.mk_mul(m_nex_creator.mk_var(j), a), b); // e = j*a + b
if (!a->is_linear()) {
nex **ptr_to_a = e->to_sum()[0]->to_mul()[1].ee();
@ -426,7 +426,7 @@ public:
// it returns true if the recursion brings a cross-nested form
bool split_with_var(nex*& e, lpvar j, vector<nex**> & front) {
SASSERT(e->is_sum());
TRACE("nla_cn", tout << "e = " << *e << ", j=" << nex_creator::ch(j) << "\n";);
TRACE(nla_cn, tout << "e = " << *e << ", j=" << nex_creator::ch(j) << "\n";);
nex_sum const* a; nex const* b;
pre_split(to_sum(e), j, a, b);
/*
@ -458,7 +458,7 @@ public:
}
nex * normalize_mul(nex_mul* a) {
TRACE("nla_cn", tout << *a << "\n";);
TRACE(nla_cn, tout << *a << "\n";);
NOT_IMPLEMENTED_YET();
return nullptr;
}

View file

@ -551,8 +551,8 @@ namespace lp {
}
void undo_add_term_method(const lar_term* t) {
TRACE("d_undo", tout << "t:" << t << ", t->j():" << t->j() << std::endl;);
TRACE("dio", lra.print_term(*t, tout); tout << ", t->j() =" << t->j() << std::endl;);
TRACE(d_undo, tout << "t:" << t << ", t->j():" << t->j() << std::endl;);
TRACE(dio, lra.print_term(*t, tout); tout << ", t->j() =" << t->j() << std::endl;);
if (!contains(m_active_terms, t)) {
for (auto i = m_added_terms.size(); i-- > 0; ) {
if (m_added_terms[i] != t)
@ -565,7 +565,7 @@ namespace lp {
}
// deregister the term that has been activated
for (const auto& p : t->ext_coeffs()) {
TRACE("dio_reg", tout << "derigister p.var():" << p.var() << "->" << t->j() << std::endl;);
TRACE(dio_reg, tout << "derigister p.var():" << p.var() << "->" << t->j() << std::endl;);
auto it = m_columns_to_terms.find(p.var());
SASSERT(it != m_columns_to_terms.end());
it->second.erase(t->j());
@ -576,7 +576,7 @@ namespace lp {
SASSERT(std::find(m_added_terms.begin(), m_added_terms.end(), t) == m_added_terms.end());
SASSERT(contains(m_active_terms, t));
m_active_terms.erase(t);
TRACE("dio", tout << "the deleted term column in m_l_matrix" << std::endl; for (auto p : m_l_matrix.column(t->j())) { tout << "p.coeff():" << p.coeff() << ", row " << p.var() << std::endl; } tout << "m_l_matrix has " << m_l_matrix.column_count() << " columns" << std::endl; tout << "and " << m_l_matrix.row_count() << " rows" << std::endl; print_lar_term_L(*t, tout); tout << "; t->j()=" << t->j() << std::endl;);
TRACE(dio, tout << "the deleted term column in m_l_matrix" << std::endl; for (auto p : m_l_matrix.column(t->j())) { tout << "p.coeff():" << p.coeff() << ", row " << p.var() << std::endl; } tout << "m_l_matrix has " << m_l_matrix.column_count() << " columns" << std::endl; tout << "and " << m_l_matrix.row_count() << " rows" << std::endl; print_lar_term_L(*t, tout); tout << "; t->j()=" << t->j() << std::endl;);
shrink_matrices();
}
@ -764,7 +764,7 @@ namespace lp {
}
void add_changed_column(unsigned j) {
TRACE("dio", lra.print_column_info(j, tout););
TRACE(dio, lra.print_column_info(j, tout););
m_changed_f_columns.insert(j);
}
std_vector<const lar_term*> m_added_terms;
@ -785,13 +785,13 @@ namespace lp {
// we add all terms, even those with big numbers, but we might choose to non process the latter.
void add_term_callback(const lar_term* t) {
unsigned j = t->j();
TRACE("dio", tout << "term column t->j():" << j << std::endl; lra.print_term(*t, tout) << std::endl;);
TRACE(dio, tout << "term column t->j():" << j << std::endl; lra.print_term(*t, tout) << std::endl;);
if (!lra.column_is_int(j)) {
TRACE("dio", tout << "ignored a non-integral column" << std::endl;);
TRACE(dio, tout << "ignored a non-integral column" << std::endl;);
m_some_terms_are_ignored = true;
return;
}
CTRACE("dio", !lra.column_has_term(j), tout << "added term that is not associated with a column yet" << std::endl;);
CTRACE(dio, !lra.column_has_term(j), tout << "added term that is not associated with a column yet" << std::endl;);
m_added_terms.push_back(t);
mark_term_change(t->j());
auto undo = undo_add_term(*this, t);
@ -799,7 +799,7 @@ namespace lp {
}
void mark_term_change(unsigned j) {
TRACE("dio", tout << "marked term change j:" << j << std::endl;);
TRACE(dio, tout << "marked term change j:" << j << std::endl;);
m_changed_terms.insert(j);
}
@ -810,7 +810,7 @@ namespace lp {
m_terms_to_tighten.insert(j); // the boundary of the term has changed: we can be successful to tighten this term
if (!lra.column_is_fixed(j))
return;
TRACE("dio", tout << "j:" << j << "\n"; lra.print_column_info(j, tout););
TRACE(dio, tout << "j:" << j << "\n"; lra.print_column_info(j, tout););
m_changed_f_columns.insert(j);
lra.trail().push(undo_fixed_column(*this, j));
}
@ -839,10 +839,10 @@ namespace lp {
}
void register_columns_to_term(const lar_term& t) {
CTRACE("dio_reg", t.j() == 1337, tout << "register term:"; lra.print_term(t, tout); tout << ", t.j()=" << t.j() << std::endl;);
CTRACE(dio_reg, t.j() == 1337, tout << "register term:"; lra.print_term(t, tout); tout << ", t.j()=" << t.j() << std::endl;);
for (const auto& p : t.ext_coeffs()) {
auto it = m_columns_to_terms.find(p.var());
TRACE("dio_reg", tout << "register p.var():" << p.var() << "->" << t.j() << std::endl;);
TRACE(dio_reg, tout << "register p.var():" << p.var() << "->" << t.j() << std::endl;);
if (it != m_columns_to_terms.end()) {
it->second.insert(t.j());
@ -881,7 +881,7 @@ namespace lp {
}
subs_entry(entry_index);
SASSERT(entry_invariant(entry_index));
TRACE("dio_entry", print_entry(entry_index, tout) << std::endl;);
TRACE(dio_entry, print_entry(entry_index, tout) << std::endl;);
}
void subs_entry(unsigned ei) {
if (ei >= m_e_matrix.row_count()) return;
@ -892,7 +892,7 @@ namespace lp {
m_q.push(p.var());
}
if (m_q.size() == 0) {
TRACE("dio", tout << "nothing to subst on ei:" << ei << "\n";);
TRACE(dio, tout << "nothing to subst on ei:" << ei << "\n";);
return;
}
substitute_on_q(ei);
@ -912,7 +912,7 @@ namespace lp {
}
void substitute_with_fresh_def(unsigned ei, unsigned j, const mpq& alpha) {
const lar_term& sub_term = m_fresh_k2xt_terms.get_by_key(j).first;
TRACE("dio", print_lar_term_L(sub_term, tout) << std::endl;);
TRACE(dio, print_lar_term_L(sub_term, tout) << std::endl;);
SASSERT(sub_term.get_coeff(j).is_one());
// we need to eliminate alpha*j in ei's row
add_term_to_entry(-alpha, sub_term, ei);
@ -966,7 +966,7 @@ namespace lp {
}
void recalculate_entry(unsigned ei) {
TRACE("dio", print_entry(ei, tout) << std::endl;);
TRACE(dio, print_entry(ei, tout) << std::endl;);
mpq& fixed_sum = m_sum_of_fixed[ei];
fixed_sum = mpq(0);
open_l_term_to_espace(ei, fixed_sum);
@ -1129,7 +1129,7 @@ namespace lp {
if (lra.settings().get_cancel_flag()) return true;
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ei++) {
if (entry_invariant(ei) == false) {
TRACE("dio", tout << "bad entry:"; print_entry(ei, tout););
TRACE(dio, tout << "bad entry:"; print_entry(ei, tout););
return false;
}
if (belongs_to_f(ei)) {
@ -1137,7 +1137,7 @@ namespace lp {
const auto& row = m_e_matrix.m_rows[ei];
for (const auto& p : row) {
if (m_k2s.has_key(p.var())) {
TRACE("dio",
TRACE(dio,
tout << "entry:" << ei << " belongs to f but depends on column " << p.var() << std::endl;
tout << "m_var_register.local_to_external(p.var()):" << m_var_register.local_to_external(p.var()) << std::endl;
print_entry(ei, tout);
@ -1220,13 +1220,13 @@ namespace lp {
// The function returns true if and only if there is no conflict.
bool normalize_e_by_gcd(unsigned ei, mpq& g) {
mpq& e = m_sum_of_fixed[ei];
TRACE("dio", print_entry(ei, tout) << std::endl;);
TRACE(dio, print_entry(ei, tout) << std::endl;);
g = gcd_of_coeffs(m_e_matrix.m_rows[ei], false);
if (g.is_zero() || g.is_one()) {
SASSERT(g.is_one() || e.is_zero());
return true;
}
TRACE("dio", tout << "g:" << g << std::endl;);
TRACE(dio, tout << "g:" << g << std::endl;);
mpq c_g = e / g;
if (c_g.is_int()) {
for (auto& p : m_e_matrix.m_rows[ei]) {
@ -1238,7 +1238,7 @@ namespace lp {
p.coeff() /= g;
}
TRACE("dio", tout << "ep_m_e:";
TRACE(dio, tout << "ep_m_e:";
print_entry(ei, tout) << std::endl;);
SASSERT(entry_invariant(ei));
return true;
@ -1249,7 +1249,7 @@ namespace lp {
lia_move subs_qfront_by_fresh(unsigned k, protected_queue& q, unsigned j) {
const lar_term& e = m_fresh_k2xt_terms.get_by_key(k).first;
TRACE("dio", tout << "k:" << k << ", in ";
TRACE(dio, tout << "k:" << k << ", in ";
print_term_o(create_term_from_espace(), tout) << std::endl;
tout << "subs with e:";
print_lar_term_L(e, tout) << std::endl;);
@ -1269,7 +1269,7 @@ namespace lp {
}
// there is no change in m_l_matrix
TRACE("dio", tout << "after subs k:" << k << "\n";
TRACE(dio, tout << "after subs k:" << k << "\n";
print_term_o(create_term_from_espace(), tout) << std::endl;
tout << "m_lspace:{"; print_lar_term_L(m_lspace.m_data, tout);
tout << "}, opened:"; print_ml(m_lspace.to_term(), tout) << std::endl;);
@ -1284,7 +1284,7 @@ namespace lp {
lia_move subs_qfront_by_S(unsigned k, protected_queue& q, unsigned j) {
const mpq& e = m_sum_of_fixed[m_k2s[k]];
TRACE("dio", tout << "k:" << k << ", in ";
TRACE(dio, tout << "k:" << k << ", in ";
print_term_o(create_term_from_espace(), tout) << std::endl;
tout << "subs with e:";
print_entry(m_k2s[k], tout) << std::endl;);
@ -1314,7 +1314,7 @@ namespace lp {
}
m_c += coeff * e;
add_l_row_to_term_with_index(coeff, sub_index(k));
TRACE("dio", tout << "after subs k:" << k << "\n";
TRACE(dio, tout << "after subs k:" << k << "\n";
print_term_o(create_term_from_espace(), tout) << std::endl;
tout << "m_lspace:{"; print_lar_term_L(m_lspace.to_term(), tout);
tout << "}, opened:"; print_ml(m_lspace.to_term(), tout) << std::endl;);
@ -1459,7 +1459,7 @@ namespace lp {
if (ls != rs) {
std::cout << "enabling trace dio\n";
enable_trace("dio");
TRACE("dio", tout << "ls:"; print_term_o(ls, tout) << "\n";
TRACE(dio, tout << "ls:"; print_term_o(ls, tout) << "\n";
tout << "rs:"; print_term_o(rs, tout) << "\n";);
return false;
}
@ -1512,7 +1512,7 @@ namespace lp {
lia_move r = lia_move::undef;
// Process sorted terms
TRACE("dio",
TRACE(dio,
tout << "changed terms:"; for (auto j : sorted_changed_terms) tout << j << " "; tout << std::endl;
print_S(tout);
// lra.display(tout);
@ -1532,7 +1532,7 @@ namespace lp {
}
for (unsigned j : processed_terms)
m_terms_to_tighten.remove(j);
TRACE("dio", tout << r << "\n");
TRACE(dio, tout << r << "\n");
return r;
}
@ -1648,7 +1648,7 @@ namespace lp {
lia_move tighten_bounds_for_term_column(unsigned j) {
// q is the queue of variables that can be substituted in term_to_tighten
protected_queue q;
TRACE("dio", tout << "j:" << j << " , initial term t: "; print_lar_term_L(lra.get_term(j), tout) << std::endl;
TRACE(dio, tout << "j:" << j << " , initial term t: "; print_lar_term_L(lra.get_term(j), tout) << std::endl;
for( const auto& p : lra.get_term(j).ext_coeffs()) {
lra.print_column_info(p.var(), tout);
}
@ -1656,7 +1656,7 @@ namespace lp {
if (!init_substitutions(lra.get_term(j), q))
return lia_move::undef;
TRACE("dio", tout << "t:";
TRACE(dio, tout << "t:";
tout << "m_espace:";
print_term_o(create_term_from_espace(), tout) << std::endl;
tout << "in lar_solver indices:\n";
@ -1774,20 +1774,20 @@ namespace lp {
SASSERT(!g.is_zero() && !g.is_one());
if (lra.has_bound_of_type(j, b_dep, rs, is_strict, is_upper)) {
TRACE("dio", tout << "x" << j << (is_upper? " <= ":" >= ") << rs << std::endl;);
TRACE(dio, tout << "x" << j << (is_upper? " <= ":" >= ") << rs << std::endl;);
mpq rs_g = (rs - m_c) % g;
if (rs_g.is_neg())
rs_g += g;
SASSERT(rs_g.is_int() && !rs_g.is_neg());
TRACE("dio", tout << "(rs - m_c) % g:" << rs_g << std::endl;);
TRACE(dio, tout << "(rs - m_c) % g:" << rs_g << std::endl;);
if (!rs_g.is_zero()) {
if (tighten_bound_kind(g, j, rs, rs_g, is_upper))
return lia_move::conflict;
}
else
TRACE("dio", tout << "rs_g is zero: no improvement in the bound\n";);
TRACE(dio, tout << "rs_g is zero: no improvement in the bound\n";);
}
return lia_move::undef;
}
@ -1832,7 +1832,7 @@ namespace lp {
mpq bound = upper ? rs - rs_g : rs + g - rs_g;
TRACE("dio", tout << "is upper:" << upper << std::endl;
TRACE(dio, tout << "is upper:" << upper << std::endl;
tout << "new " << (upper ? "upper" : "lower") << " bound:" << bound << std::endl;);
SASSERT((upper && bound < lra.get_upper_bound(j).x) ||
@ -1840,7 +1840,7 @@ namespace lp {
lconstraint_kind kind = upper ? lconstraint_kind::LE : lconstraint_kind::GE;
u_dependency* dep = upper ? lra.get_column_upper_bound_witness(j) : lra.get_column_lower_bound_witness(j);
auto fixed_part_of_the_term = open_fixed_from_ml(m_lspace);
TRACE("dio",
TRACE(dio,
tout << "fixed_part_of_the_term:";
print_term_o(fixed_part_of_the_term.to_term(), tout);
);
@ -1851,12 +1851,12 @@ namespace lp {
SASSERT(is_fixed(p.var()));
if (p.coeff().is_int() && (p.coeff() % g).is_zero()) {
// we can skip this dependency as explained above
TRACE("dio", tout << "skipped dep:\n"; print_deps(tout, lra.get_bound_constraint_witnesses_for_column(p.var())););
TRACE(dio, tout << "skipped dep:\n"; print_deps(tout, lra.get_bound_constraint_witnesses_for_column(p.var())););
continue;
}
dep = lra.join_deps(dep, lra.get_bound_constraint_witnesses_for_column(p.var()));
}
TRACE("dio", tout << "jterm:";
TRACE(dio, tout << "jterm:";
print_lar_term_L(lra.get_term(j), tout) << "\ndep:";
print_deps(tout, dep) << std::endl;);
if (lra.settings().get_cancel_flag())
@ -1932,7 +1932,7 @@ namespace lp {
if (r == lia_move::conflict) {
return lia_move::conflict;
}
TRACE("dio_s", print_S(tout));
TRACE(dio_s, print_S(tout));
return lia_move::undef;
}
@ -1944,7 +1944,7 @@ namespace lp {
ret = tighten_terms_with_S();
if (ret == lia_move::conflict)
lra.stats().m_dio_tighten_conflicts++;
TRACE("dio", print_S(tout););
TRACE(dio, print_S(tout););
return ret;
}
@ -1958,7 +1958,7 @@ namespace lp {
const mpq& j_coeff = p.coeff();
SASSERT(j_coeff.is_one() || j_coeff.is_minus_one());
c += j_coeff * lra.get_lower_bound(local_to_lar_solver(j)).x;
TRACE("dio_br", tout << "the value of the vixed var is:" << lra.get_lower_bound(local_to_lar_solver(j)).x << ", m_sum_of_fixed[" << ei << "]:" << m_sum_of_fixed[ei] << ", new free coeff c:" << c << std::endl;);
TRACE(dio_br, tout << "the value of the vixed var is:" << lra.get_lower_bound(local_to_lar_solver(j)).x << ", m_sum_of_fixed[" << ei << "]:" << m_sum_of_fixed[ei] << ", new free coeff c:" << c << std::endl;);
continue;
}
if (g.is_zero()) {
@ -1981,7 +1981,7 @@ namespace lp {
We only can get a conflict when j is substituted, and the entry m_k2s[j], the entry defining the substitution becomes infeaseable, that is the gcd of the monomial coeffitients does not divide the free coefficient. In other cases the gcd of the monomials will remain to be 1.
*/
if (m_k2s.has_key(j)) { // j is substituted but using an entry
TRACE("dio_br",
TRACE(dio_br,
tout << "fixed j:" << j << ", was substited by ";
print_entry(m_k2s[j], tout););
if (check_fixing(j) == lia_move::conflict) {
@ -2023,12 +2023,12 @@ namespace lp {
unsigned j = p.first;
const auto it = m_columns_to_terms.find(j);
if (it == m_columns_to_terms.end()) {
TRACE("dio", tout << "column j" << j << " is not registered" << std::endl; tout << "the column belongs to the the following terms:"; for (unsigned tj : p.second) { tout << " " << tj; } tout << std::endl;);
TRACE(dio, tout << "column j" << j << " is not registered" << std::endl; tout << "the column belongs to the the following terms:"; for (unsigned tj : p.second) { tout << " " << tj; } tout << std::endl;);
return false;
}
if (it->second != p.second) {
TRACE("dioph_eq_deb", tout << "m_columns_to_terms[" << j << "] has to be "; tout << "{"; for (unsigned lll : p.second) { tout << lll << ", "; } tout << "}, \nbut it is {"; for (unsigned lll : it->second) { tout << lll << ", "; }; tout << "}" << std::endl;
TRACE(dioph_eq_deb, tout << "m_columns_to_terms[" << j << "] has to be "; tout << "{"; for (unsigned lll : p.second) { tout << lll << ", "; } tout << "}, \nbut it is {"; for (unsigned lll : it->second) { tout << lll << ", "; }; tout << "}" << std::endl;
);
return false;
@ -2039,7 +2039,7 @@ namespace lp {
unsigned j = p.first;
const auto it = c2t.find(j);
if (it == c2t.end()) {
TRACE("dio", tout << "should not be registered j " << j << std::endl;
TRACE(dio, tout << "should not be registered j " << j << std::endl;
lra.print_terms(tout););
return false;
}
@ -2076,7 +2076,7 @@ namespace lp {
public:
lia_move check() {
lra.stats().m_dio_calls++;
TRACE("dio", tout << lra.stats().m_dio_calls << std::endl;);
TRACE(dio, tout << lra.stats().m_dio_calls << std::endl;);
std_vector<unsigned> f_vector;
lia_move ret;
do {
@ -2130,7 +2130,7 @@ namespace lp {
SASSERT(belongs_to_s(ei));
const auto& e = m_sum_of_fixed[ei];
SASSERT(j_sign_is_correct(ei, j, j_sign));
TRACE("dio", tout << "eliminate var:" << j << " by using:";
TRACE(dio, tout << "eliminate var:" << j << " by using:";
print_entry(ei, tout) << std::endl;);
auto& column = m_e_matrix.m_columns[j];
auto it =
@ -2158,16 +2158,16 @@ namespace lp {
SASSERT(c.var() != ei && entry_invariant(c.var()));
mpq coeff = m_e_matrix.get_val(c);
unsigned i = c.var();
TRACE("dio", tout << "before pivot entry:";
TRACE(dio, tout << "before pivot entry:";
print_entry(i, tout) << std::endl;);
m_sum_of_fixed[i] -= j_sign * coeff * e;
m_e_matrix.pivot_row_to_row_given_cell_with_sign(ei, c, j, j_sign);
// m_sum_of_fixed[i].m_l -= j_sign * coeff * e.m_l;
m_l_matrix.add_rows(-j_sign * coeff, ei, i);
TRACE("dio", tout << "after pivoting c_row:";
TRACE(dio, tout << "after pivoting c_row:";
print_entry(i, tout););
CTRACE(
"dio", !entry_invariant(i), tout << "invariant delta:"; {
dio, !entry_invariant(i), tout << "invariant delta:"; {
print_term_o(get_term_from_entry(ei) -
fix_vars(open_ml(m_l_matrix.m_rows[ei])),
tout)
@ -2182,7 +2182,7 @@ namespace lp {
// matrix m_l_matrix is not changed since it is a substitution of a fresh variable
void eliminate_var_in_f_with_term(const lar_term& t, unsigned j, int j_sign) {
SASSERT(abs(t.get_coeff(j)).is_one());
TRACE("dio", tout << "eliminate var:" << j << " by using:";
TRACE(dio, tout << "eliminate var:" << j << " by using:";
print_lar_term_L(t, tout) << std::endl;);
auto& column = m_e_matrix.m_columns[j];
@ -2192,9 +2192,9 @@ namespace lp {
continue;
mpq coeff = m_e_matrix.get_val(c);
TRACE("dio", tout << "before pivot entry :"; print_entry(c.var(), tout) << std::endl;);
TRACE(dio, tout << "before pivot entry :"; print_entry(c.var(), tout) << std::endl;);
m_e_matrix.pivot_term_to_row_given_cell(t, c, j, j_sign);
TRACE("dio", tout << "after pivoting c_row:";
TRACE(dio, tout << "after pivoting c_row:";
print_entry(c.var(), tout););
SASSERT(entry_invariant(c.var()));
}
@ -2239,7 +2239,7 @@ namespace lp {
unsigned j = local_to_lar_solver(p.var());
if (is_fixed(j)) {
enable_trace("dio");
TRACE("dio", tout << "x" << j << "(local: " << "x" << p.var() << ") should not be fixed\nbad entry:"; print_entry(ei, tout) << "\n";);
TRACE(dio, tout << "x" << j << "(local: " << "x" << p.var() << ") should not be fixed\nbad entry:"; print_entry(ei, tout) << "\n";);
return false;
}
}
@ -2249,7 +2249,7 @@ namespace lp {
if (!ls_val.is_zero()) {
std::cout << "ls_val is not zero\n";
enable_trace("dio");
TRACE("dio", {
TRACE(dio, {
tout << "get_term_from_entry(" << ei << "):";
print_term_o(get_term_from_entry(ei), tout) << std::endl;
tout << "ls:";
@ -2267,7 +2267,7 @@ namespace lp {
bool ret = ls == fix_vars(open_ml(m_l_matrix.m_rows[ei]));
if (!ret) {
enable_trace("dio");
CTRACE("dio", !ret,
CTRACE(dio, !ret,
{
tout << "get_term_from_entry(" << ei << "):";
print_term_o(get_term_from_entry(ei), tout) << std::endl;
@ -2295,7 +2295,7 @@ namespace lp {
while (!q.empty()) {
unsigned xt = q.pop_front(); // xt is a fresh var
const lar_term& fresh_t = m_fresh_k2xt_terms.get_by_val(xt).first;
TRACE("dio_remove_fresh", print_lar_term_L(fresh_t, tout););
TRACE(dio_remove_fresh, print_lar_term_L(fresh_t, tout););
SASSERT(fresh_t.get_coeff(xt).is_minus_one());
if (!t.contains(xt))
continue;
@ -2521,12 +2521,12 @@ namespace lp {
break;
}
if (h == UINT_MAX) {
TRACE("dio", tout << "done - cannot find an entry to rewrite\n");
TRACE(dio, tout << "done - cannot find an entry to rewrite\n");
return lia_move::undef;
}
SASSERT(h == f_vector[ih]);
if (min_ahk.is_one()) {
TRACE("dio", tout << "push to S:\n"; print_entry(h, tout););
TRACE(dio, tout << "push to S:\n"; print_entry(h, tout););
move_entry_from_f_to_s(kh, h);
eliminate_var_in_f(h, kh, kh_sign);
f_vector[ih] = f_vector.back();
@ -2544,7 +2544,7 @@ namespace lp {
void explain(explanation& ex) {
SASSERT(ex.empty());
if (has_conflict_index()) {
TRACE("dio", print_entry(m_normalize_conflict_index, tout << "conflict:", true) << std::endl;);
TRACE(dio, print_entry(m_normalize_conflict_index, tout << "conflict:", true) << std::endl;);
for (auto ci : lra.flatten(explain_fixed_in_meta_term(m_l_matrix.m_rows[m_normalize_conflict_index], m_normalize_conflict_gcd)))
ex.push_back(ci);
}
@ -2552,7 +2552,7 @@ namespace lp {
for (auto ci : m_infeas_explanation)
ex.push_back(ci.ci());
}
TRACE("dio", lra.print_expl(tout, ex););
TRACE(dio, lra.print_expl(tout, ex););
}
// needed for the template bound_analyzer_on_row.h

View file

@ -37,7 +37,7 @@ void emonics::inc_visited() const {
}
void emonics::push() {
TRACE("nla_solver_mons", display(tout << "push\n"););
TRACE(nla_solver_mons, display(tout << "push\n"););
SASSERT(invariant());
m_u_f_stack.push_scope();
m_ve.push();
@ -48,7 +48,7 @@ void emonics::push() {
void emonics::pop_monic() {
m_ve.pop(1);
monic& m = m_monics.back();
TRACE("nla_solver_mons", display(tout << m << "\n"););
TRACE(nla_solver_mons, display(tout << m << "\n"););
remove_cg_mon(m);
m_var2index[m.var()] = UINT_MAX;
do_canonize(m);
@ -65,7 +65,7 @@ void emonics::pop_monic() {
}
void emonics::pop(unsigned n) {
TRACE("nla_solver_mons", tout << "pop: " << n << "\n";);
TRACE(nla_solver_mons, tout << "pop: " << n << "\n";);
SASSERT(invariant());
for (unsigned i = 0; i < n; ++i) {
m_ve.pop(1);
@ -126,7 +126,7 @@ void emonics::unmerge_cells(head_tail& root, head_tail& other) {
cell* other_head = other.m_head;
cell* other_tail = other.m_tail;
TRACE("nla_solver_mons",
TRACE(nla_solver_mons,
display(tout << "other: ", other_head) << "\n";
display(tout << "root: ", root_head) << "\n"; );
@ -142,7 +142,7 @@ void emonics::unmerge_cells(head_tail& root, head_tail& other) {
root_tail->m_next = root_head;
other_tail->m_next = other_head;
}
TRACE("nla_solver_mons",
TRACE(nla_solver_mons,
display(tout << "other: ", other_head) << "\n";
display(tout << "root: ", root_head) << "\n"; );
}
@ -166,8 +166,8 @@ monic const* emonics::find_canonical(svector<lpvar> const& vars) const {
}
void emonics::remove_cg(lpvar v) {
TRACE("nla_solver_mons", tout << "remove: " << v << "\n";);
// TRACE("nla_solver_mons", display(tout););
TRACE(nla_solver_mons, tout << "remove: " << v << "\n";);
// TRACE(nla_solver_mons, display(tout););
cell* c = m_use_lists[v].m_head;
if (c == nullptr) {
return;
@ -225,7 +225,7 @@ void emonics::insert_cg(lpvar v) {
do {
unsigned idx = c->m_index;
c = c->m_next;
TRACE("nla_solver_mons", tout << "inserting v" << v << " for " << idx << "\n";);
TRACE(nla_solver_mons, tout << "inserting v" << v << " for " << idx << "\n";);
monic & m = m_monics[idx];
if (!is_visited(m)) {
set_visited(m);
@ -233,7 +233,7 @@ void emonics::insert_cg(lpvar v) {
}
}
while (c != first);
TRACE("nla_solver_mons", tout << "insert: " << v << "\n";);
TRACE(nla_solver_mons, tout << "insert: " << v << "\n";);
}
bool emonics::elists_are_consistent(std::unordered_map<unsigned_vector, std::unordered_set<lpvar>, hash_svector>& lists) const {
@ -257,7 +257,7 @@ bool emonics::elists_are_consistent(std::unordered_map<unsigned_vector, std::uno
c.insert(e.var());
auto it = lists.find(m.rvars());
(void)it;
CTRACE("nla_solver_mons", it->second != c,
CTRACE(nla_solver_mons, it->second != c,
tout << "m = " << m << "\n";
tout << "c = " ; print_vector(c, tout); tout << "\n";
if (it == lists.end()) {
@ -280,7 +280,7 @@ bool emonics::elists_are_consistent(std::unordered_map<unsigned_vector, std::uno
void emonics::insert_cg_mon(monic & m) {
do_canonize(m);
lpvar v = m.var(), w;
TRACE("nla_solver_mons", tout << m << "\n";); // hash: " << m_cg_hash(v) << "\n";);
TRACE(nla_solver_mons, tout << m << "\n";); // hash: " << m_cg_hash(v) << "\n";);
auto& vec = m_cg_table.insert_if_not_there(v, unsigned_vector());
if (vec.empty()) {
vec.push_back(v);
@ -293,11 +293,11 @@ void emonics::insert_cg_mon(monic & m) {
unsigned max_i = std::max(v_idx, w_idx);
while (m_u_f.get_num_vars() <= max_i)
m_u_f.mk_var();
TRACE("nla_solver_mons", tout << "merge " << v << " idx " << v_idx << ", and " << w << " idx " << w_idx << "\n";);
TRACE(nla_solver_mons, tout << "merge " << v << " idx " << v_idx << ", and " << w << " idx " << w_idx << "\n";);
m_u_f.merge(v_idx, w_idx);
}
else {
TRACE("nla_solver_mons", tout << "found " << v << "\n";);
TRACE(nla_solver_mons, tout << "found " << v << "\n";);
}
}
@ -318,7 +318,7 @@ bool emonics::is_visited(monic const& m) const {
The monic is inserted into a congruence class of equal up-to var_eqs monics.
*/
void emonics::add(lpvar v, unsigned sz, lpvar const* vs) {
TRACE("nla_solver_mons", tout << "v = " << v << "\n";);
TRACE(nla_solver_mons, tout << "v = " << v << "\n";);
SASSERT(m_ve.is_root(v));
SASSERT(!is_monic_var(v));
SASSERT(invariant());
@ -353,12 +353,12 @@ void emonics::add(lpvar v, unsigned sz, lpvar const* vs) {
}
void emonics::do_canonize(monic & m) const {
TRACE("nla_solver_mons", tout << m << "\n";);
TRACE(nla_solver_mons, tout << m << "\n";);
m.reset_rfields();
for (lpvar v : m.vars())
m.push_rvar(m_ve.find(v));
m.sort_rvars();
TRACE("nla_solver_mons", tout << m << "\n";);
TRACE(nla_solver_mons, tout << m << "\n";);
}
bool emonics::is_canonized(const monic & m) const {
@ -430,9 +430,9 @@ void emonics::merge_eh(signed_var r2, signed_var r1, signed_var v2, signed_var v
}
void emonics::after_merge_eh(signed_var r2, signed_var r1, signed_var v2, signed_var v1) {
TRACE("nla_solver_mons", tout << v2 << " <- " << v1 << " : " << r2 << " <- " << r1 << "\n";);
TRACE(nla_solver_mons, tout << v2 << " <- " << v1 << " : " << r2 << " <- " << r1 << "\n";);
if (r1.var() == r2.var() || m_ve.find(~r1) == m_ve.find(~r2)) { // the other sign has also been merged
TRACE("nla_solver_mons",
TRACE(nla_solver_mons,
display_uf(tout << r2 << " <- " << r1 << "\n");
tout << "rehashing " << r1.var() << "\n";);
m_use_lists.reserve(std::max(r2.var(), r1.var()) + 1);
@ -443,7 +443,7 @@ void emonics::after_merge_eh(signed_var r2, signed_var r1, signed_var v2, signed
void emonics::unmerge_eh(signed_var r2, signed_var r1) {
if (r1.var() == r2.var() || m_ve.find(~r1) != m_ve.find(~r2)) { // the other sign has also been unmerged
TRACE("nla_solver_mons", tout << r2 << " -> " << r1 << "\n";);
TRACE(nla_solver_mons, tout << r2 << " -> " << r1 << "\n";);
unmerge_cells(m_use_lists[r2.var()], m_use_lists[r1.var()]);
rehash_cg(r1.var());
}
@ -514,7 +514,7 @@ std::ostream& emonics::display(std::ostream& out, cell* c) const {
bool emonics::invariant() const {
TRACE("nla_solver_mons", display(tout););
TRACE(nla_solver_mons, display(tout););
// the variable index contains exactly the active monomials
unsigned mons = 0;
for (lpvar v = 0; v < m_var2index.size(); v++)
@ -522,7 +522,7 @@ bool emonics::invariant() const {
mons++;
if (m_monics.size() != mons) {
TRACE("nla_solver_mons", tout << "missmatch of monic vars\n";);
TRACE(nla_solver_mons, tout << "missmatch of monic vars\n";);
return false;
}
@ -540,7 +540,7 @@ bool emonics::invariant() const {
auto w1 = m_ve.find(w);
found |= v1.var() == w1.var();
}
CTRACE("nla_solver_mons", !found, tout << "not found v" << v << ": " << m << "\n";);
CTRACE(nla_solver_mons, !found, tout << "not found v" << v << ": " << m << "\n";);
SASSERT(found);
(void)found;
c = c->m_next;
@ -563,18 +563,18 @@ bool emonics::invariant() const {
c = c->m_next;
}
while (c != c0 && !found);
CTRACE("nla_solver_mons", !found, tout << "m" << idx << " not found in use list for v" << v << "\n";);
CTRACE(nla_solver_mons, !found, tout << "m" << idx << " not found in use list for v" << v << "\n";);
return found;
};
unsigned idx = 0;
for (auto const& m : m_monics) {
CTRACE("nla_solver_mons", !m_cg_table.contains(m.var()), tout << "removed " << m << "\n"; );
CTRACE(nla_solver_mons, !m_cg_table.contains(m.var()), tout << "removed " << m << "\n"; );
SASSERT(m_cg_table.contains(m.var()));
SASSERT(m_cg_table[m.var()].contains(m.var()));
// same with rooted variables
for (auto v : m.rvars()) {
if (!find_index(v, idx)) {
TRACE("nla_solver_mons", tout << "rooted var not found in monic use list" << v << "\n";);
TRACE(nla_solver_mons, tout << "rooted var not found in monic use list" << v << "\n";);
return false;
}
}
@ -587,7 +587,7 @@ bool emonics::invariant() const {
for (auto const& k : m_cg_table) {
auto const& v = k.m_value;
if (!v.empty() && v[0] != k.m_key) {
TRACE("nla_solver_mons", tout << "bad table entry: " << k.m_key << ": " << k.m_value << "\n";);
TRACE(nla_solver_mons, tout << "bad table entry: " << k.m_key << ": " << k.m_value << "\n";);
return false;
}
}

View file

@ -135,7 +135,7 @@ public:
}
void unmerge_eh(unsigned i, unsigned j) {
TRACE("nla_solver", tout << "unmerged " << i << " and " << j << "\n";);
TRACE(nla_solver, tout << "unmerged " << i << " and " << j << "\n";);
}
void merge_eh(unsigned r2, unsigned r1, unsigned v2, unsigned v1) {}

View file

@ -59,7 +59,7 @@ struct create_cut {
void int_case_in_gomory_cut(unsigned j) {
SASSERT(is_int(j) && m_fj.is_pos());
TRACE("gomory_cut_detail",
TRACE(gomory_cut_detail,
tout << " k = " << m_k;
tout << ", fj: " << m_fj << ", ";
tout << (at_lower(j)?"at_lower":"at_upper")<< std::endl;
@ -81,7 +81,7 @@ struct create_cut {
push_explanation(column_upper_bound_constraint(j));
}
m_t.add_monomial(new_a, j);
TRACE("gomory_cut_detail", tout << "new_a = " << new_a << ", k = " << m_k << "\n";);
TRACE(gomory_cut_detail, tout << "new_a = " << new_a << ", k = " << m_k << "\n";);
if (numerator(new_a) > m_big_number)
m_found_big = true;
}
@ -93,7 +93,7 @@ struct create_cut {
}
void real_case_in_gomory_cut(const mpq & a, unsigned j) {
TRACE("gomory_cut_detail_real", tout << "j = " << j << ", a = " << a << ", m_k = " << m_k << "\n";);
TRACE(gomory_cut_detail_real, tout << "j = " << j << ", a = " << a << ", m_k = " << m_k << "\n";);
mpq new_a;
if (at_lower(j)) {
if (a.is_pos()) {
@ -126,7 +126,7 @@ struct create_cut {
push_explanation(column_upper_bound_constraint(j));
}
m_t.add_monomial(new_a, j);
TRACE("gomory_cut_detail_real", tout << "add " << new_a << "*v" << j << ", k: " << m_k << "\n";
TRACE(gomory_cut_detail_real, tout << "add " << new_a << "*v" << j << ", k: " << m_k << "\n";
tout << "m_t = "; lia.lra.print_term(m_t, tout) << "\nk: " << m_k << "\n";);
if (numerator(new_a) > m_big_number)
@ -245,7 +245,7 @@ public:
}
lia_move cut() {
TRACE("gomory_cut", dump(tout););
TRACE(gomory_cut, dump(tout););
// If m_polarity is MAX, then
// the row constraints the base variable to be at the maximum,
// MIN - at the minimum,
@ -257,7 +257,7 @@ public:
m_t.clear();
m_ex->clear();
m_found_big = false;
TRACE("gomory_cut_detail", tout << "m_f: " << m_f << ", ";
TRACE(gomory_cut_detail, tout << "m_f: " << m_f << ", ";
tout << "1 - m_f: " << 1 - m_f << ", get_value(m_inf_col).x - m_f = " << get_value(m_inf_col).x - m_f << "\n";);
SASSERT(m_f.is_pos() && (get_value(m_inf_col).x - m_f).is_int());
auto set_polarity_for_int = [&](const mpq & a, lpvar j) {
@ -319,13 +319,13 @@ public:
if (m_t.is_empty()) {
return report_conflict_from_gomory_cut();
}
TRACE("gomory_cut", print_linear_combination_of_column_indices_only(m_t.coeffs_as_vector(), tout << "gomory cut: "); tout << " >= " << m_k << std::endl;);
TRACE(gomory_cut, print_linear_combination_of_column_indices_only(m_t.coeffs_as_vector(), tout << "gomory cut: "); tout << " >= " << m_k << std::endl;);
m_dep = nullptr;
for (auto c : *m_ex)
m_dep = lia.lra.join_deps(lia.lra.dep_manager().mk_leaf(c.ci()), m_dep);
TRACE("gomory_cut_detail", dump_cut_and_constraints_as_smt_lemma(tout);
TRACE(gomory_cut_detail, dump_cut_and_constraints_as_smt_lemma(tout);
lia.lra.display(tout));
SASSERT(lia.current_solution_is_inf_on_cut());
@ -363,7 +363,7 @@ public:
if (p.coeff().is_int() && lia.column_is_int(j) && lia.get_value(j).is_int()) continue;
if ( !lia.at_bound(j) || lia.get_value(j).y != 0) {
TRACE("gomory_cut", tout << "row is not gomory cut target:\n";
TRACE(gomory_cut, tout << "row is not gomory cut target:\n";
lia.display_column(tout, j);
tout << "infinitesimal: " << !(lia.get_value(j).y ==0) << "\n";);
return false;

View file

@ -196,7 +196,7 @@ mpq determinant_of_rectangular_matrix(const M& m, svector<unsigned> & basis_rows
for (unsigned i = 0; i < rank; i++) {
basis_rows.push_back(m_copy.adjust_row(i));
}
TRACE("hnf_calc", tout << "basis_rows = "; print_vector(basis_rows, tout); m_copy.print(tout, "m_copy = "););
TRACE(hnf_calc, tout << "basis_rows = "; print_vector(basis_rows, tout); m_copy.print(tout, "m_copy = "););
return gcd_of_row_starting_from_diagonal(m_copy, rank - 1);
}
} // end of namespace hnf_calc
@ -229,7 +229,7 @@ class hnf {
mpq mod_R(const mpq & a) const {
mpq t = a % m_R;
t = is_neg(t) ? t + m_R : t;
CTRACE("hnf", is_neg(t), tout << "a=" << a << ", m_R= " << m_R << std::endl;);
CTRACE(hnf, is_neg(t), tout << "a=" << a << ", m_R= " << m_R << std::endl;);
return t;
}
@ -464,14 +464,14 @@ class hnf {
bool is_correct_final() const {
if (!is_correct()) {
TRACE("hnf_calc",
TRACE(hnf_calc,
tout << "m_H = "; m_H.print(tout, 17);
tout << "\nm_A_orig * m_U = "; (m_A_orig * m_U).print(tout, 17);
tout << "is_correct() does not hold" << std::endl;);
return false;
}
if (!is_correct_form()) {
TRACE("hnf_calc", tout << "is_correct_form() does not hold" << std::endl;);
TRACE(hnf_calc, tout << "is_correct_form() does not hold" << std::endl;);
return false;
}
return true;
@ -605,7 +605,7 @@ public:
#endif
calculate_by_modulo();
#ifdef Z3DEBUG
CTRACE("hnf_calc", m_H != m_W,
CTRACE(hnf_calc, m_H != m_W,
tout << "A = "; m_A_orig.print(tout, 4); tout << std::endl;
tout << "H = "; m_H.print(tout, 4); tout << std::endl;
tout << "W = "; m_W.print(tout, 4); tout << std::endl;);

View file

@ -251,7 +251,7 @@ branch y_i >= ceil(y0_i) is impossible.
if (!init_terms_for_hnf_cut())
return lia_move::undef;
lia.settings().stats().m_hnf_cutter_calls++;
TRACE("hnf_cut", tout << "settings().stats().m_hnf_cutter_calls = " << lia.settings().stats().m_hnf_cutter_calls << "\n";
TRACE(hnf_cut, tout << "settings().stats().m_hnf_cutter_calls = " << lia.settings().stats().m_hnf_cutter_calls << "\n";
for (u_dependency* d : constraints_for_explanation())
for (auto ci : lra.flatten(d))
lra.constraints().display(tout, ci);
@ -267,7 +267,7 @@ branch y_i >= ceil(y0_i) is impossible.
);
if (r == lia_move::cut) {
TRACE("hnf_cut",
TRACE(hnf_cut,
lra.print_term(lia.get_term(), tout << "cut:");
tout << " <= " << lia.offset() << std::endl;
for (auto* dep : constraints_for_explanation())

View file

@ -39,9 +39,9 @@ bool horner::row_has_monomial_to_refine(const T& row) const {
// Returns true if the row has at least two monomials sharing a variable
template <typename T>
bool horner::row_is_interesting(const T& row) const {
TRACE("nla_solver_details", c().print_row(row, tout););
TRACE(nla_solver_details, c().print_row(row, tout););
if (row.size() > c().params().arith_nl_horner_row_length_limit()) {
TRACE("nla_solver_details", tout << "disregard\n";);
TRACE(nla_solver_details, tout << "disregard\n";);
return false;
}
SASSERT(row_has_monomial_to_refine(row));
@ -68,7 +68,7 @@ bool horner::row_is_interesting(const T& row) const {
}
bool horner::lemmas_on_expr(cross_nested& cn, nex_sum* e) {
TRACE("nla_horner", tout << "e = " << *e << "\n";);
TRACE(nla_horner, tout << "e = " << *e << "\n";);
cn.run(e);
return cn.done();
}
@ -81,7 +81,7 @@ bool horner::lemmas_on_row(const T& row) {
create_sum_from_row(row, m_nex_creator, m_row_sum, dep);
c().set_active_vars_weights(m_nex_creator); // without this call the comparisons will be incorrect
nex* e = m_nex_creator.simplify(m_row_sum.mk());
TRACE("nla_horner", tout << "e = " << * e << "\n";);
TRACE(nla_horner, tout << "e = " << * e << "\n";);
if (e->get_degree() < 2)
return false;
if (!e->is_sum())
@ -99,7 +99,7 @@ bool horner::lemmas_on_row(const T& row) {
bool horner::horner_lemmas() {
if (!c().params().arith_nl_horner()) {
TRACE("nla_solver", tout << "not generating horner lemmas\n";);
TRACE(nla_solver, tout << "not generating horner lemmas\n";);
return false;
}
c().lp_settings().stats().m_horner_calls++;

View file

@ -30,7 +30,7 @@ lia_move int_branch::operator()() {
}
lia_move int_branch::create_branch_on_column(int j) {
TRACE("check_main_int", tout << "branching" << std::endl;);
TRACE(check_main_int, tout << "branching" << std::endl;);
lia.get_term().clear();
SASSERT(j != -1);
@ -44,7 +44,7 @@ lia_move int_branch::create_branch_on_column(int j) {
lia.offset() = lia.is_upper()? floor(lia.get_value(j)) : ceil(lia.get_value(j));
}
TRACE("int_solver",
TRACE(int_solver,
lia.display_column(tout << "branching v" << j << " = " << lia.get_value(j) << "\n", j);
tout << "k = " << lia.offset() << std::endl;);
return lia_move::branch;

View file

@ -26,7 +26,7 @@ namespace lp {
lia_move int_cube::operator()() {
lia.settings().stats().m_cube_calls++;
TRACE("cube",
TRACE(cube,
for (unsigned j = 0; j < lra.number_of_vars(); j++)
lia.display_column(tout, j);
tout << lra.constraints();
@ -41,7 +41,7 @@ namespace lp {
lp_status st = lra.find_feasible_solution();
if (st != lp_status::FEASIBLE && st != lp_status::OPTIMAL) {
TRACE("cube", tout << "cannot find a feasible solution";);
TRACE(cube, tout << "cannot find a feasible solution";);
lra.pop();
lra.move_non_basic_columns_to_bounds();
// it can happen that we found an integer solution here
@ -51,7 +51,7 @@ namespace lp {
lra.round_to_integer_solution();
lra.set_status(lp_status::FEASIBLE);
SASSERT(lia.settings().get_cancel_flag() || lia.is_feasible());
TRACE("cube", tout << "success";);
TRACE(cube, tout << "success";);
lia.settings().stats().m_cube_success++;
return lia_move::sat;
}
@ -61,7 +61,7 @@ namespace lp {
return true;
const lar_term& t = lra.get_term(i);
impq delta = get_cube_delta_for_term(t);
TRACE("cube", lra.print_term_as_indices(t, tout); tout << ", delta = " << delta << "\n";);
TRACE(cube, lra.print_term_as_indices(t, tout); tout << ", delta = " << delta << "\n";);
if (is_zero(delta))
return true;
return lra.tighten_term_bounds_by_delta(i, delta);
@ -70,7 +70,7 @@ namespace lp {
bool int_cube::tighten_terms_for_cube() {
for (const lar_term* t: lra.terms())
if (!tighten_term_for_cube(t->j())) {
TRACE("cube", tout << "cannot tighten";);
TRACE(cube, tout << "cannot tighten";);
return false;
}
return true;

View file

@ -60,7 +60,7 @@ namespace lp {
lia_move int_gcd_test::operator()() {
lia.settings().stats().m_gcd_calls++;
TRACE("int_solver", tout << "gcd-test " << lia.settings().stats().m_gcd_calls << "\n";);
TRACE(int_solver, tout << "gcd-test " << lia.settings().stats().m_gcd_calls << "\n";);
if (gcd_test()) {
m_delay = m_next_gcd++;
return lia_move::undef;
@ -69,7 +69,7 @@ namespace lp {
m_next_gcd = 0;
m_delay = 0;
lia.settings().stats().m_gcd_conflicts++;
TRACE("gcd_test", tout << "gcd conflict\n";);
TRACE(gcd_test, tout << "gcd conflict\n";);
return lia_move::conflict;
}
}
@ -147,7 +147,7 @@ namespace lp {
}
SASSERT(gcds.is_int());
SASSERT(m_least_coeff.is_int());
TRACE("gcd_test_bug", tout << "coeff: " << a << ", gcds: " << gcds
TRACE(gcd_test_bug, tout << "coeff: " << a << ", gcds: " << gcds
<< " least_coeff: " << m_least_coeff << " consts: " << m_consts << "\n";);
}
@ -160,7 +160,7 @@ namespace lp {
}
if (!(m_consts / gcds).is_int()) {
TRACE("gcd_test", tout << "row failed the GCD test:\n"; lia.display_row_info(tout, i););
TRACE(gcd_test, tout << "row failed the GCD test:\n"; lia.display_row_info(tout, i););
fill_explanation_from_fixed_columns(A.m_rows[i]);
return false;
}
@ -178,7 +178,7 @@ namespace lp {
}
bool int_gcd_test::ext_gcd_test(const row_strip<mpq> & row) {
TRACE("ext_gcd_test", tout << "row = "; lra.print_row(row, tout););
TRACE(ext_gcd_test, tout << "row = "; lra.print_row(row, tout););
mpq gcds(0);
mpq l(m_consts);
mpq u(m_consts);
@ -187,7 +187,7 @@ namespace lp {
unsigned j;
for (const auto & c : row) {
j = c.var();
TRACE("ext_gcd_test", tout << "col = "; lra.print_column_info(j, tout););
TRACE(ext_gcd_test, tout << "col = "; lra.print_column_info(j, tout););
const mpq & a = c.coeff();
if (lra.column_is_fixed(j))
continue;
@ -229,7 +229,7 @@ namespace lp {
if (u1 < l1) {
fill_explanation_from_fixed_columns(row);
TRACE("gcd_test", tout << "row failed the GCD test:\n"; lia.display_row(tout, row););
TRACE(gcd_test, tout << "row failed the GCD test:\n"; lia.display_row(tout, row););
return false;
}
return true;
@ -279,7 +279,7 @@ namespace lp {
offset = mod(offset, modulus);
if (!least_sign && offset != 0)
offset = modulus - offset;
TRACE("gcd_test", tout << least_idx << " modulus: " << modulus << " consts: " << m_consts << " sign " << least_sign << " offset: " << offset << "\n";);
TRACE(gcd_test, tout << least_idx << " modulus: " << modulus << " consts: " << m_consts << " sign " << least_sign << " offset: " << offset << "\n";);
SASSERT(0 <= offset && offset < modulus);
return insert_parity(least_idx, row, offset, modulus);

View file

@ -268,7 +268,7 @@ namespace lp {
const auto & x = lrac.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 <= impq(m_k) * sign,
CTRACE(current_solution_is_inf_on_cut, v * sign <= impq(m_k) * sign,
tout << "m_upper = " << m_upper << std::endl;
tout << "v = " << v << ", k = " << m_k << std::endl;
tout << "term:";lra.print_term(m_t, tout) << "\n";
@ -316,11 +316,11 @@ namespace lp {
if (abs(value.x) < small_value ||
(lra.column_has_upper_bound(j) && small_value > upper_bound(j).x - value.x) ||
(has_lower(j) && small_value > value.x - lower_bound(j).x)) {
TRACE("int_solver", tout << "small j" << j << "\n");
TRACE(int_solver, tout << "small j" << j << "\n");
add_column(true, r_small_value, n_small_value, j);
continue;
}
TRACE("int_solver", tout << "any j" << j << "\n");
TRACE(int_solver, tout << "any j" << j << "\n");
add_column(usage >= prev_usage, r_any_value, n_any_value, j);
if (usage > prev_usage)
prev_usage = usage;
@ -529,7 +529,7 @@ namespace lp {
if (lrac.m_r_heading[j] >= 0 || is_fixed(j)) // basic or fixed var
return false;
TRACE("random_update", display_column(tout, j) << ", is_int = " << column_is_int(j) << "\n";);
TRACE(random_update, display_column(tout, j) << ", is_int = " << column_is_int(j) << "\n";);
impq const & xj = get_value(j);
inf_l = true;
@ -545,7 +545,7 @@ namespace lp {
const auto & A = lra.A_r();
TRACE("random_update", tout << "m = " << m << "\n";);
TRACE(random_update, tout << "m = " << m << "\n";);
auto delta = [](mpq const& x, impq const& y, impq const& z) {
if (x.is_one())
@ -584,7 +584,7 @@ namespace lp {
l += xj;
u += xj;
TRACE("freedom_interval",
TRACE(freedom_interval,
tout << "freedom variable for:\n";
tout << lra.get_variable_name(j);
tout << "[";
@ -736,13 +736,13 @@ namespace lp {
mpq r = a - b;
if (!r.is_pos())
return false;
TRACE("int_solver", tout << "a = " << a << ", b = " << b << ", r = " << r<< ", m = " << m << "\n";);
TRACE(int_solver, tout << "a = " << a << ", b = " << b << ", r = " << r<< ", m = " << m << "\n";);
if (r < mpq(range))
range = static_cast<unsigned>(r.get_uint64());
mpq s = b + mpq(lra.settings().random_next() % (range + 1));
impq new_val = x + m * impq(s);
TRACE("int_solver", tout << "new_val = " << new_val << "\n";);
TRACE(int_solver, tout << "new_val = " << new_val << "\n";);
SASSERT(l <= new_val && new_val <= u);
lra.set_value_for_nbasic_column(j, new_val);
return true;

View file

@ -83,13 +83,13 @@ unsigned lar_core_solver::get_number_of_non_ints() const {
}
void lar_core_solver::solve() {
TRACE("lar_solver", tout << m_r_solver.get_status() << "\n";);
TRACE(lar_solver, tout << m_r_solver.get_status() << "\n";);
SASSERT(m_r_solver.non_basic_columns_are_set_correctly());
SASSERT(m_r_solver.inf_heap_is_correct());
TRACE("find_feas_stats", tout << "infeasibles = " << m_r_solver.inf_heap_size() << ", int_infs = " << get_number_of_non_ints() << std::endl;);
TRACE(find_feas_stats, tout << "infeasibles = " << m_r_solver.inf_heap_size() << ", int_infs = " << get_number_of_non_ints() << std::endl;);
if (m_r_solver.current_x_is_feasible() && m_r_solver.m_look_for_feasible_solution_only) {
m_r_solver.set_status(lp_status::OPTIMAL);
TRACE("lar_solver", tout << m_r_solver.get_status() << "\n";);
TRACE(lar_solver, tout << m_r_solver.get_status() << "\n";);
return;
}
++m_r_solver.m_settings.stats().m_need_to_solve_inf;
@ -118,7 +118,7 @@ void lar_core_solver::solve() {
SASSERT(m_r_solver.non_basic_columns_are_set_correctly());
SASSERT(m_r_solver.inf_heap_is_correct());
TRACE("lar_solver", tout << m_r_solver.get_status() << "\n";);
TRACE(lar_solver, tout << m_r_solver.get_status() << "\n";);
}
} // namespace lp

View file

@ -117,7 +117,7 @@ namespace lp {
lar_solver solver;
solver.m_validate_blocker = true;
TRACE("lar_solver_validate", tout << lra.get_variable_name(j) << " " << lconstraint_kind_string(kind) << " " << rs << std::endl;);
TRACE(lar_solver_validate, tout << lra.get_variable_name(j) << " " << lconstraint_kind_string(kind) << " " << rs << std::endl;);
lra.add_dep_constraints_to_solver(solver, dep);
if (solver.external_to_local(j) == null_lpvar) {
return false; // we have to mention j in the dep
@ -163,12 +163,12 @@ namespace lp {
}
}
CTRACE("arith", !lra.column_is_fixed(k), lra.print_terms(tout););
CTRACE(arith, !lra.column_is_fixed(k), lra.print_terms(tout););
// SASSERT(column_is_fixed(k));
if (j != k && lra.column_is_fixed(k)) {
SASSERT(lra.column_is_int(j) == lra.column_is_int(k));
equal_to_j = k;
TRACE("lar_solver", tout << "found equal column k = " << k <<
TRACE(lar_solver, tout << "found equal column k = " << k <<
", external = " << equal_to_j << "\n";);
}
}
@ -375,7 +375,7 @@ namespace lp {
lp_status lar_solver::get_status() const { return m_imp->m_status; }
void lar_solver::set_status(lp_status s) {
TRACE("lar_solver", tout << "setting status to " << s << "\n";);
TRACE(lar_solver, tout << "setting status to " << s << "\n";);
m_imp->m_status = s;
}
const u_dependency* lar_solver::crossed_bounds_deps() const { return m_imp->m_crossed_bounds_deps;}
@ -548,7 +548,7 @@ namespace lp {
void lar_solver::pop(unsigned k) {
TRACE("lar_solver", tout << "k = " << k << std::endl;);
TRACE(lar_solver, tout << "k = " << k << std::endl;);
m_imp->m_crossed_bounds_column = null_lpvar;
m_imp->m_crossed_bounds_deps = nullptr;
m_imp->m_trail.pop_scope(k);
@ -559,7 +559,7 @@ namespace lp {
SASSERT(get_core_solver().m_r_solver.m_basis.size() == A_r().row_count());
SASSERT(get_core_solver().m_r_solver.basis_heading_is_correct());
SASSERT(A_r().column_count() == n);
TRACE("lar_solver_details", for (unsigned j = 0; j < n; j++) print_column_info(j, tout) << "\n";);
TRACE(lar_solver_details, for (unsigned j = 0; j < n; j++) print_column_info(j, tout) << "\n";);
get_core_solver().pop(k);
remove_non_fixed_from_fixed_var_table();
@ -592,7 +592,7 @@ namespace lp {
get_core_solver().m_r_solver.set_status(lp_status::FEASIBLE);
get_core_solver().solve();
lp_status st = get_core_solver().m_r_solver.get_status();
TRACE("lar_solver", tout << st << "\n";);
TRACE(lar_solver, tout << st << "\n";);
SASSERT(get_core_solver().m_r_solver.calc_current_x_is_feasible_include_non_basis());
if (st == lp_status::UNBOUNDED || st == lp_status::CANCELLED) {
return false;
@ -613,7 +613,7 @@ namespace lp {
for (const auto & [d_j, j]: max_coeffs) {
SASSERT (!d_j.is_zero());
TRACE("lar_solver_improve_bounds", tout << "d[" << j << "] = " << d_j << "\n";
TRACE(lar_solver_improve_bounds, tout << "d[" << j << "] = " << d_j << "\n";
this->get_core_solver().m_r_solver.print_column_info(j, tout););
const column& ul = m_imp->m_columns[j];
u_dependency * bound_dep;
@ -621,7 +621,7 @@ namespace lp {
bound_dep = ul.upper_bound_witness();
else
bound_dep = ul.lower_bound_witness();
TRACE("lar_solver_improve_bounds", {
TRACE(lar_solver_improve_bounds, {
svector<constraint_index> cs;
dep_manager().linearize(bound_dep, cs);
for (auto c : cs)
@ -646,7 +646,7 @@ namespace lp {
if (lower_bound)
term.negate();
vector<std::pair<mpq, unsigned>> max_coeffs;
TRACE("lar_solver_improve_bounds", tout << "j = " << j << ", "; print_term(term, tout << "term to maximize\n"););
TRACE(lar_solver_improve_bounds, tout << "j = " << j << ", "; print_term(term, tout << "term to maximize\n"););
impq term_max;
if (!maximize_term_on_feasible_r_solver(term, term_max, &max_coeffs))
return nullptr;
@ -664,7 +664,7 @@ namespace lp {
if (column_has_lower_bound(j) && column_is_int(j) && bound <= column_lower_bound(j).x)
return nullptr;
TRACE("lar_solver_improve_bounds",
TRACE(lar_solver_improve_bounds,
tout << "setting lower bound for " << j << " to " << bound << "\n";
if (column_has_lower_bound(j)) tout << "bound was = " << column_lower_bound(j) << "\n";);
}
@ -676,7 +676,7 @@ namespace lp {
if (bound >= column_upper_bound(j).x)
return nullptr;
}
TRACE("lar_solver_improve_bounds",
TRACE(lar_solver_improve_bounds,
tout << "setting upper bound for " << j << " to " << bound << "\n";
if (column_has_upper_bound(j)) tout << "bound was = " << column_upper_bound(j) << "\n";;);
}
@ -716,7 +716,7 @@ namespace lp {
}
void lar_solver::prepare_costs_for_r_solver(const lar_term& term) {
TRACE("lar_solver", print_term(term, tout << "prepare: ") << "\n";);
TRACE(lar_solver, print_term(term, tout << "prepare: ") << "\n";);
auto& rslv = get_core_solver().m_r_solver;
SASSERT(costs_are_zeros_for_r_solver());
SASSERT(reduced_costs_are_zeroes_for_r_solver());
@ -795,7 +795,7 @@ namespace lp {
auto& x = get_core_solver().r_x(j);
auto delta = new_val - x;
x = new_val;
TRACE("lar_solver_feas", tout << "setting " << j << " to "
TRACE(lar_solver_feas, tout << "setting " << j << " to "
<< new_val << (column_is_feasible(j)?"feas":"non-feas") << "\n";);
change_basic_columns_dependend_on_a_given_nb_column(j, delta);
}
@ -804,7 +804,7 @@ namespace lp {
impq& term_max, vector<std::pair<mpq, lpvar>>* max_coeffs = nullptr) {
settings().backup_costs = false;
bool ret = false;
TRACE("lar_solver", print_term(term, tout << "maximize: ") << "\n"
TRACE(lar_solver, print_term(term, tout << "maximize: ") << "\n"
<< constraints() << ", strategy = " << (int)settings().simplex_strategy() << "\n";);
if (settings().simplex_strategy() != simplex_strategy_enum::tableau_costs)
m_imp->require_nbasis_sort();
@ -817,7 +817,7 @@ namespace lp {
if (d_j.is_zero())
continue;
max_coeffs->push_back(std::make_pair(d_j, j));
TRACE("lar_solver", tout<<"m_d["<<j<<"] = " << d_j<< ",\n";print_column_info(j, tout) << "\n";);
TRACE(lar_solver, tout<<"m_d["<<j<<"] = " << d_j<< ",\n";print_column_info(j, tout) << "\n";);
}
}
set_costs_to_zero(term);
@ -849,7 +849,7 @@ namespace lp {
lp_status lar_solver::maximize_term(unsigned j,
impq& term_max) {
TRACE("lar_solver", print_values(tout););
TRACE(lar_solver, print_values(tout););
SASSERT(get_core_solver().m_r_solver.calc_current_x_is_feasible_include_non_basis());
lar_term term = get_term_to_maximize(j);
if (term.is_empty()) return lp_status::UNBOUNDED;
@ -892,7 +892,7 @@ namespace lp {
term_max = prev_value;
restore();
}
TRACE("lar_solver", print_values(tout););
TRACE(lar_solver, print_values(tout););
if (term_max == opt_val) {
set_status(lp_status::OPTIMAL);
return lp_status::OPTIMAL;
@ -1024,7 +1024,7 @@ namespace lp {
return;
tabu.insert(j);
IF_VERBOSE(10, verbose_stream() << "solve for " << j << " base " << is_base(j) << " " << column_is_fixed(j) << "\n");
TRACE("arith", tout << "solve for " << j << " base " << is_base(j) << " " << column_is_fixed(j) << "\n");
TRACE(arith, tout << "solve for " << j << " base " << is_base(j) << " " << column_is_fixed(j) << "\n");
if (column_is_fixed(j))
return;
@ -1096,7 +1096,7 @@ namespace lp {
update_column_type_and_bound(j, hi.y == 0 ? lconstraint_kind::LE : lconstraint_kind::LT, hi.x, dep);
}
TRACE("arith", print_term(t, tout << "j" << j << " := ") << "\n");
TRACE(arith, print_term(t, tout << "j" << j << " := ") << "\n");
if (!column_is_fixed(j))
sols.push_back({j, t});
}
@ -1144,7 +1144,7 @@ namespace lp {
if (column_is_fixed(j)) {
for (const auto & c : A_r().m_rows[i] ) {
if (!column_is_fixed(c.var())) {
TRACE("lar_solver", print_row(A_r().m_rows[i], tout) << "\n";
TRACE(lar_solver, print_row(A_r().m_rows[i], tout) << "\n";
for(const auto & c : A_r().m_rows[i]) {
print_column_info(c.var(), tout) << "\n";
});
@ -1165,7 +1165,7 @@ namespace lp {
for (const auto& c : A_r().m_rows[i]) {
r += c.coeff() * get_core_solver().r_x(c.var());
}
CTRACE("lar_solver", !is_zero(r), tout << "row = " << i << ", j = " << get_core_solver().m_r_basis[i] << "\n";
CTRACE(lar_solver, !is_zero(r), tout << "row = " << i << ", j = " << get_core_solver().m_r_basis[i] << "\n";
print_row(A_r().m_rows[i], tout); tout << " = " << r << "\n");
return is_zero(r);
}
@ -1199,7 +1199,7 @@ namespace lp {
m_imp->m_basic_columns_with_changed_cost.insert(bj);
}
get_core_solver().m_r_solver.add_delta_to_x_and_track_feasibility(bj, -A_r().get_val(c) * delta);
TRACE("change_x_del",
TRACE(change_x_del,
tout << "changed basis column " << bj << ", it is " <<
(column_is_feasible(bj) ? "feas" : "inf") << std::endl;);
}
@ -1300,7 +1300,7 @@ namespace lp {
for (auto const& c : m_imp->m_constraints.active()) {
if (!constraint_holds(c, var_map)) {
TRACE("lar_solver",
TRACE(lar_solver,
m_imp->m_constraints.display(tout, c) << "\n";
for (auto p : c.coeffs()) {
get_core_solver().m_r_solver.print_column_info(p.second, tout);
@ -1498,7 +1498,7 @@ namespace lp {
for (unsigned j = 0; j < n; j++)
variable_values[j] = get_value(j);
TRACE("lar_solver_model", tout << "delta = " << m_imp->m_delta << "\nmodel:\n";
TRACE(lar_solver_model, tout << "delta = " << m_imp->m_delta << "\nmodel:\n";
for (auto p : variable_values) tout << this->get_variable_name(p.first) << " = " << p.second << "\n";);
}
@ -1508,8 +1508,8 @@ namespace lp {
SASSERT(A_r().column_count() == rslv.m_costs.size());
SASSERT(A_r().column_count() == get_core_solver().r_x().size());
SASSERT(A_r().column_count() == rslv.m_d.size());
CTRACE("lar_solver_model",!m_imp->m_columns_with_changed_bounds.empty(), tout << "non-empty changed bounds\n");
TRACE("lar_solver_model", tout << get_status() << "\n");
CTRACE(lar_solver_model,!m_imp->m_columns_with_changed_bounds.empty(), tout << "non-empty changed bounds\n");
TRACE(lar_solver_model, tout << get_status() << "\n");
auto status = get_status();
SASSERT((status != lp_status::OPTIMAL && status != lp_status::FEASIBLE)
|| rslv.calc_current_x_is_feasible_include_non_basis());
@ -1535,7 +1535,7 @@ namespace lp {
}
}
} while (j != n);
TRACE("lar_solver_model", tout << "delta = " << m_imp->m_delta << "\nmodel:\n";);
TRACE(lar_solver_model, tout << "delta = " << m_imp->m_delta << "\nmodel:\n";);
return true;
}
@ -1569,7 +1569,7 @@ namespace lp {
auto& v = get_core_solver().r_x(j);
if (!v.y.is_zero()) {
v = impq(v.x + delta * v.y);
TRACE("lar_solver_feas", tout << "x[" << j << "] = " << v << "\n";);
TRACE(lar_solver_feas, tout << "x[" << j << "] = " << v << "\n";);
}
}
}
@ -1660,7 +1660,7 @@ namespace lp {
void lar_solver::fill_var_set_for_random_update(unsigned sz, lpvar const* vars, vector<unsigned>& column_list) {
TRACE("lar_solver_rand", tout << "sz = " << sz << "\n";);
TRACE(lar_solver_rand, tout << "sz = " << sz << "\n";);
for (unsigned i = 0; i < sz; i++) {
lpvar var = vars[i];
if (column_has_term(var)) {
@ -1895,7 +1895,7 @@ namespace lp {
};
lpvar lar_solver::add_var(unsigned ext_j, bool is_int) {
TRACE("add_var", tout << "adding var " << ext_j << (is_int ? " int" : " nonint") << std::endl;);
TRACE(add_var, tout << "adding var " << ext_j << (is_int ? " int" : " nonint") << std::endl;);
lpvar local_j;
if (m_imp->m_var_register.external_is_used(ext_j, local_j))
return local_j;
@ -1931,7 +1931,7 @@ namespace lp {
void lar_solver::add_new_var_to_core_fields_for_mpq(bool register_in_basis) {
unsigned j = A_r().column_count();
TRACE("add_var", tout << "j = " << j << std::endl;);
TRACE(add_var, tout << "j = " << j << std::endl;);
A_r().add_column();
SASSERT(get_core_solver().r_x().size() == j);
// SASSERT(get_core_solver().m_r_lower_bounds.size() == j && get_core_solver().m_r_upper_bounds.size() == j); // restore later
@ -2007,7 +2007,7 @@ namespace lp {
}
// if UINT_MAX == null_lpvar then the term does not correspond and external variable
lpvar lar_solver::add_term(const vector<std::pair<mpq, lpvar>>& coeffs, unsigned ext_i) {
TRACE("lar_solver_terms", print_linear_combination_of_column_indices_only(coeffs, tout) << ", ext_i =" << ext_i << "\n";);
TRACE(lar_solver_terms, print_linear_combination_of_column_indices_only(coeffs, tout) << ", ext_i =" << ext_i << "\n";);
SASSERT(!m_imp->m_var_register.external_is_used(ext_i));
SASSERT(all_vars_are_registered(coeffs));
lar_term* t = new lar_term(coeffs);
@ -2026,7 +2026,7 @@ namespace lp {
}
void lar_solver::add_row_from_term_no_constraint(lar_term* term, unsigned ext_index) {
TRACE("dump_terms", print_term(*term, tout) << std::endl;);
TRACE(dump_terms, print_term(*term, tout) << std::endl;);
register_new_external_var(ext_index, term_is_int(term));
// j will be a new variable
unsigned j = A_r().column_count();
@ -2127,7 +2127,7 @@ namespace lp {
}
constraint_index lar_solver::mk_var_bound(lpvar j, lconstraint_kind kind, const mpq& right_side) {
TRACE("lar_solver", tout << "j = " << get_variable_name(j) << " " << lconstraint_kind_string(kind) << " " << right_side << std::endl;);
TRACE(lar_solver, tout << "j = " << get_variable_name(j) << " " << lconstraint_kind_string(kind) << " " << right_side << std::endl;);
constraint_index ci;
if (!column_has_term(j)) {
mpq rs = adjust_bound_for_int(j, kind, right_side);
@ -2161,7 +2161,7 @@ namespace lp {
void lar_solver::update_column_type_and_bound(unsigned j,
const mpq& right_side,
constraint_index constr_index) {
TRACE("lar_solver_feas", tout << "j = " << j << " was " << (this->column_is_feasible(j)?"feas":"non-feas") << std::endl;);
TRACE(lar_solver_feas, tout << "j = " << j << " was " << (this->column_is_feasible(j)?"feas":"non-feas") << std::endl;);
m_imp->m_constraints.activate(constr_index);
lconstraint_kind kind = m_imp->m_constraints[constr_index].kind();
u_dependency* dep = m_imp->m_constraints[constr_index].dep();
@ -2200,7 +2200,7 @@ namespace lp {
}
void lar_solver::add_constraint_to_validate(lar_solver& ls, constraint_index ci) {
auto const& c = m_imp->m_constraints[ci];
TRACE("lar_solver_validate", tout << "adding constr with column = "<< c.column() << "\n"; m_imp->m_constraints.display(tout, c); tout << std::endl;);
TRACE(lar_solver_validate, tout << "adding constr with column = "<< c.column() << "\n"; m_imp->m_constraints.display(tout, c); tout << std::endl;);
vector<std::pair<mpq, lpvar>> coeffs;
for (auto const& [coeff, jext] : c.coeffs()) {
lpvar j = ls.external_to_local(jext);
@ -2225,7 +2225,7 @@ namespace lp {
void lar_solver::update_column_type_and_bound(unsigned j, lconstraint_kind kind, const mpq& right_side, u_dependency* dep) {
// SASSERT(validate_bound(j, kind, right_side, dep));
TRACE(
"lar_solver_feas",
lar_solver_feas,
tout << "j" << j << " " << lconstraint_kind_string(kind) << " " << right_side << std::endl;
print_column_info(j, tout) << "\n";
if (dep) {
@ -2250,7 +2250,7 @@ namespace lp {
m_imp->m_fixed_base_var_set.insert(j);
TRACE("lar_solver_feas", tout << "j = " << j << " became " << (this->column_is_feasible(j) ? "feas" : "non-feas") << ", and " << (this->column_is_bounded(j) ? "bounded" : "non-bounded") << std::endl;);
TRACE(lar_solver_feas, tout << "j = " << j << " became " << (this->column_is_feasible(j) ? "feas" : "non-feas") << ", and " << (this->column_is_bounded(j) ? "bounded" : "non-bounded") << std::endl;);
if (m_update_column_bound_callback)
m_update_column_bound_callback(j);
@ -2266,7 +2266,7 @@ namespace lp {
void lar_solver::insert_to_columns_with_changed_bounds(unsigned j) {
m_imp->m_columns_with_changed_bounds.insert(j);
TRACE("lar_solver", tout << "column " << j << (column_is_feasible(j) ? " feas" : " non-feas") << "\n";);
TRACE(lar_solver, tout << "column " << j << (column_is_feasible(j) ? " feas" : " non-feas") << "\n";);
}
void lar_solver::update_column_type_and_bound_check_on_equal(unsigned j,
@ -2532,15 +2532,15 @@ namespace lp {
bool lar_solver::tighten_term_bounds_by_delta(lpvar j, const impq& delta) {
SASSERT(column_has_term(j));
TRACE("cube", tout << "delta = " << delta << std::endl;
TRACE(cube, tout << "delta = " << delta << std::endl;
m_imp->m_int_solver->display_column(tout, j); );
if (column_has_upper_bound(j) && column_has_lower_bound(j)) {
if (get_upper_bound(j) - delta < get_lower_bound(j) + delta) {
TRACE("cube", tout << "cannot tighten, delta = " << delta;);
TRACE(cube, tout << "cannot tighten, delta = " << delta;);
return false;
}
}
TRACE("cube", tout << "can tighten";);
TRACE(cube, tout << "can tighten";);
if (column_has_upper_bound(j)) {
if (!is_zero(delta.y) || !is_zero(get_upper_bound(j).y))
add_var_bound(j, lconstraint_kind::LT, get_upper_bound(j).x - delta.x);
@ -2564,7 +2564,7 @@ namespace lp {
impq & v = get_core_solver().r_x(j);
if (v.is_int())
continue;
TRACE("cube", m_imp->m_int_solver->display_column(tout, j););
TRACE(cube, m_imp->m_int_solver->display_column(tout, j););
impq flv = impq(floor(v));
auto del = flv - v; // del is negative
if (del < -impq(mpq(1, 2))) {
@ -2575,7 +2575,7 @@ namespace lp {
v = flv;
}
m_imp->m_incorrect_columns.insert(j);
TRACE("cube", tout << "new val = " << v << " column: " << j << "\n";);
TRACE(cube, tout << "new val = " << v << " column: " << j << "\n";);
}
if (!m_imp->m_incorrect_columns.empty()) {
fix_terms_with_rounded_columns();
@ -2671,18 +2671,18 @@ namespace lp {
void lar_solver::register_normalized_term(const lar_term& t, lpvar j) {
mpq a;
lar_term normalized_t = t.get_normalized_by_min_var(a);
TRACE("lar_solver_terms", tout << "t="; print_term_as_indices(t, tout);
TRACE(lar_solver_terms, tout << "t="; print_term_as_indices(t, tout);
tout << ", normalized_t="; print_term_as_indices(normalized_t, tout) << "\n";);
if (m_imp->m_normalized_terms_to_columns.find(normalized_t) == m_imp->m_normalized_terms_to_columns.end()) {
m_imp->m_normalized_terms_to_columns[normalized_t] = std::make_pair(a, j);
}
else {
TRACE("lar_solver_terms", tout << "the term has been seen already\n";);
TRACE(lar_solver_terms, tout << "the term has been seen already\n";);
}
}
void lar_solver::deregister_normalized_term(const lar_term& t) {
TRACE("lar_solver_terms", tout << "deregister term ";
TRACE(lar_solver_terms, tout << "deregister term ";
print_term_as_indices(t, tout) << "\n";);
mpq a;
lar_term normalized_t = t.get_normalized_by_min_var(a);
@ -2691,7 +2691,7 @@ namespace lp {
void lar_solver::register_existing_terms() {
if (!m_imp->m_need_register_terms) {
TRACE("nla_solver", tout << "registering " << m_imp->m_terms.size() << " terms\n";);
TRACE(nla_solver, tout << "registering " << m_imp->m_terms.size() << " terms\n";);
for (const lar_term* t : m_imp->m_terms) {
register_normalized_term(*t, t->j());
}
@ -2701,15 +2701,15 @@ namespace lp {
// a_j.first gives the normalised coefficient,
// a_j.second givis the column
bool lar_solver::fetch_normalized_term_column(const lar_term& c, std::pair<mpq, lpvar>& a_j) const {
TRACE("lar_solver_terms", print_term_as_indices(c, tout << "looking for term ") << "\n";);
TRACE(lar_solver_terms, print_term_as_indices(c, tout << "looking for term ") << "\n";);
SASSERT(c.is_normalized());
auto it = m_imp->m_normalized_terms_to_columns.find(c);
if (it != m_imp->m_normalized_terms_to_columns.end()) {
TRACE("lar_solver_terms", tout << "got " << it->second << "\n";);
TRACE(lar_solver_terms, tout << "got " << it->second << "\n";);
a_j = it->second;
return true;
}
TRACE("lar_solver_terms", tout << "have not found\n";);
TRACE(lar_solver_terms, tout << "have not found\n";);
return false;
}
@ -2758,7 +2758,7 @@ namespace lp {
u_dependency* bdep = lower_bound? ul.lower_bound_witness() : ul.upper_bound_witness();
SASSERT(bdep != nullptr);
m_imp->m_crossed_bounds_deps = dep_manager().mk_join(bdep, dep);
TRACE("dio", tout << "crossed_bound_deps:\n"; print_explanation(tout, flatten(m_imp->m_crossed_bounds_deps)) << "\n";);
TRACE(dio, tout << "crossed_bound_deps:\n"; print_explanation(tout, flatten(m_imp->m_crossed_bounds_deps)) << "\n";);
}
const indexed_uint_set & lar_solver::touched_rows() const { return m_imp->m_touched_rows; }
indexed_uint_set & lar_solver::touched_rows() { return m_imp->m_touched_rows; }

View file

@ -349,7 +349,7 @@ public:
basic_columns_with_changed_cost().insert(bj);
get_core_solver().m_r_solver.add_delta_to_x_and_track_feasibility(bj, -A_r().get_val(c) * delta);
after(bj);
TRACE("change_x_del",
TRACE(change_x_del,
tout << "changed basis column " << bj << ", it is " << (get_core_solver().m_r_solver.column_is_feasible(bj) ? "feas" : "inf") << std::endl;);
}
}
@ -371,7 +371,7 @@ public:
const Blocker& is_blocked,
const ChangeReport& change_report) {
if (is_base(j)) {
TRACE("nla_solver", get_int_solver()->display_row_info(tout, row_of_basic_column(j)) << "\n";);
TRACE(nla_solver, get_int_solver()->display_row_info(tout, row_of_basic_column(j)) << "\n";);
if (!remove_from_basis(j))
return false;
}
@ -379,7 +379,7 @@ public:
impq ival(val);
if (is_blocked(j, ival))
return false;
TRACE("nla_solver", tout << "j" << j << " not blocked\n";);
TRACE(nla_solver, tout << "j" << j << " not blocked\n";);
impq delta = get_column_value(j) - ival;
for (auto c : A_r().column(j)) {
unsigned row_index = c.var();

View file

@ -90,7 +90,7 @@ private:
explanation ex;
explain_fixed_in_row(r1, ex);
explain_fixed_in_row(r2, ex);
TRACE("eq", print_row(tout, r1); print_row(tout, r2); tout << v1 << " == " << v2 << " = " << val(v1) << "\n");
TRACE(eq, print_row(tout, r1); print_row(tout, r2); tout << v1 << " == " << v2 << " = " << val(v1) << "\n");
add_eq_on_columns(ex, v1, v2, true);
}
@ -162,12 +162,12 @@ public:
found_bound.m_bound = v;
found_bound.m_strict = strict;
found_bound.set_explain(explain_bound);
TRACE("add_bound", lp().print_implied_bound(found_bound, tout););
TRACE(add_bound, lp().print_implied_bound(found_bound, tout););
}
} else {
m_improved_lower_bounds.insert(j, static_cast<unsigned>(m_ibounds.size()));
m_ibounds.push_back(implied_bound(v, j, is_low, strict, explain_bound));
TRACE("add_bound", lp().print_implied_bound(m_ibounds.back(), tout););
TRACE(add_bound, lp().print_implied_bound(m_ibounds.back(), tout););
}
} else { // the upper bound case
unsigned k;
@ -178,12 +178,12 @@ public:
found_bound.m_bound = v;
found_bound.m_strict = strict;
found_bound.set_explain(explain_bound);
TRACE("add_bound", lp().print_implied_bound(found_bound, tout););
TRACE(add_bound, lp().print_implied_bound(found_bound, tout););
}
} else {
m_improved_upper_bounds.insert(j, static_cast<unsigned>(m_ibounds.size()));
m_ibounds.push_back(implied_bound(v, j, is_low, strict, explain_bound));
TRACE("add_bound", lp().print_implied_bound(m_ibounds.back(), tout););
TRACE(add_bound, lp().print_implied_bound(m_ibounds.back(), tout););
}
}
}
@ -217,7 +217,7 @@ public:
SASSERT(je != ke && is_int(je) == is_int(ke));
SASSERT(ival(je) == ival(ke));
TRACE("eq",
TRACE(eq,
tout << "reported idx " << je << ", " << ke << "\n";
lp().print_expl(tout, exp);
tout << "theory_vars v" << lp().local_to_external(je) << " == v" << lp().local_to_external(ke) << "\n";);
@ -247,7 +247,7 @@ public:
}
void explain_fixed_in_row(unsigned row, explanation& ex) {
TRACE("eq", tout << lp().get_row(row) << std::endl);
TRACE(eq, tout << lp().get_row(row) << std::endl);
for (const auto& c : lp().get_row(row))
if (lp().column_is_fixed(c.var()))
lp().explain_fixed_column(c.var(), ex);
@ -255,7 +255,7 @@ public:
unsigned explain_fixed_in_row_and_get_base(unsigned row, explanation& ex) {
unsigned base = UINT_MAX;
TRACE("eq", tout << lp().get_row(row) << std::endl);
TRACE(eq, tout << lp().get_row(row) << std::endl);
for (const auto& c : lp().get_row(row)) {
if (lp().column_is_fixed(c.var())) {
lp().explain_fixed_column(c.var(), ex);
@ -342,7 +342,7 @@ public:
try_add_equation_with_internal_fixed_tables(row_index);
return;
}
TRACE("eq",
TRACE(eq,
tout << "v_j = ";
lp().print_column_info(v_j, tout) << std::endl;
tout << "found j " << j << std::endl; lp().print_column_info(j, tout) << std::endl;
@ -356,7 +356,7 @@ public:
void cheap_eq_on_nbase(unsigned row_index) {
reset_cheap_eq _reset(*this);
TRACE("eq", tout << "row_index = " << row_index << "\n";
TRACE(eq, tout << "row_index = " << row_index << "\n";
print_row(tout, row_index) << "\n";);
if (!check_insert(m_visited_rows, row_index))
return;
@ -378,7 +378,7 @@ public:
SASSERT(lp().is_base(y) == false);
auto& table = y_sign == 1 ? m_row2index_pos : m_row2index_neg;
table.insert(val(x), row_index);
TRACE("eq", tout << "y = " << y << "\n";);
TRACE(eq, tout << "y = " << y << "\n";);
for (const column_cell& c : lp().get_column(y)) {
unsigned i = c.var(); // the running index of the row
@ -406,7 +406,7 @@ public:
continue;
explain_fixed_in_row(found_i, ex);
explain_fixed_in_row(i, ex);
TRACE("eq", {
TRACE(eq, {
print_row(tout, i);
print_row(tout, found_i) << "\n";
lp().print_column_info(base_of_found, tout);

View file

@ -55,7 +55,7 @@ private:
lp_status m_status;
public:
bool current_x_is_feasible() const {
TRACE("feas_bug",
TRACE(feas_bug,
if (!m_inf_heap.empty()) {
tout << "column " << *m_inf_heap.begin() << " is infeasible" << std::endl;
print_column_info(*m_inf_heap.begin(), tout);
@ -211,7 +211,7 @@ public:
d -= this->m_costs[this->m_basis[cc.var()]] * this->m_A.get_val(cc);
}
if (m_d[j] != d) {
TRACE("lar_solver", tout << "reduced costs are incorrect for column j = " << j << " should be " << d << " but we have m_d[j] = " << m_d[j] << std::endl;);
TRACE(lar_solver, tout << "reduced costs are incorrect for column j = " << j << " should be " << d << " but we have m_d[j] = " << m_d[j] << std::endl;);
return false;
}
}
@ -364,7 +364,7 @@ public:
}
void change_basis_unconditionally(unsigned entering, unsigned leaving) {
TRACE("lar_solver", tout << "entering = " << entering << ", leaving = " << leaving << "\n";);
TRACE(lar_solver, tout << "entering = " << entering << ", leaving = " << leaving << "\n";);
SASSERT(m_basis_heading[entering] < 0);
int place_in_non_basis = -1 - m_basis_heading[entering];
if (static_cast<unsigned>(place_in_non_basis) >= m_nbasis.size()) {
@ -384,7 +384,7 @@ public:
}
void change_basis(unsigned entering, unsigned leaving) {
TRACE("lar_solver", tout << "entering = " << entering << ", leaving = " << leaving << "\n";);
TRACE(lar_solver, tout << "entering = " << entering << ", leaving = " << leaving << "\n";);
SASSERT(m_basis_heading[entering] < 0);
SASSERT(m_basis_heading[leaving] >= 0);
@ -410,7 +410,7 @@ public:
bool non_basic_columns_are_set_correctly() const {
for (unsigned j : this->m_nbasis)
if (!column_is_feasible(j)) {
TRACE("lp_core", tout << "inf col "; print_column_info(j, tout) << "\n";);
TRACE(lp_core, tout << "inf col "; print_column_info(j, tout) << "\n";);
return false;
}
@ -545,20 +545,20 @@ public:
}
void add_delta_to_x_and_track_feasibility(unsigned j, const X & del) {
TRACE("lar_solver_feas", tout << "del = " << del << ", was x[" << j << "] = " << m_x[j] << "\n";);
TRACE(lar_solver_feas, tout << "del = " << del << ", was x[" << j << "] = " << m_x[j] << "\n";);
m_x[j] += del;
TRACE("lar_solver_feas", tout << "became x[" << j << "] = " << m_x[j] << "\n";);
TRACE(lar_solver_feas, tout << "became x[" << j << "] = " << m_x[j] << "\n";);
track_column_feasibility(j);
}
void update_x(unsigned j, const X & v) {
m_x[j] = v;
TRACE("lar_solver_feas", tout << "not tracking feas j = " << j << ", v = " << v << (column_is_feasible(j)? " feas":" non-feas") << "\n";);
TRACE(lar_solver_feas, tout << "not tracking feas j = " << j << ", v = " << v << (column_is_feasible(j)? " feas":" non-feas") << "\n";);
}
void add_delta_to_x(unsigned j, const X& delta) {
m_x[j] += delta;
TRACE("lar_solver_feas", tout << "not tracking feas j = " << j << " v = " << m_x[j] << " delta = " << delta << (column_is_feasible(j) ? " feas" : " non-feas") << "\n";);
TRACE(lar_solver_feas, tout << "not tracking feas j = " << j << " v = " << m_x[j] << " delta = " << delta << (column_is_feasible(j) ? " feas" : " non-feas") << "\n";);
}
void track_column_feasibility(unsigned j) {
@ -571,20 +571,20 @@ public:
if (!m_inf_heap.contains(j)) {
m_inf_heap.reserve(j+1);
m_inf_heap.insert(j);
TRACE("lar_solver_inf_heap", tout << "insert into inf_heap j = " << j << "\n";);
TRACE(lar_solver_inf_heap, tout << "insert into inf_heap j = " << j << "\n";);
}
SASSERT(!column_is_feasible(j));
}
void remove_column_from_inf_heap(unsigned j) {
if (m_inf_heap.contains(j)) {
TRACE("lar_solver_inf_heap", tout << "erase from heap j = " << j << "\n";);
TRACE(lar_solver_inf_heap, tout << "erase from heap j = " << j << "\n";);
m_inf_heap.erase(j);
}
SASSERT(column_is_feasible(j));
}
void clear_inf_heap() {
TRACE("lar_solver_feas",);
TRACE(lar_solver_feas,);
m_inf_heap.clear();
}

View file

@ -116,11 +116,11 @@ pretty_print(std::ostream & out) {
template <typename T, typename X> void lp_core_solver_base<T, X>::
add_delta_to_entering(unsigned entering, const X& delta) {
m_x[entering] += delta;
TRACE("lar_solver_feas", tout << "not tracking feas entering = " << entering << " = " << m_x[entering] << (column_is_feasible(entering) ? " feas" : " non-feas") << "\n";);
TRACE(lar_solver_feas, tout << "not tracking feas entering = " << entering << " = " << m_x[entering] << (column_is_feasible(entering) ? " feas" : " non-feas") << "\n";);
for (const auto & c : m_A.m_columns[entering]) {
unsigned i = c.var();
m_x[m_basis[i]] -= delta * m_A.get_val(c);
TRACE("lar_solver_feas", tout << "not tracking feas m_basis[i] = " << m_basis[i] << " = " << m_x[m_basis[i]] << (column_is_feasible(m_basis[i]) ? " feas" : " non-feas") << "\n";);
TRACE(lar_solver_feas, tout << "not tracking feas m_basis[i] = " << m_basis[i] << " = " << m_x[m_basis[i]] << (column_is_feasible(m_basis[i]) ? " feas" : " non-feas") << "\n";);
}
}
@ -201,7 +201,7 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::calc_current_x
unsigned j = this->m_n();
while (j--) {
if (!column_is_feasible(j)) {
TRACE("lar_solver", tout << "infeasible column: "; print_column_info(j, tout) << "\n";);
TRACE(lar_solver, tout << "infeasible column: "; print_column_info(j, tout) << "\n";);
return false;
}
}
@ -213,7 +213,7 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::inf_heap_is_co
bool belongs_to_set = m_inf_heap.contains(j);
bool is_feas = column_is_feasible(j);
if (is_feas == belongs_to_set) {
TRACE("lp_core", tout << "incorrectly set column in inf set "; print_column_info(j, tout) << "\n";);
TRACE(lp_core, tout << "incorrectly set column in inf set "; print_column_info(j, tout) << "\n";);
return false;
}
}
@ -333,12 +333,12 @@ non_basis_is_correctly_represented_in_heading(std::list<unsigned>* non_basis_lis
nbasis_set.insert(j);
if (non_basis_list->size() != nbasis_set.size()) {
TRACE("lp_core", tout << "non_basis_list.size() = " << non_basis_list->size() << ", nbasis_set.size() = " << nbasis_set.size() << "\n";);
TRACE(lp_core, tout << "non_basis_list.size() = " << non_basis_list->size() << ", nbasis_set.size() = " << nbasis_set.size() << "\n";);
return false;
}
for (auto it = non_basis_list->begin(); it != non_basis_list->end(); it++) {
if (nbasis_set.find(*it) == nbasis_set.end()) {
TRACE("lp_core", tout << "column " << *it << " is in m_non_basis_list but not in m_nbasis\n";);
TRACE(lp_core, tout << "column " << *it << " is in m_non_basis_list but not in m_nbasis\n";);
return false;
}
}
@ -347,7 +347,7 @@ non_basis_is_correctly_represented_in_heading(std::list<unsigned>* non_basis_lis
nbasis_set.clear();
for (auto it = non_basis_list->begin(); it != non_basis_list->end(); it++) {
if (nbasis_set.find(*it) != nbasis_set.end()) {
TRACE("lp_core", tout << "column " << *it << " is in m_non_basis_list twice\n";);
TRACE(lp_core, tout << "column " << *it << " is in m_non_basis_list twice\n";);
return false;
}
nbasis_set.insert(*it);

View file

@ -394,8 +394,8 @@ namespace lp {
const X &new_val_for_leaving = get_val_for_leaving(leaving);
X theta = (this->m_x[leaving] - new_val_for_leaving) / a_ent;
this->m_x[leaving] = new_val_for_leaving;
TRACE("lar_solver_feas", tout << "entering = " << entering << ", leaving = " << leaving << ", new_val_for_leaving = " << new_val_for_leaving << ", theta = " << theta << "\n";);
TRACE("lar_solver_feas", tout << "leaving = " << leaving
TRACE(lar_solver_feas, tout << "entering = " << entering << ", leaving = " << leaving << ", new_val_for_leaving = " << new_val_for_leaving << ", theta = " << theta << "\n";);
TRACE(lar_solver_feas, tout << "leaving = " << leaving
<< " removed from inf_heap()\n";);
// this will remove the leaving from the heap
this->inf_heap().erase_min();

View file

@ -74,7 +74,7 @@ template <typename T, typename X>
bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis(unsigned j) const {
const T& dj = this->m_d[j];
if (dj.is_zero()) return false;
TRACE("lar_solver", tout << "d[" << j <<"] = " << dj << "\n";);
TRACE(lar_solver, tout << "d[" << j <<"] = " << dj << "\n";);
SASSERT(correctly_moved_to_bounds(j));
switch (this->m_column_types[j]) {
case column_type::fixed: break;

View file

@ -37,7 +37,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_e
X t;
int leaving = find_leaving_and_t_tableau(entering, t);
if (leaving == -1) {
TRACE("lar_solver", tout << "nothing leaving " << entering << "\n";);
TRACE(lar_solver, tout << "nothing leaving " << entering << "\n";);
this->set_status(lp_status::UNBOUNDED);
return;
}
@ -91,7 +91,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_e
template <typename T, typename X>
unsigned lp_primal_core_solver<T, X>::solve() {
TRACE("lar_solver", tout << "solve " << this->get_status() << "\n";);
TRACE(lar_solver, tout << "solve " << this->get_status() << "\n";);
init_run_tableau();
if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only) {
this->set_status(lp_status::FEASIBLE);
@ -108,7 +108,7 @@ unsigned lp_primal_core_solver<T, X>::solve() {
} else {
one_iteration_tableau();
}
TRACE("lar_solver", tout << "one iteration tableau " << this->get_status() << "\n";);
TRACE(lar_solver, tout << "one iteration tableau " << this->get_status() << "\n";);
switch (this->get_status()) {
case lp_status::OPTIMAL: // check again that we are at optimum
break;

View file

@ -45,7 +45,7 @@ namespace nla {
void monomial_bounds::propagate_fixed_var(lpvar v) {
SASSERT(c().var_is_fixed(v));
TRACE("nla_solver", tout << "propagate fixed var: " << c().var_str(v) << "\n";);
TRACE(nla_solver, tout << "propagate fixed var: " << c().var_str(v) << "\n";);
for (auto const& m : c().emons().get_use_list(v))
propagate_fixed_var(m, v);
}
@ -113,7 +113,7 @@ namespace nla {
new_lemma lemma(c(), "propagate value - upper bound of range is below value");
lemma &= ex;
lemma |= ineq(v, cmp, upper);
TRACE("nla_solver", dep.display(tout << c().val(v) << " > ", range) << "\n" << lemma << "\n";);
TRACE(nla_solver, dep.display(tout << c().val(v) << " > ", range) << "\n" << lemma << "\n";);
propagated = true;
}
if (should_propagate_lower(range, v, 1)) {
@ -127,7 +127,7 @@ namespace nla {
new_lemma lemma(c(), "propagate value - lower bound of range is above value");
lemma &= ex;
lemma |= ineq(v, cmp, lower);
TRACE("nla_solver", dep.display(tout << c().val(v) << " < ", range) << "\n" << lemma << "\n";);
TRACE(nla_solver, dep.display(tout << c().val(v) << " < ", range) << "\n" << lemma << "\n";);
propagated = true;
}
return propagated;
@ -419,7 +419,7 @@ namespace nla {
void monomial_bounds::propagate_fixed_to_zero(monic const& m, lpvar fixed_to_zero) {
auto* dep = c().lra.get_bound_constraint_witnesses_for_column(fixed_to_zero);
TRACE("nla_solver", tout << "propagate fixed " << m << " = 0, fixed_to_zero = " << fixed_to_zero << "\n";);
TRACE(nla_solver, tout << "propagate fixed " << m << " = 0, fixed_to_zero = " << fixed_to_zero << "\n";);
c().lra.update_column_type_and_bound(m.var(), lp::lconstraint_kind::EQ, rational(0), dep);
// propagate fixed equality
@ -429,7 +429,7 @@ namespace nla {
void monomial_bounds::propagate_fixed(monic const& m, rational const& k) {
auto* dep = explain_fixed(m, k);
TRACE("nla_solver", tout << "propagate fixed " << m << " = " << k << "\n";);
TRACE(nla_solver, tout << "propagate fixed " << m << " = " << k << "\n";);
c().lra.update_column_type_and_bound(m.var(), lp::lconstraint_kind::EQ, k, dep);
// propagate fixed equality
@ -443,7 +443,7 @@ namespace nla {
coeffs.push_back({rational::one(), m.var()});
lp::lpvar j = c().lra.add_term(coeffs, UINT_MAX);
auto* dep = explain_fixed(m, k);
TRACE("nla_solver", tout << "propagate nonfixed " << m << " = " << k << " " << w << "\n";);
TRACE(nla_solver, tout << "propagate nonfixed " << m << " = " << k << " " << w << "\n";);
c().lra.update_column_type_and_bound(j, lp::lconstraint_kind::EQ, mpq(0), dep);
if (k == 1) {

View file

@ -233,7 +233,7 @@ public:
}
void get_powers_from_mul(std::unordered_map<lpvar, unsigned> & r) const {
TRACE("nla_cn_details", tout << "powers of " << *this << "\n";);
TRACE(nla_cn_details, tout << "powers of " << *this << "\n";);
r.clear();
for (const auto & c : *this) {
if (c.e()->is_var()) {
@ -242,7 +242,7 @@ public:
r[j] = c.pow();
}
}
TRACE("nla_cn_details", tout << "powers of " << *this << "\n"; print_vector(r, tout)<< "\n";);
TRACE(nla_cn_details, tout << "powers of " << *this << "\n"; print_vector(r, tout)<< "\n";);
}
unsigned get_degree() const override {
@ -288,18 +288,18 @@ public:
unsigned size() const override { return m_children.size(); }
bool is_linear() const override {
TRACE("nex_details", tout << *this << "\n";);
TRACE(nex_details, tout << *this << "\n";);
for (auto e : *this) {
if (!e->is_linear())
return false;
}
TRACE("nex_details", tout << "linear\n";);
TRACE(nex_details, tout << "linear\n";);
return true;
}
// we need a linear combination of at least two variables
bool is_a_linear_term() const {
TRACE("nex_details", tout << *this << "\n";);
TRACE(nex_details, tout << *this << "\n";);
unsigned number_of_non_scalars = 0;
for (auto e : *this) {
int d = e->get_degree();
@ -307,7 +307,7 @@ public:
if (d > 1) return false;
number_of_non_scalars++;
}
TRACE("nex_details", tout << (number_of_non_scalars > 1?"linear":"non-linear") << "\n";);
TRACE(nex_details, tout << (number_of_non_scalars > 1?"linear":"non-linear") << "\n";);
return number_of_non_scalars > 1;
}
@ -405,7 +405,7 @@ inline rational get_nex_val(const nex* e, std::function<rational (unsigned)> var
case expr_type::VAR:
return var_val(e->to_var().var());
default:
TRACE("nla_cn_details", tout << e->type() << "\n";);
TRACE(nla_cn_details, tout << e->type() << "\n";);
SASSERT(false);
return rational();
}
@ -430,7 +430,7 @@ inline std::unordered_set<lpvar> get_vars_of_expr(const nex *e ) {
r.insert(e->to_var().var());
return r;
default:
TRACE("nla_cn_details", tout << e->type() << "\n";);
TRACE(nla_cn_details, tout << e->type() << "\n";);
SASSERT(false);
return r;
}

View file

@ -60,7 +60,7 @@ bool nex_creator::eat_scalar_pow(rational& r, const nex_pow& p, unsigned pow) {
void nex_creator::simplify_children_of_mul(vector<nex_pow> & children, rational& coeff) {
TRACE("grobner_d", print_vector(children, tout << "children_of_mul: "); tout << "\n";);
TRACE(grobner_d, print_vector(children, tout << "children_of_mul: "); tout << "\n";);
vector<nex_pow> to_promote;
unsigned j = 0;
for (nex_pow& p : children) {
@ -78,10 +78,10 @@ void nex_creator::simplify_children_of_mul(vector<nex_pow> & children, rational&
children.shrink(j);
for (nex_pow & p : to_promote) {
TRACE("grobner_d", tout << p << "\n";);
TRACE(grobner_d, tout << p << "\n";);
nex_mul &pm = p.e()->to_mul();
for (nex_pow& pp : pm) {
TRACE("grobner_d", tout << pp << "\n";);
TRACE(grobner_d, tout << pp << "\n";);
if (!eat_scalar_pow(coeff, pp, p.pow()))
children.push_back(nex_pow(pp.e(), pp.pow() * p.pow()));
}
@ -90,7 +90,7 @@ void nex_creator::simplify_children_of_mul(vector<nex_pow> & children, rational&
mul_to_powers(children);
TRACE("grobner_d", print_vector(children, tout););
TRACE(grobner_d, print_vector(children, tout););
}
template <typename T>
@ -123,12 +123,12 @@ bool nex_creator::gt_on_powers_mul_same_degree(const T& a, const nex_mul& b) con
if (it_b != b.end()) b_pow = it_b->pow();
}
TRACE("nex_gt", tout << "a = "; print_vector(a, tout) << (ret?" > ":" <= ") << b << "\n";);
TRACE(nex_gt, tout << "a = "; print_vector(a, tout) << (ret?" > ":" <= ") << b << "\n";);
return ret;
}
bool nex_creator::gt_on_mul_mul(const nex_mul& a, const nex_mul& b) const {
TRACE("grobner_d", tout << "a = " << a << " , b = " << b << "\n";);
TRACE(grobner_d, tout << "a = " << a << " , b = " << b << "\n";);
SASSERT(is_simplified(a) && is_simplified(b));
unsigned a_deg = a.get_degree();
unsigned b_deg = b.get_degree();
@ -190,7 +190,7 @@ bool nex_creator::gt_on_sum_sum(const nex_sum& a, const nex_sum& b) const {
// the only difference with gt() that it disregards the coefficient in nex_mul
bool nex_creator::gt_for_sort_join_sum(const nex* a, const nex* b) const {
TRACE("grobner_d_", tout << *a << " ? " << *b << "\n";);
TRACE(grobner_d_, tout << *a << " ? " << *b << "\n";);
if (a == b)
return false;
bool ret;
@ -215,12 +215,12 @@ bool nex_creator::gt_for_sort_join_sum(const nex* a, const nex* b) const {
UNREACHABLE();
return false;
}
TRACE("grobner_d_", tout << *a << (ret?" < ":" >= ") << *b << "\n";);
TRACE(grobner_d_, tout << *a << (ret?" < ":" >= ") << *b << "\n";);
return ret;
}
bool nex_creator::gt(const nex& a, const nex& b) const {
TRACE("grobner_d_", tout << a << " ? " << b << "\n";);
TRACE(grobner_d_, tout << a << " ? " << b << "\n";);
if (&a == &b)
return false;
bool ret;
@ -243,14 +243,14 @@ bool nex_creator::gt(const nex& a, const nex& b) const {
UNREACHABLE();
return false;
}
TRACE("grobner_d_", tout << a << (ret?" < ":" >= ") << b << "\n";);
TRACE(grobner_d_, tout << a << (ret?" < ":" >= ") << b << "\n";);
return ret;
}
bool nex_creator::is_sorted(const nex_mul& e) const {
for (unsigned j = 0; j < e.size() - 1; j++) {
if (!(gt_on_nex_pow(e[j], e[j+1]))) {
TRACE("grobner_d", tout << "not sorted e " << e << "\norder is incorrect " <<
TRACE(grobner_d, tout << "not sorted e " << e << "\norder is incorrect " <<
e[j] << " >= " << e[j + 1]<< "\n";);
return false;
@ -260,28 +260,28 @@ bool nex_creator::is_sorted(const nex_mul& e) const {
}
bool nex_creator::mul_is_simplified(const nex_mul& e) const {
TRACE("nla_cn_", tout << "e = " << e << "\n";);
TRACE(nla_cn_, tout << "e = " << e << "\n";);
if (e.size() == 0) {
TRACE("nla_cn", );
TRACE(nla_cn, );
return false; // it has to be a scalar
}
if (e.size() == 1 && e.begin()->pow() == 1 && e.coeff().is_one()) {
TRACE("nla_cn", );
TRACE(nla_cn, );
return false;
}
std::set<const nex*, nex_lt> s([this](const nex* a, const nex* b) {return gt(a, b); });
for (const auto &p : e) {
const nex* ee = p.e();
if (p.pow() == 0) {
TRACE("nla_cn", tout << "not simplified " << *ee << "\n";);
TRACE(nla_cn, tout << "not simplified " << *ee << "\n";);
return false;
}
if (ee->is_mul()) {
TRACE("nla_cn", tout << "not simplified " << *ee << "\n";);
TRACE(nla_cn, tout << "not simplified " << *ee << "\n";);
return false;
}
if (ee->is_scalar() && to_scalar(ee)->value().is_one()) {
TRACE("nla_cn", tout << "not simplified " << *ee << "\n";);
TRACE(nla_cn, tout << "not simplified " << *ee << "\n";);
return false;
}
@ -289,7 +289,7 @@ bool nex_creator::mul_is_simplified(const nex_mul& e) const {
if (it == s.end()) {
s.insert(ee);
} else {
TRACE("nla_cn", tout << "not simplified " << *ee << "\n";);
TRACE(nla_cn, tout << "not simplified " << *ee << "\n";);
return false;
}
}
@ -297,7 +297,7 @@ bool nex_creator::mul_is_simplified(const nex_mul& e) const {
}
nex * nex_creator::simplify_mul(nex_mul *e) {
TRACE("grobner_d", tout << *e << "\n";);
TRACE(grobner_d, tout << *e << "\n";);
rational& coeff = e->m_coeff;
simplify_children_of_mul(e->m_children, coeff);
if (e->size() == 1 && (*e)[0].pow() == 1 && coeff.is_one())
@ -305,13 +305,13 @@ nex * nex_creator::simplify_mul(nex_mul *e) {
if (e->size() == 0 || e->coeff().is_zero())
return mk_scalar(e->coeff());
TRACE("grobner_d", tout << *e << "\n";);
TRACE(grobner_d, tout << *e << "\n";);
SASSERT(is_simplified(*e));
return e;
}
nex* nex_creator::simplify_sum(nex_sum *e) {
TRACE("grobner_d", tout << "was e = " << *e << "\n";);
TRACE(grobner_d, tout << "was e = " << *e << "\n";);
simplify_children_of_sum(*e);
nex *r;
if (e->size() == 1) {
@ -321,7 +321,7 @@ nex* nex_creator::simplify_sum(nex_sum *e) {
} else {
r = const_cast<nex_sum*>(e);
}
TRACE("grobner_d", tout << "became r = " << *r << "\n";);
TRACE(grobner_d, tout << "became r = " << *r << "\n";);
return r;
}
@ -329,22 +329,22 @@ bool nex_creator::sum_is_simplified(const nex_sum& e) const {
if (e.size() < 2) return false;
bool scalar = false;
for (nex const* ee : e) {
TRACE("nla_cn_details", tout << "ee = " << *ee << "\n";);
TRACE(nla_cn_details, tout << "ee = " << *ee << "\n";);
if (ee->is_sum()) {
TRACE("nla_cn", tout << "not simplified e = " << e << "\n"
TRACE(nla_cn, tout << "not simplified e = " << e << "\n"
<< " has a child which is a sum " << *ee << "\n";);
return false;
}
if (ee->is_scalar()) {
if (scalar) {
TRACE("nla_cn", tout << "not simplified e = " << e << "\n"
TRACE(nla_cn, tout << "not simplified e = " << e << "\n"
<< " have more than one scalar " << *ee << "\n";);
return false;
}
if (to_scalar(ee)->value().is_zero()) {
if (scalar) {
TRACE("nla_cn", tout << "have a zero scalar " << *ee << "\n";);
TRACE(nla_cn, tout << "have a zero scalar " << *ee << "\n";);
return false;
}
@ -380,15 +380,15 @@ void nex_creator::mul_to_powers(vector<nex_pow>& children) {
// returns true if the key exists already
bool nex_creator::register_in_join_map(std::map<nex const*, rational, nex_lt>& map, nex const* e, const rational& r) const{
TRACE("grobner_d", tout << *e << ", r = " << r << std::endl;);
TRACE(grobner_d, tout << *e << ", r = " << r << std::endl;);
auto map_it = map.find(e);
if (map_it == map.end()) {
map[e] = r;
TRACE("grobner_d", tout << "inserting " << std::endl;);
TRACE(grobner_d, tout << "inserting " << std::endl;);
return false;
} else {
map_it->second += r;
TRACE("grobner_d", tout << "adding " << r << " , got " << map_it->second << std::endl;);
TRACE(grobner_d, tout << "adding " << r << " , got " << map_it->second << std::endl;);
return true;
}
}
@ -418,14 +418,14 @@ bool nex_creator::fill_join_map_for_sum(
}
// a + 3bc + 2bc => a + 5bc
void nex_creator::sort_join_sum(nex_sum& sum) {
TRACE("grobner_d", tout << sum << "\n";);
TRACE(grobner_d, tout << sum << "\n";);
std::map<nex const*, rational, nex_lt> map([this](const nex *a , const nex *b)
{ return gt_for_sort_join_sum(a, b); });
std::unordered_set<nex const*> allocated_nexs; // handling (nex*) as numbers
rational common_scalar(0);
fill_join_map_for_sum(sum, map, allocated_nexs, common_scalar);
TRACE("grobner_d", for (auto & p : map ) { tout << "(" << *p.first << ", " << p.second << ") ";});
TRACE(grobner_d, for (auto & p : map ) { tout << "(" << *p.first << ", " << p.second << ") ";});
sum.m_children.reset();
for (auto& p : map) {
process_map_pair(const_cast<nex*>(p.first), p.second, sum, allocated_nexs);
@ -433,7 +433,7 @@ void nex_creator::sort_join_sum(nex_sum& sum) {
if (!common_scalar.is_zero()) {
sum.m_children.push_back(mk_scalar(common_scalar));
}
TRACE("grobner_d",
TRACE(grobner_d,
tout << "map=";
for (auto & p : map ) tout << "(" << *p.first << ", " << p.second << ") ";
tout << "\nchildren=" << sum << "\n";);
@ -479,7 +479,7 @@ nex * nex_creator::mk_div_sum_by_mul(const nex_sum& m, const nex_mul& b) {
sf += mk_div_by_mul(*e, b);
}
nex* r = sf.mk();
TRACE("grobner_d", tout << *r << "\n";);
TRACE(grobner_d, tout << *r << "\n";);
return r;
}
@ -488,11 +488,11 @@ nex * nex_creator::mk_div_mul_by_mul(const nex_mul& a, const nex_mul& b) {
b.get_powers_from_mul(m_powers);
m_mk_mul.reset();
for (auto& p_from_a : a) {
TRACE("grobner_d", tout << "p_from_a = " << p_from_a << "\n";);
TRACE(grobner_d, tout << "p_from_a = " << p_from_a << "\n";);
const nex* e = p_from_a.e();
if (e->is_scalar()) {
m_mk_mul *= nex_pow(clone(e), p_from_a.pow());
TRACE("grobner_d", tout << "processed scalar\n";);
TRACE(grobner_d, tout << "processed scalar\n";);
continue;
}
SASSERT(e->is_var());
@ -520,7 +520,7 @@ nex * nex_creator::mk_div_mul_by_mul(const nex_mul& a, const nex_mul& b) {
SASSERT(m_powers.size() == 0);
m_mk_mul *= (a.coeff() / b.coeff());
nex* ret = m_mk_mul.mk_reduced();
TRACE("grobner_d", tout << *ret << "\n";);
TRACE(grobner_d, tout << *ret << "\n";);
return ret;
}
@ -536,7 +536,7 @@ nex * nex_creator::mk_div_by_mul(const nex& a, const nex_mul& b) {
}
nex * nex_creator::mk_div(const nex& a, const nex& b) {
TRACE("grobner_d", tout << a <<" / " << b << "\n";);
TRACE(grobner_d, tout << a <<" / " << b << "\n";);
if (b.is_var()) {
return mk_div(a, b.to_var().var());
}
@ -545,23 +545,23 @@ nex * nex_creator::mk_div(const nex& a, const nex& b) {
nex* nex_creator::simplify(nex* e) {
nex* es;
TRACE("grobner_d", tout << *e << std::endl;);
TRACE(grobner_d, tout << *e << std::endl;);
if (e->is_mul())
es = simplify_mul(to_mul(e));
else if (e->is_sum())
es = simplify_sum(to_sum(e));
else
es = e;
TRACE("grobner_d", tout << "simplified = " << *es << std::endl;);
TRACE(grobner_d, tout << "simplified = " << *es << std::endl;);
SASSERT(is_simplified(*es));
return es;
}
// adds to children the corrected expression and also adds to allocated the new expressions
void nex_creator::process_map_pair(nex*e, const rational& coeff, nex_sum & sum, std::unordered_set<nex const*>& allocated_nexs) {
TRACE("grobner_d", tout << "e=" << *e << " , coeff= " << coeff << "\n";);
TRACE(grobner_d, tout << "e=" << *e << " , coeff= " << coeff << "\n";);
if (coeff.is_zero()) {
TRACE("grobner_d", tout << "did nothing\n";);
TRACE(grobner_d, tout << "did nothing\n";);
return;
}
bool e_is_old = allocated_nexs.find(e) != allocated_nexs.end();
@ -585,7 +585,7 @@ void nex_creator::process_map_pair(nex*e, const rational& coeff, nex_sum & sum,
}
bool nex_creator::is_simplified(const nex& e) const {
TRACE("nla_cn_details", tout << "e = " << e << "\n";);
TRACE(nla_cn_details, tout << "e = " << e << "\n";);
if (e.is_mul())
return mul_is_simplified(e.to_mul());
if (e.is_sum())
@ -602,7 +602,7 @@ unsigned nex_creator::find_sum_in_mul(const nex_mul* a) const {
}
nex* nex_creator::canonize_mul(nex_mul *a) {
TRACE("grobner_d", tout << "a = " << *a << "\n";);
TRACE(grobner_d, tout << "a = " << *a << "\n";);
unsigned j = find_sum_in_mul(a);
if (j + 1 == 0)
return a;
@ -625,7 +625,7 @@ nex* nex_creator::canonize_mul(nex_mul *a) {
sf += mf.mk();
}
nex* r = sf.mk();
TRACE("grobner_d", tout << "canonized a = " << *r << "\n";);
TRACE(grobner_d, tout << "canonized a = " << *r << "\n";);
return canonize(r);
}
@ -640,14 +640,14 @@ nex* nex_creator::canonize(const nex *a) {
s[j] = canonize(s[j]);
}
t = simplify(&s);
TRACE("grobner_d", tout << *t << "\n";);
TRACE(grobner_d, tout << *t << "\n";);
return t;
}
return canonize_mul(to_mul(t));
}
bool nex_creator::equal(const nex* a, const nex* b) {
TRACE("grobner_d", tout << *a << " against " << *b << "\n";);
TRACE(grobner_d, tout << *a << " against " << *b << "\n";);
nex_creator cn;
unsigned n = 0;
for (lpvar j : get_vars_of_expr(a)) {
@ -662,8 +662,8 @@ bool nex_creator::equal(const nex* a, const nex* b) {
}
nex * ca = cn.canonize(a);
nex * cb = cn.canonize(b);
TRACE("grobner_d", tout << "a = " << *a << ", canonized a = " << *ca << "\n";);
TRACE("grobner_d", tout << "b = " << *b << ", canonized b = " << *cb << "\n";);
TRACE(grobner_d, tout << "a = " << *a << ", canonized a = " << *ca << "\n";);
TRACE(grobner_d, tout << "b = " << *b << ", canonized b = " << *cb << "\n";);
return !(cn.gt(ca, cb) || cn.gt(cb, ca));
}

View file

@ -133,7 +133,7 @@ public:
void add_to_allocated(nex* r) {
m_allocated.push_back(r);
CTRACE("grobner_stats_d", m_allocated.size() % 1000 == 0, tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
CTRACE(grobner_stats_d, m_allocated.size() % 1000 == 0, tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
}
// NSB: we can use region allocation, but still need to invoke destructor
@ -142,7 +142,7 @@ public:
for (unsigned j = sz; j < m_allocated.size(); j++)
dealloc(m_allocated[j]);
m_allocated.resize(sz);
TRACE("grobner_stats_d", tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
TRACE(grobner_stats_d, tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
}
void clear() {

View file

@ -22,7 +22,7 @@ bool basics::basic_sign_lemma_on_two_monics(const monic& m, const monic& n) {
const rational sign = sign_to_rat(m.rsign() ^ n.rsign());
if (var_val(m) == var_val(n) * sign)
return false;
TRACE("nla_solver", tout << "sign contradiction:\nm = " << pp_mon(c(), m) << "n= " << pp_mon(c(), n) << "sign: " << sign << "\n";);
TRACE(nla_solver, tout << "sign contradiction:\nm = " << pp_mon(c(), m) << "n= " << pp_mon(c(), n) << "sign: " << sign << "\n";);
generate_sign_lemma(m, n, sign);
return true;
}
@ -46,7 +46,7 @@ void basics::generate_zero_lemmas(const monic& m) {
if (sign && is_even(zero_power)) {
sign = 0;
}
TRACE("nla_solver_details", tout << "zero_j = " << zero_j << ", sign = " << sign << "\n";);
TRACE(nla_solver_details, tout << "zero_j = " << zero_j << ", sign = " << sign << "\n";);
if (sign == 0) { // have to generate a non-convex lemma
add_trivial_zero_lemma(zero_j, m);
} else { // here we know the sign of zero_j
@ -80,7 +80,7 @@ void basics::get_non_strict_sign(lpvar j, int& sign) const {
void basics::basic_sign_lemma_model_based_one_mon(const monic& m, int product_sign) {
if (product_sign == 0) {
TRACE("nla_solver_bl", tout << "zero product sign: " << pp_mon(_(), m)<< "\n";);
TRACE(nla_solver_bl, tout << "zero product sign: " << pp_mon(_(), m)<< "\n";);
generate_zero_lemmas(m);
} else {
new_lemma lemma(c(), __FUNCTION__);
@ -113,21 +113,21 @@ bool basics::basic_sign_lemma_on_mon(lpvar v, std::unordered_set<unsigned> & exp
return false;
}
const monic& m_v = c().emons()[v];
TRACE("nla_solver", tout << "m_v = " << pp_mon_with_vars(c(), m_v););
CTRACE("nla_solver", !c().emons().is_canonized(m_v),
TRACE(nla_solver, tout << "m_v = " << pp_mon_with_vars(c(), m_v););
CTRACE(nla_solver, !c().emons().is_canonized(m_v),
c().emons().display(c(), tout);
c().m_evars.display(tout);
);
SASSERT(c().emons().is_canonized(m_v));
for (auto const& m : c().emons().enum_sign_equiv_monics(v)) {
TRACE("nla_solver_details", tout << "m = " << pp_mon_with_vars(c(), m););
TRACE(nla_solver_details, tout << "m = " << pp_mon_with_vars(c(), m););
SASSERT(m.rvars() == m_v.rvars());
if (m_v.var() != m.var() && basic_sign_lemma_on_two_monics(m_v, m) && done())
return true;
}
TRACE("nla_solver_details", tout << "return false\n";);
TRACE(nla_solver_details, tout << "return false\n";);
return false;
}
@ -150,7 +150,7 @@ bool basics::basic_sign_lemma(bool derived) {
// but it is not the case in the model
void basics::generate_sign_lemma(const monic& m, const monic& n, const rational& sign) {
new_lemma lemma(c(), "sign lemma");
TRACE("nla_solver",
TRACE(nla_solver,
tout << "m = " << pp_mon_with_vars(_(), m);
tout << "n = " << pp_mon_with_vars(_(), n);
);
@ -181,7 +181,7 @@ void basics::add_trivial_zero_lemma(lpvar zero_j, const monic& m) {
}
void basics::generate_strict_case_zero_lemma(const monic& m, unsigned zero_j, int sign_of_zj) {
TRACE("nla_solver_bl", tout << "sign_of_zj = " << sign_of_zj << "\n";);
TRACE(nla_solver_bl, tout << "sign_of_zj = " << sign_of_zj << "\n";);
// we know all the signs
new_lemma lemma(c(), "strict case 0");
lemma |= ineq(zero_j, sign_of_zj == 1? llc::GT : llc::LT, 0);
@ -200,7 +200,7 @@ void basics::add_fixed_zero_lemma(const monic& m, lpvar j) {
}
void basics::negate_strict_sign(new_lemma& lemma, lpvar j) {
TRACE("nla_solver_details", tout << pp_var(c(), j) << " " << val(j).is_zero() << "\n";);
TRACE(nla_solver_details, tout << pp_var(c(), j) << " " << val(j).is_zero() << "\n";);
if (!val(j).is_zero()) {
int sign = nla::rat_sign(val(j));
lemma |= ineq(j, (sign == 1? llc::LE : llc::GE), 0);
@ -225,7 +225,7 @@ bool basics::basic_lemma_for_mon_zero(const monic& rm, const factorization& f) {
if (val(j).is_zero())
return false;
}
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout););
TRACE(nla_solver, c().trace_print_monic_and_factorization(rm, f, tout););
new_lemma lemma(c(), "xy = 0 -> x = 0 or y = 0");
lemma.explain_fixed(var(rm));
std::unordered_set<lpvar> processed;
@ -245,7 +245,7 @@ bool basics::basic_lemma(bool derived) {
if (derived)
return false;
const auto& mon_inds_to_ref = c().m_to_refine;
TRACE("nla_solver", tout << "mon_inds_to_ref = "; print_vector(mon_inds_to_ref, tout) << "\n";);
TRACE(nla_solver, tout << "mon_inds_to_ref = "; print_vector(mon_inds_to_ref, tout) << "\n";);
unsigned start = c().random();
unsigned sz = mon_inds_to_ref.size();
for (unsigned j = 0; j < sz; ++j) {
@ -292,7 +292,7 @@ bool basics::basic_lemma_for_mon_derived(const monic& rm) {
// x = 0 or y = 0 -> xy = 0
bool basics::basic_lemma_for_mon_non_zero_derived(const monic& rm, const factorization& f) {
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout););
TRACE(nla_solver, c().trace_print_monic_and_factorization(rm, f, tout););
if (!c().var_is_separated_from_zero(var(rm)))
return false;
for (auto fc : f) {
@ -314,10 +314,10 @@ bool basics::basic_lemma_for_mon_non_zero_derived(const monic& rm, const factori
// |x*a| = |x| & x != 0 -> |a| = 1
bool basics::basic_lemma_for_mon_neutral_derived(const monic& rm, const factorization& f) {
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout););
TRACE(nla_solver, c().trace_print_monic_and_factorization(rm, f, tout););
lpvar mon_var = c().emons()[rm.var()].var();
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout); tout << "\nmon_var = " << mon_var << "\n";);
TRACE(nla_solver, c().trace_print_monic_and_factorization(rm, f, tout); tout << "\nmon_var = " << mon_var << "\n";);
const auto mv = val(mon_var);
const auto abs_mv = abs(mv);
@ -415,7 +415,7 @@ void basics::generate_pl_on_mon(const monic& m, unsigned k) {
*/
void basics::generate_pl(const monic& m, const factorization& fc, int factor_index) {
SASSERT(!c().has_real(fc));
TRACE("nla_solver", tout << "factor_index = " << factor_index << ", m = "
TRACE(nla_solver, tout << "factor_index = " << factor_index << ", m = "
<< pp_mon(c(), m);
tout << ", fc = " << c().pp(fc);
tout << "orig mon = "; c().print_monic(c().emons()[m.var()], tout););
@ -457,7 +457,7 @@ bool basics::is_separated_from_zero(const factorization& f) const {
// here we use the fact xy = 0 -> x = 0 or y = 0
void basics::basic_lemma_for_mon_zero_model_based(const monic& rm, const factorization& f) {
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout););
TRACE(nla_solver, c().trace_print_monic_and_factorization(rm, f, tout););
SASSERT(var_val(rm).is_zero() && !c().rm_check(rm));
new_lemma lemma(c(), "xy = 0 -> x = 0 or y = 0");
if (!is_separated_from_zero(f)) {
@ -475,7 +475,7 @@ void basics::basic_lemma_for_mon_zero_model_based(const monic& rm, const factori
}
void basics::basic_lemma_for_mon_model_based(const monic& rm) {
TRACE("nla_solver_bl", tout << "rm = " << pp_mon(_(), rm) << "\n";);
TRACE(nla_solver_bl, tout << "rm = " << pp_mon(_(), rm) << "\n";);
if (var_val(rm).is_zero()) {
for (auto factorization : factorization_factory_imp(rm, c())) {
if (factorization.is_empty())
@ -528,7 +528,7 @@ bool basics::basic_lemma_for_mon_neutral_from_factors_to_monic_model_based_fm(co
// |uvw| = |u| and uvw != 0 -> |v| = 1
bool basics::basic_lemma_for_mon_neutral_monic_to_factor_model_based(const monic& rm, const factorization& f) {
lpvar mon_var = c().emons()[rm.var()].var();
TRACE("nla_solver_bl", c().trace_print_monic_and_factorization(rm, f, tout); tout << "\nmon_var = " << mon_var << "\n";);
TRACE(nla_solver_bl, c().trace_print_monic_and_factorization(rm, f, tout); tout << "\nmon_var = " << mon_var << "\n";);
const auto mv = val(mon_var);
const auto abs_mv = abs(mv);
@ -581,10 +581,10 @@ void basics::basic_lemma_for_mon_neutral_model_based(const monic& rm, const fact
template <typename T>
bool basics::can_create_lemma_for_mon_neutral_from_factors_to_monic_model_based(const monic& m, const T& f, lpvar &not_one, rational& sign) {
sign = rational(1);
// TRACE("nla_solver_bl", tout << pp_mon_with_vars(_(), m) <<"\nf = " << c().pp(f) << "sign = " << sign << '\n';);
// TRACE(nla_solver_bl, tout << pp_mon_with_vars(_(), m) <<"\nf = " << c().pp(f) << "sign = " << sign << '\n';);
not_one = null_lpvar;
for (auto j : f) {
TRACE("nla_solver_bl", tout << "j = "; c().print_factor_with_vars(j, tout););
TRACE(nla_solver_bl, tout << "j = "; c().print_factor_with_vars(j, tout););
auto v = val(j);
if (v.is_one())
@ -609,7 +609,7 @@ bool basics::can_create_lemma_for_mon_neutral_from_factors_to_monic_model_based(
return false;
}
if (not_one != null_lpvar && var_val(m) == val(not_one) * sign) {
TRACE("nla_solver", tout << "the whole is equal to the factor" << std::endl;);
TRACE(nla_solver, tout << "the whole is equal to the factor" << std::endl;);
return false;
}
@ -639,14 +639,14 @@ bool basics::basic_lemma_for_mon_neutral_from_factors_to_monic_model_based(const
for (auto j : f)
if (j.sign())
return false;
TRACE("nla_solver_bl", tout << "not_one = " << not_one << "\n";);
TRACE(nla_solver_bl, tout << "not_one = " << not_one << "\n";);
new_lemma lemma(c(), __FUNCTION__);
for (auto j : f) {
lpvar var_j = var(j);
if (not_one == var_j) continue;
TRACE("nla_solver_bl", tout << "j = "; c().print_factor_with_vars(j, tout););
TRACE(nla_solver_bl, tout << "j = "; c().print_factor_with_vars(j, tout););
lemma |= ineq(var_j, llc::NE, val(var_j));
}
@ -656,13 +656,13 @@ bool basics::basic_lemma_for_mon_neutral_from_factors_to_monic_model_based(const
lemma |= ineq(term(m.var(), -sign, not_one), llc::EQ, 0);
lemma &= m;
lemma &= f;
TRACE("nla_solver", tout << "m = " << pp_mon_with_vars(c(), m););
TRACE(nla_solver, tout << "m = " << pp_mon_with_vars(c(), m););
return true;
}
// x = 0 or y = 0 -> xy = 0
void basics::basic_lemma_for_mon_non_zero_model_based(const monic& rm, const factorization& f) {
TRACE("nla_solver_bl", c().trace_print_monic_and_factorization(rm, f, tout););
TRACE(nla_solver_bl, c().trace_print_monic_and_factorization(rm, f, tout););
for (auto j : f) {
if (val(j).is_zero()) {
new_lemma lemma(c(), "x = 0 => x*... = 0");

View file

@ -99,11 +99,11 @@ nex * common::nexvar(const rational & coeff, lpvar j, nex_creator& cn, u_depende
else {
c().insert_to_active_var_set(k);
mf *= cn.mk_var(k);
CTRACE("nla_grobner", c().is_monic_var(k), c().print_var(k, tout) << "\n";);
CTRACE(nla_grobner, c().is_monic_var(k), c().print_var(k, tout) << "\n";);
}
}
nex* e = mf.mk();
TRACE("nla_grobner", tout << *e;);
TRACE(nla_grobner, tout << *e;);
return e;
}
@ -113,7 +113,7 @@ template <typename T> void common::create_sum_from_row(const T& row,
nex_creator::sum_factory& sum,
u_dependency*& dep) {
TRACE("nla_horner", tout << "row="; m_core.print_row(row, tout) << "\n";);
TRACE(nla_horner, tout << "row="; m_core.print_row(row, tout) << "\n";);
SASSERT(row.size() > 1);
sum.reset();
for (const auto &p : row) {

View file

@ -135,13 +135,13 @@ void core::add_monic(lpvar v, unsigned sz, lpvar const* vs) {
}
void core::push() {
TRACE("nla_solver_verbose", tout << "\n";);
TRACE(nla_solver_verbose, tout << "\n";);
m_emons.push();
}
void core::pop(unsigned n) {
TRACE("nla_solver_verbose", tout << "n = " << n << "\n";);
TRACE(nla_solver_verbose, tout << "n = " << n << "\n";);
m_emons.pop(n);
SASSERT(elists_are_consistent(false));
}
@ -166,7 +166,7 @@ bool core::check_monic(const monic& m) const {
return true;
bool ret = product_value(m) == lra.get_column_value(m.var()).x;
CTRACE("nla_solver_check_monic", !ret, print_monic(m, tout) << '\n';);
CTRACE(nla_solver_check_monic, !ret, print_monic(m, tout) << '\n';);
return ret;
}
@ -406,14 +406,14 @@ bool core::explain_by_equiv(const lp::lar_term& t, lp::explanation& e) const {
return false;
m_evars.explain(signed_var(i, false), signed_var(j, sign), e);
TRACE("nla_solver", tout << "explained :"; lra.print_term_as_indices(t, tout););
TRACE(nla_solver, tout << "explained :"; lra.print_term_as_indices(t, tout););
return true;
}
void core::mk_ineq_no_expl_check(new_lemma& lemma, lp::lar_term& t, llc cmp, const rational& rs) {
TRACE("nla_solver_details", lra.print_term_as_indices(t, tout << "t = "););
TRACE(nla_solver_details, lra.print_term_as_indices(t, tout << "t = "););
lemma |= ineq(cmp, t, rs);
CTRACE("nla_solver", ineq_holds(ineq(cmp, t, rs)), print_ineq(ineq(cmp, t, rs), tout) << "\n";);
CTRACE(nla_solver, ineq_holds(ineq(cmp, t, rs)), print_ineq(ineq(cmp, t, rs), tout) << "\n";);
SASSERT(!ineq_holds(ineq(cmp, t, rs)));
}
@ -433,7 +433,7 @@ void core::fill_explanation_and_lemma_sign(new_lemma& lemma, const monic& a, con
SASSERT(sign == 1 || sign == -1);
lemma &= a;
lemma &= b;
TRACE("nla_solver", tout << "used constraints: " << lemma;);
TRACE(nla_solver, tout << "used constraints: " << lemma;);
SASSERT(lemma.num_ineqs() == 0);
lemma |= ineq(term(rational(1), a.var(), -sign, b.var()), llc::EQ, 0);
}
@ -447,7 +447,7 @@ svector<lpvar> core::reduce_monic_to_rooted(const svector<lpvar> & vars, rationa
for (lpvar v : vars) {
auto root = m_evars.find(v);
s ^= root.sign();
TRACE("nla_solver_eq",
TRACE(nla_solver_eq,
tout << pp(v) << " mapped to " << pp(root.var()) << "\n";);
ret.push_back(root.var());
}
@ -524,7 +524,7 @@ bool core::sign_contradiction(const monic& m) const {
/*
unsigned_vector eq_vars(lpvar j) const {
TRACE("nla_solver_eq", tout << "j = " << pp(j) << "eqs = ";
TRACE(nla_solver_eq, tout << "j = " << pp(j) << "eqs = ";
for(auto jj : m_evars.eq_vars(j)) tout << pp(jj) << " ";
});
return m_evars.eq_vars(j);
@ -692,7 +692,7 @@ void core::collect_equivs() {
continue;
lpvar j = t->j();
if (var_is_fixed_to_zero(j)) {
TRACE("nla_solver_mons", s.print_term_as_indices(*t, tout << "term = ") << "\n";);
TRACE(nla_solver_mons, s.print_term_as_indices(*t, tout << "term = ") << "\n";);
add_equivalence_maybe(t, s.get_column_upper_bound_witness(j), s.get_column_lower_bound_witness(j));
}
}
@ -809,7 +809,7 @@ void core::clear() {
}
void core::init_search() {
TRACE("nla_solver_mons", tout << "init\n";);
TRACE(nla_solver_mons, tout << "init\n";);
SASSERT(m_emons.invariant());
clear();
init_vars_equivalence();
@ -818,19 +818,19 @@ void core::init_search() {
}
void core::insert_to_refine(lpvar j) {
TRACE("lar_solver", tout << "j=" << j << '\n';);
TRACE(lar_solver, tout << "j=" << j << '\n';);
m_to_refine.insert(j);
}
void core::erase_from_to_refine(lpvar j) {
TRACE("lar_solver", tout << "j=" << j << '\n';);
TRACE(lar_solver, tout << "j=" << j << '\n';);
if (m_to_refine.contains(j))
m_to_refine.remove(j);
}
void core::init_to_refine() {
TRACE("nla_solver_details", tout << "emons:" << pp_emons(*this, m_emons););
TRACE(nla_solver_details, tout << "emons:" << pp_emons(*this, m_emons););
m_to_refine.reset();
unsigned r = random(), sz = m_emons.number_of_monics();
for (unsigned k = 0; k < sz; k++) {
@ -839,7 +839,7 @@ void core::init_to_refine() {
insert_to_refine(m.var());
}
TRACE("nla_solver",
TRACE(nla_solver,
tout << m_to_refine.size() << " mons to refine:\n";
for (lpvar v : m_to_refine) tout << pp_mon(*this, m_emons[v]) << ":error = " <<
(val(v) - mul_val(m_emons[v])).get_double() << "\n";);
@ -872,19 +872,19 @@ std::unordered_set<lpvar> core::collect_vars(const lemma& l) const {
// divides bc by c, so bc = b*c
bool core::divide(const monic& bc, const factor& c, factor & b) const {
svector<lpvar> c_rvars = sorted_rvars(c);
TRACE("nla_solver_div", tout << "c_rvars = "; print_product(c_rvars, tout); tout << "\nbc_rvars = "; print_product(bc.rvars(), tout););
TRACE(nla_solver_div, tout << "c_rvars = "; print_product(c_rvars, tout); tout << "\nbc_rvars = "; print_product(bc.rvars(), tout););
if (!lp::is_proper_factor(c_rvars, bc.rvars()))
return false;
auto b_rvars = lp::vector_div(bc.rvars(), c_rvars);
TRACE("nla_solver_div", tout << "b_rvars = "; print_product(b_rvars, tout););
TRACE(nla_solver_div, tout << "b_rvars = "; print_product(b_rvars, tout););
SASSERT(b_rvars.size() > 0);
if (b_rvars.size() == 1) {
b = factor(b_rvars[0], factor_type::VAR);
} else {
monic const* sv = m_emons.find_canonical(b_rvars);
if (sv == nullptr) {
TRACE("nla_solver_div", tout << "not in rooted";);
TRACE(nla_solver_div, tout << "not in rooted";);
return false;
}
b = factor(sv->var(), factor_type::MON);
@ -894,7 +894,7 @@ bool core::divide(const monic& bc, const factor& c, factor & b) const {
// Dividing by bc.rvars() we get canonize_sign(bc) = canonize_sign(b)*canonize_sign(c)
// Currently, canonize_sign(b) is 1, we might need to adjust it
b.sign() = canonize_sign(b) ^ canonize_sign(c) ^ canonize_sign(bc);
TRACE("nla_solver", tout << "success div:" << pp(b) << "\n";);
TRACE(nla_solver, tout << "success div:" << pp(b) << "\n";);
return true;
}
@ -959,7 +959,7 @@ void core::maybe_add_a_factor(lpvar i,
} else {
if (try_insert(i, found_rm)) {
r.push_back(factor(i, factor_type::MON));
TRACE("nla_solver", tout << "inserting factor = "; print_factor_with_vars(factor(i, factor_type::MON), tout); );
TRACE(nla_solver, tout << "inserting factor = "; print_factor_with_vars(factor(i, factor_type::MON), tout); );
}
}
}
@ -994,7 +994,7 @@ bool core::find_bfc_to_refine_on_monic(const monic& m, factorization & bf) {
auto b = f[1];
if (var_val(m) != val(a) * val(b)) {
bf = f;
TRACE("nla_solver", tout << "found bf";
TRACE(nla_solver, tout << "found bf";
tout << ":m:" << pp_mon_with_vars(*this, m) << "\n";
tout << "bf:"; print_bfc(bf, tout););
@ -1023,7 +1023,7 @@ bool core::find_bfc_to_refine(const monic* & m, factorization & bf){
}
if (find_bfc_to_refine_on_monic(*m, bf)) {
TRACE("nla_solver",
TRACE(nla_solver,
tout << "bf = "; print_factorization(bf, tout);
tout << "\nval(*m) = " << var_val(*m) << ", should be = (val(bf[0])=" << val(bf[0]) << ")*(val(bf[1]) = " << val(bf[1]) << ") = " << val(bf[0])*val(bf[1]) << "\n";);
return true;
@ -1046,7 +1046,7 @@ new_lemma::new_lemma(core& c, char const* name):name(name), c(c) {
new_lemma& new_lemma::operator|=(ineq const& ineq) {
if (!c.explain_ineq(*this, ineq.term(), ineq.cmp(), ineq.rs())) {
CTRACE("nla_solver", c.ineq_holds(ineq), c.print_ineq(ineq, tout) << "\n";);
CTRACE(nla_solver, c.ineq_holds(ineq), c.print_ineq(ineq, tout) << "\n";);
SASSERT(!c.ineq_holds(ineq));
current().push_back(ineq);
}
@ -1064,7 +1064,7 @@ new_lemma::~new_lemma() {
}
IF_VERBOSE(4, verbose_stream() << name << "\n");
IF_VERBOSE(4, verbose_stream() << *this << "\n");
TRACE("nla_solver", tout << name << " " << (++i) << "\n" << *this; );
TRACE(nla_solver, tout << name << " " << (++i) << "\n" << *this; );
}
lemma& new_lemma::current() const {
@ -1138,7 +1138,7 @@ new_lemma& new_lemma::explain_existing_lower_bound(lpvar j) {
lp::explanation ex;
c.lra.push_explanation(c.lra.get_column_lower_bound_witness(j), ex);
*this &= ex;
TRACE("nla_solver", tout << j << ": " << *this << "\n";);
TRACE(nla_solver, tout << j << ": " << *this << "\n";);
return *this;
}
@ -1236,7 +1236,7 @@ bool core::var_breaks_correct_monic_as_factor(lpvar j, const monic& m) const {
bool core::var_breaks_correct_monic(lpvar j) const {
if (is_monic_var(j) && !m_to_refine.contains(j)) {
TRACE("nla_solver", tout << "j = " << j << ", m = "; print_monic(emon(j), tout) << "\n";);
TRACE(nla_solver, tout << "j = " << j << ", m = "; print_monic(emon(j), tout) << "\n";);
return true; // changing the value of a correct monic
}
@ -1297,30 +1297,30 @@ bool core::has_real(const monic& m) const {
// returns true if the patching is blocking
bool core::is_patch_blocked(lpvar u, const lp::impq& ival) const {
TRACE("nla_solver", tout << "u = " << u << '\n';);
TRACE(nla_solver, tout << "u = " << u << '\n';);
if (m_cautious_patching &&
(!lra.inside_bounds(u, ival) || (var_is_int(u) && ival.is_int() == false))) {
TRACE("nla_solver", tout << "u = " << u << " blocked, for feas or integr\n";);
TRACE(nla_solver, tout << "u = " << u << " blocked, for feas or integr\n";);
return true; // block
}
if (u == m_patched_var) {
TRACE("nla_solver", tout << "u == m_patched_var, no block\n";);
TRACE(nla_solver, tout << "u == m_patched_var, no block\n";);
return false; // do not block
}
// we can change only one variable in variables of m_patched_var
if (m_patched_monic->contains_var(u) || u == var(*m_patched_monic)) {
TRACE("nla_solver", tout << "u = " << u << " blocked as contained\n";);
TRACE(nla_solver, tout << "u = " << u << " blocked as contained\n";);
return true; // block
}
if (var_breaks_correct_monic(u)) {
TRACE("nla_solver", tout << "u = " << u << " blocked as used in a correct monomial\n";);
TRACE(nla_solver, tout << "u = " << u << " blocked as used in a correct monomial\n";);
return true;
}
TRACE("nla_solver", tout << "u = " << u << ", m_patched_m = "; print_monic(*m_patched_monic, tout) <<
TRACE(nla_solver, tout << "u = " << u << ", m_patched_m = "; print_monic(*m_patched_monic, tout) <<
", not blocked\n";);
return false;
@ -1343,7 +1343,7 @@ bool core::to_refine_is_correct() const {
if (!is_monic_var(j)) continue;
bool valid = check_monic(emon(j));
if (valid == m_to_refine.contains(j)) {
TRACE("nla_solver", tout << "inconstency in m_to_refine : ";
TRACE(nla_solver, tout << "inconstency in m_to_refine : ";
print_monic(emon(j), tout) << "\n";
if (valid) tout << "should NOT be in to_refine\n";
else tout << "should be in to_refine\n";);
@ -1356,7 +1356,7 @@ bool core::to_refine_is_correct() const {
void core::patch_monomial(lpvar j) {
m_patched_monic =& (emon(j));
m_patched_var = j;
TRACE("nla_solver", tout << "m = "; print_monic(*m_patched_monic, tout) << "\n";);
TRACE(nla_solver, tout << "m = "; print_monic(*m_patched_monic, tout) << "\n";);
rational v = mul_val(*m_patched_monic);
if (val(j) == v) {
erase_from_to_refine(j);
@ -1368,18 +1368,18 @@ void core::patch_monomial(lpvar j) {
}
// We could not patch j, now we try patching the factor variables.
TRACE("nla_solver", tout << " trying squares\n";);
TRACE(nla_solver, tout << " trying squares\n";);
// handle perfect squares
if ((*m_patched_monic).vars().size() == 2 && (*m_patched_monic).vars()[0] == (*m_patched_monic).vars()[1]) {
rational root;
if (v.is_perfect_square(root)) {
m_patched_var = (*m_patched_monic).vars()[0];
if (!var_breaks_correct_monic(m_patched_var) && (try_to_patch(root) || try_to_patch(-root))) {
TRACE("nla_solver", tout << "patched square\n";);
TRACE(nla_solver, tout << "patched square\n";);
return;
}
}
TRACE("nla_solver", tout << " cannot patch\n";);
TRACE(nla_solver, tout << " cannot patch\n";);
return;
}
@ -1388,13 +1388,13 @@ void core::patch_monomial(lpvar j) {
if (!v.is_zero()) {
rational r = val(j) / v;
SASSERT((*m_patched_monic).is_sorted());
TRACE("nla_solver", tout << "r = " << r << ", v = " << v << "\n";);
TRACE(nla_solver, tout << "r = " << r << ", v = " << v << "\n";);
for (unsigned l = 0; l < (*m_patched_monic).size(); l++) {
m_patched_var = (*m_patched_monic).vars()[l];
if (!in_power((*m_patched_monic).vars(), l) &&
!var_breaks_correct_monic(m_patched_var) &&
try_to_patch(r * val(m_patched_var))) { // r * val(k) gives the right value of k
TRACE("nla_solver", tout << "patched " << m_patched_var << "\n";);
TRACE(nla_solver, tout << "patched " << m_patched_var << "\n";);
SASSERT(mul_val((*m_patched_monic)) == val(j));
erase_from_to_refine(j);
break;
@ -1415,7 +1415,7 @@ void core::patch_monomials_on_to_refine() {
for (unsigned i = 0; i < sz && !m_to_refine.empty(); i++)
patch_monomial(to_refine[(start + i) % sz]);
TRACE("nla_solver", tout << "sz = " << sz << ", m_to_refine = " << m_to_refine.size() <<
TRACE(nla_solver, tout << "sz = " << sz << ", m_to_refine = " << m_to_refine.size() <<
(sz > m_to_refine.size()? " less" : " same" ) << "\n";);
}
@ -1471,7 +1471,7 @@ void core::add_bounds() {
m_emons.set_bound_propagated(m);
// split the free variable (j <= 0, or j > 0), and return
m_literals.push_back(ineq(j, lp::lconstraint_kind::EQ, rational::zero()));
TRACE("nla_solver", print_ineq(m_literals.back(), tout) << "\n");
TRACE(nla_solver, print_ineq(m_literals.back(), tout) << "\n");
++lp_settings().stats().m_nla_add_bounds;
return;
}
@ -1480,11 +1480,11 @@ void core::add_bounds() {
lbool core::check() {
lp_settings().stats().m_nla_calls++;
TRACE("nla_solver", tout << "calls = " << lp_settings().stats().m_nla_calls << "\n";);
TRACE(nla_solver, tout << "calls = " << lp_settings().stats().m_nla_calls << "\n";);
lra.get_rid_of_inf_eps();
if (!(lra.get_status() == lp::lp_status::OPTIMAL ||
lra.get_status() == lp::lp_status::FEASIBLE)) {
TRACE("nla_solver", tout << "unknown because of the lra.m_status = " << lra.get_status() << "\n";);
TRACE(nla_solver, tout << "unknown because of the lra.m_status = " << lra.get_status() << "\n";);
return l_undef;
}
@ -1567,9 +1567,9 @@ lbool core::check() {
lp_settings().stats().m_nla_lemmas += m_lemmas.size();
TRACE("nla_solver", tout << "ret = " << ret << ", lemmas count = " << m_lemmas.size() << "\n";);
TRACE(nla_solver, tout << "ret = " << ret << ", lemmas count = " << m_lemmas.size() << "\n";);
IF_VERBOSE(5, if(ret == l_undef) {verbose_stream() << "Monomials\n"; print_monics(verbose_stream());});
CTRACE("nla_solver", ret == l_undef, tout << "Monomials\n"; print_monics(tout););
CTRACE(nla_solver, ret == l_undef, tout << "Monomials\n"; print_monics(tout););
return ret;
}
@ -1610,7 +1610,7 @@ lbool core::bounded_nlsat() {
bool core::no_lemmas_hold() const {
for (auto & l : m_lemmas) {
if (lemma_holds(l)) {
TRACE("nla_solver", print_lemma(l, tout););
TRACE(nla_solver, print_lemma(l, tout););
return false;
}
}

View file

@ -102,7 +102,7 @@ namespace nla {
for (auto eq : m_solver.equations()) {
if (is_conflicting(*eq)) {
lp_settings().stats().m_grobner_conflicts++;
TRACE("grobner", m_solver.display(tout));
TRACE(grobner, m_solver.display(tout));
IF_VERBOSE(3, verbose_stream() << "grobner conflict\n");
return true;
}
@ -229,7 +229,7 @@ namespace nla {
m_solver.reset();
try {
set_level2var();
TRACE("grobner",
TRACE(grobner,
tout << "base vars: ";
for (lpvar j : c().active_var_set())
if (lra.is_base(j))
@ -247,7 +247,7 @@ namespace nla {
IF_VERBOSE(2, verbose_stream() << "pdd throw\n");
return false;
}
TRACE("grobner", m_solver.display(tout));
TRACE(grobner, m_solver.display(tout));
#if 0
IF_VERBOSE(2, m_pdd_grobner.display(verbose_stream()));
@ -323,7 +323,7 @@ namespace nla {
scoped_dep_interval i(di), i_wd(di);
evali.get_interval<dd::w_dep::without_deps>(e.poly(), i);
if (!di.separated_from_zero(i)) {
TRACE("grobner", m_solver.display(tout << "not separated from 0 ", e) << "\n";
TRACE(grobner, m_solver.display(tout << "not separated from 0 ", e) << "\n";
evali.get_interval_distributed<dd::w_dep::without_deps>(e.poly(), i);
tout << "separated from 0: " << di.separated_from_zero(i) << "\n";
for (auto j : e.poly().free_vars()) {
@ -348,7 +348,7 @@ namespace nla {
lemma &= e;
};
if (di.check_interval_for_conflict_on_zero(i_wd, e.dep(), f)) {
TRACE("grobner", m_solver.display(tout << "conflict ", e) << "\n");
TRACE(grobner, m_solver.display(tout << "conflict ", e) << "\n");
return true;
}
else {
@ -356,7 +356,7 @@ namespace nla {
if (add_nla_conflict(e))
return true;
#endif
TRACE("grobner", m_solver.display(tout << "no conflict ", e) << "\n");
TRACE(grobner, m_solver.display(tout << "no conflict ", e) << "\n");
return false;
}
}
@ -439,7 +439,7 @@ namespace nla {
// a free column over the reals can be assigned
if (lra.column_is_free(k) && k != j && !lra.var_is_int(k))
continue;
CTRACE("grobner", matrix.m_rows[row].size() > c().params().arith_nl_grobner_row_length_limit(),
CTRACE(grobner, matrix.m_rows[row].size() > c().params().arith_nl_grobner_row_length_limit(),
tout << "ignore the row " << row << " with the size " << matrix.m_rows[row].size() << "\n";);
// limits overhead of grobner equations, unless this is for extracting a complete COI of the non-satisfied subset.
if (!m_add_all_eqs && matrix.m_rows[row].size() > c().params().arith_nl_horner_row_length_limit())
@ -564,14 +564,14 @@ namespace nla {
dd::pdd sum = m_pdd_manager.mk_val(rational(0));
for (const auto &p : row)
sum += pdd_expr(p.coeff(), p.var(), dep);
TRACE("grobner", c().print_row(row, tout) << " " << sum << "\n");
TRACE(grobner, c().print_row(row, tout) << " " << sum << "\n");
add_eq(sum, dep);
}
void grobner::find_nl_cluster() {
prepare_rows_and_active_vars();
svector<lpvar> q;
TRACE("grobner", for (lpvar j : c().m_to_refine) print_monic(c().emons()[j], tout) << "\n";);
TRACE(grobner, for (lpvar j : c().m_to_refine) print_monic(c().emons()[j], tout) << "\n";);
for (lpvar j : c().m_to_refine)
q.push_back(j);
@ -581,7 +581,7 @@ namespace nla {
q.pop_back();
add_var_and_its_factors_to_q_and_collect_new_rows(j, q);
}
TRACE("grobner", tout << "vars in cluster: ";
TRACE(grobner, tout << "vars in cluster: ";
for (lpvar j : c().active_var_set()) tout << "j" << j << " "; tout << "\n";
display_matrix_of_m_rows(tout);
);
@ -630,7 +630,7 @@ namespace nla {
m_pdd_manager.reset(l2v);
TRACE("grobner",
TRACE(grobner,
for (auto v : sorted_vars)
tout << "j" << v << " w:" << weighted_vars[v] << " ";
tout << "\n");
@ -698,13 +698,13 @@ namespace nla {
void grobner::check_missing_propagation(const dd::solver::equation& e) {
bool is_confl = is_nla_conflict(e);
CTRACE("grobner", is_confl, m_solver.display(tout << "missed conflict ", e););
CTRACE(grobner, is_confl, m_solver.display(tout << "missed conflict ", e););
if (is_confl) {
IF_VERBOSE(2, verbose_stream() << "missed conflict\n");
return;
}
//lbool r = c().m_nra.check_tight(e.poly());
//CTRACE("grobner", r == l_false, m_solver.display(tout << "tight equality ", e););
//CTRACE(grobner, r == l_false, m_solver.display(tout << "tight equality ", e););
}

View file

@ -101,13 +101,13 @@ bool intervals::check_nex(const nex* n, u_dependency* initial_deps) {
}
scoped_dep_interval interv_wd(get_dep_intervals());
interval_of_expr<e_with_deps::with_deps>(n, 1, interv_wd, f);
TRACE("nla_intervals", display_separating_interval(tout, n, interv_wd, initial_deps););
TRACE(nla_intervals, display_separating_interval(tout, n, interv_wd, initial_deps););
m_dep_intervals.check_interval_for_conflict_on_zero(interv_wd, initial_deps, f);
return true;
}
void intervals::add_mul_of_degree_one_to_vector(const nex_mul* e, vector<std::pair<rational, lpvar>> &v) {
TRACE("nla_intervals_details", tout << *e << "\n";);
TRACE(nla_intervals_details, tout << *e << "\n";);
SASSERT(e->size() == 1);
SASSERT((*e)[0].pow() == 1);
const nex *ev = (*e)[0].e();
@ -116,7 +116,7 @@ void intervals::add_mul_of_degree_one_to_vector(const nex_mul* e, vector<std::pa
}
void intervals::add_linear_to_vector(const nex* e, vector<std::pair<rational, lpvar>> &v) {
TRACE("nla_intervals_details", tout << *e << "\n";);
TRACE(nla_intervals_details, tout << *e << "\n";);
switch (e->type()) {
case expr_type::MUL:
add_mul_of_degree_one_to_vector(to_mul(e), v);
@ -132,7 +132,7 @@ void intervals::add_linear_to_vector(const nex* e, vector<std::pair<rational, lp
// e = a * can_t + b
lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational& a, rational& b) {
TRACE("nla_intervals_details", tout << *e << "\n";);
TRACE(nla_intervals_details, tout << *e << "\n";);
lpvar smallest_j = 0;
vector<std::pair<rational, lpvar>> v;
b = rational(0);
@ -150,7 +150,7 @@ lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational
}
}
}
TRACE("nla_intervals_details", tout << "a_index = " << a_index << ", v="; print_vector(v, tout) << "\n";);
TRACE(nla_intervals_details, tout << "a_index = " << a_index << ", v="; print_vector(v, tout) << "\n";);
a = v[a_index].first;
lp::lar_term t;
@ -167,7 +167,7 @@ lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational
t.add_var(p.second);
}
}
TRACE("nla_intervals_details", tout << a << "* (";
TRACE(nla_intervals_details, tout << a << "* (";
lp::lar_solver::print_term_as_indices(t, tout) << ") + " << b << std::endl;);
SASSERT(t.is_normalized());
return t;
@ -244,7 +244,7 @@ std::ostream& intervals::display(std::ostream& out, const interval& i) const {
template <e_with_deps wd>
void intervals::set_var_interval(lpvar v, interval& b) {
TRACE("nla_intervals_details", m_core->print_var(v, tout) << "\n";);
TRACE(nla_intervals_details, m_core->print_var(v, tout) << "\n";);
u_dependency* dep = nullptr;
rational val;
bool is_strict;
@ -285,7 +285,7 @@ bool intervals::interval_from_term(const nex& e, scoped_dep_interval& i) {
}
i.get().m_upper_dep = i.get().m_lower_dep;
}
TRACE("nla_intervals", tout << "explain_by_equiv\n";);
TRACE(nla_intervals, tout << "explain_by_equiv\n";);
return true;
}
lpvar j = find_term_column(norm_t, a);
@ -298,7 +298,7 @@ bool intervals::interval_from_term(const nex& e, scoped_dep_interval& i) {
m_dep_intervals.add(b, bi);
m_dep_intervals.set<wd>(i, bi);
TRACE("nla_intervals",
TRACE(nla_intervals,
m_core->lra.print_column_info(j, tout) << "\n";
tout << "a=" << a << ", b=" << b << "\n";
tout << e << ", interval = "; display(tout, i););
@ -315,20 +315,20 @@ bool intervals::interval_of_sum_no_term(const nex_sum& e, scoped_dep_interval &
if (!interval_of_expr<wd>(e[0], 1, sdi, f))
return false;
for (unsigned k = 1; k < e.size(); k++) {
TRACE("nla_intervals_details", tout << "e[" << k << "]= " << *e[k] << "\n";);
TRACE(nla_intervals_details, tout << "e[" << k << "]= " << *e[k] << "\n";);
scoped_dep_interval b(get_dep_intervals());
if (!interval_of_expr<wd>(e[k], 1, b, f)) {
return false;
}
scoped_dep_interval c(get_dep_intervals());
TRACE("nla_intervals_details", tout << "sdi = "; display(tout, sdi) << "\nb = "; display(tout, b) << "\n";);
TRACE(nla_intervals_details, tout << "sdi = "; display(tout, sdi) << "\nb = "; display(tout, b) << "\n";);
m_dep_intervals.add<wd>(sdi, b, c);
m_dep_intervals.set<wd>(sdi, c);
TRACE("nla_intervals_details", tout << *e[k] << ", ";
TRACE(nla_intervals_details, tout << *e[k] << ", ";
display(tout, sdi); tout << "\n";);
}
TRACE("nla_intervals_details", tout << "e=" << e << "\n";
TRACE(nla_intervals_details, tout << "e=" << e << "\n";
tout << " interv = "; display(tout, sdi););
return true; // no conflict
}
@ -355,21 +355,21 @@ bool intervals::conflict_u_l(const interval& a, const interval& b) const {
template <e_with_deps wd, typename T>
bool intervals::interval_of_sum(const nex_sum& e, scoped_dep_interval& a, const std::function<void (const T&)>& f) {
TRACE("nla_intervals_details", tout << "e=" << e << "\n";);
TRACE(nla_intervals_details, tout << "e=" << e << "\n";);
if(! interval_of_sum_no_term<wd>(e, a, f)) {
return false;
}
TRACE("nla_intervals_details", tout << "a = "; display(tout, a););
TRACE(nla_intervals_details, tout << "a = "; display(tout, a););
if (e.is_a_linear_term()) {
SASSERT(e.is_sum() && e.size() > 1);
scoped_dep_interval i_from_term(get_dep_intervals());
if (interval_from_term<wd>(e, i_from_term)) {
scoped_dep_interval r(get_dep_intervals());
m_dep_intervals.intersect<wd>(a, i_from_term, r);
TRACE("nla_intervals_details", tout << "intersection="; display(tout, r) << "\n";);
TRACE(nla_intervals_details, tout << "intersection="; display(tout, r) << "\n";);
if (m_dep_intervals.is_empty(r)) {
TRACE("nla_intervals_details", tout << "empty\n";);
TRACE(nla_intervals_details, tout << "empty\n";);
if (wd == e_with_deps::with_deps) {
T expl;
if (conflict_u_l(a, i_from_term)) {
@ -395,7 +395,7 @@ bool intervals::interval_of_sum(const nex_sum& e, scoped_dep_interval& a, const
template <e_with_deps wd, typename T>
bool intervals::interval_of_mul(const nex_mul& e, scoped_dep_interval& a, const std::function<void (const T&)>& f) {
TRACE("nla_intervals_details", tout << "e = " << e << "\n";);
TRACE(nla_intervals_details, tout << "e = " << e << "\n";);
const nex* zero_interval_child = get_zero_interval_child(e);
if (zero_interval_child) {
bool r = interval_of_expr<wd>(zero_interval_child, 1, a, f);
@ -403,25 +403,25 @@ bool intervals::interval_of_mul(const nex_mul& e, scoped_dep_interval& a, const
(void)r;
if(wd == e_with_deps::with_deps)
set_zero_interval_deps_for_mult(a);
TRACE("nla_intervals_details", tout << "zero_interval_child = " << *zero_interval_child << std::endl << "a = "; display(tout, a); );
TRACE(nla_intervals_details, tout << "zero_interval_child = " << *zero_interval_child << std::endl << "a = "; display(tout, a); );
return true; // regural calculation: no conflict
}
m_dep_intervals.set_interval_for_scalar(a, e.coeff());
TRACE("nla_intervals_details", tout << "a = "; display(tout, a); );
TRACE(nla_intervals_details, tout << "a = "; display(tout, a); );
for (const auto& ep : e) {
scoped_dep_interval b(get_dep_intervals());
if (!interval_of_expr<wd>(ep.e(), ep.pow(), b, f))
return false;
TRACE("nla_intervals_details", tout << "ep = " << ep << ", "; display(tout, b); );
TRACE(nla_intervals_details, tout << "ep = " << ep << ", "; display(tout, b); );
scoped_dep_interval c(get_dep_intervals());
m_dep_intervals.mul<wd>(a, b, c);
TRACE("nla_intervals_details", tout << "a "; display(tout, a););
TRACE("nla_intervals_details", tout << "c "; display(tout, c););
TRACE(nla_intervals_details, tout << "a "; display(tout, a););
TRACE(nla_intervals_details, tout << "c "; display(tout, c););
m_dep_intervals.set<wd>(a, c);
TRACE("nla_intervals_details", tout << "part mult "; display(tout, a););
TRACE(nla_intervals_details, tout << "part mult "; display(tout, a););
}
TRACE("nla_intervals_details", tout << "e=" << e << "\n";
TRACE(nla_intervals_details, tout << "e=" << e << "\n";
tout << " return "; display(tout, a););
return true;
}
@ -465,7 +465,7 @@ bool intervals::interval_of_expr(const nex* e, unsigned p, scoped_dep_interval&
}
break;
default:
TRACE("nla_intervals_details", tout << e->type() << "\n";);
TRACE(nla_intervals_details, tout << e->type() << "\n";);
UNREACHABLE();
}
return true; // no conflict

View file

@ -18,9 +18,9 @@ typedef lp::lar_term term;
// The order lemma is
// a > b && c > 0 => ac > bc
void order::order_lemma() {
TRACE("nla_solver", );
TRACE(nla_solver, );
if (!c().params().arith_nl_order()) {
TRACE("nla_solver", tout << "not generating order lemmas\n";);
TRACE(nla_solver, tout << "not generating order lemmas\n";);
return;
}
@ -38,7 +38,7 @@ void order::order_lemma() {
// Consider here some binary factorizations of m=ac and
// try create order lemmas with either factor playing the role of c.
void order::order_lemma_on_monic(const monic& m) {
TRACE("nla_solver_details",
TRACE(nla_solver_details,
tout << "m = " << pp_mon(c(), m););
for (auto ac : factorization_factory_imp(m, _())) {
if (ac.size() != 2)
@ -56,7 +56,7 @@ void order::order_lemma_on_monic(const monic& m) {
// a > b && c > 0 => ac > bc,
// with either variable of ac playing the role of c
void order::order_lemma_on_binomial(const monic& ac) {
TRACE("nla_solver", tout << pp_mon_with_vars(c(), ac););
TRACE(nla_solver, tout << pp_mon_with_vars(c(), ac););
SASSERT(!check_monic(ac) && ac.size() == 2);
const rational mult_val = mul_val(ac);
const rational acv = var_val(ac);
@ -93,14 +93,14 @@ void order::order_lemma_on_binomial_sign(const monic& xy, lpvar x, lpvar y, int
// We look for monics e = m.rvars()[k]*d and see if we can create an order lemma for m and e
void order::order_lemma_on_factor_binomial_explore(const monic& ac, bool k) {
TRACE("nla_solver", tout << "ac = " << pp_mon_with_vars(c(), ac););
TRACE(nla_solver, tout << "ac = " << pp_mon_with_vars(c(), ac););
SASSERT(ac.size() == 2);
lpvar c = ac.vars()[k];
for (monic const& bd : _().emons().get_products_of(c)) {
if (bd.var() == ac.var())
continue;
TRACE("nla_solver", tout << "bd = " << pp_mon_with_vars(_(), bd););
TRACE(nla_solver, tout << "bd = " << pp_mon_with_vars(_(), bd););
order_lemma_on_factor_binomial_rm(ac, k, bd);
if (done())
break;
@ -110,7 +110,7 @@ void order::order_lemma_on_factor_binomial_explore(const monic& ac, bool k) {
// ac is a binomial
// create order lemma on monics bd where d is equivalent to ac[k]
void order::order_lemma_on_factor_binomial_rm(const monic& ac, bool k, const monic& bd) {
TRACE("nla_solver",
TRACE(nla_solver,
tout << "ac=" << pp_mon_with_vars(_(), ac) << "\n";
tout << "k=" << k << "\n";
tout << "bd=" << pp_mon_with_vars(_(), bd) << "\n";
@ -126,7 +126,7 @@ void order::order_lemma_on_factor_binomial_rm(const monic& ac, bool k, const mon
void order::order_lemma_on_binomial_ac_bd(const monic& ac, bool k, const monic& bd, const factor& b, lpvar d) {
lpvar a = ac.vars()[!k];
lpvar c = ac.vars()[k];
TRACE("nla_solver",
TRACE(nla_solver,
tout << "ac = " << pp_mon(_(), ac) << "a = " << pp_var(_(), a) << "c = " << pp_var(_(), c) << "\nbd = " << pp_mon(_(), bd) << "b = " << pp_fac(_(), b) << "d = " << pp_var(_(), d) << "\n";
);
SASSERT(_().m_evars.find(c).var() == d);
@ -138,7 +138,7 @@ void order::order_lemma_on_binomial_ac_bd(const monic& ac, bool k, const monic&
rational bv = val(b);
// Notice that ac/|c| = a*c_sign , and bd/|d| = b*d_sign
auto av_c_s = av*c_sign; auto bv_d_s = bv*d_sign;
TRACE("nla_solver",
TRACE(nla_solver,
tout << "acv = " << acv << ", av = " << av << ", c_sign = " << c_sign << ", d_sign = " << d_sign << ", bdv = " << bdv <<
"\nbv = " << bv << ", av_c_s = " << av_c_s << ", bv_d_s = " << bv_d_s << "\n";);
@ -187,7 +187,7 @@ bool order::order_lemma_on_ac_and_bc(const monic& rm_ac,
const factorization& ac_f,
bool k,
const monic& rm_bd) {
TRACE("nla_solver",
TRACE(nla_solver,
tout << "rm_ac = " << pp_mon_with_vars(_(), rm_ac) << "\n";
tout << "rm_bd = " << pp_mon_with_vars(_(), rm_bd) << "\n";
tout << "ac_f[k] = ";
@ -209,7 +209,7 @@ void order::order_lemma_on_factorization(const monic& m, const factorization& ab
const rational rsign = sign_to_rat(sign);
const rational fv = val(var(ab[0])) * val(var(ab[1]));
const rational mv = rsign * var_val(m);
TRACE("nla_solver",
TRACE(nla_solver,
tout << "ab.size()=" << ab.size() << "\n";
tout << "we should have mv =" << mv << " = " << fv << " = fv\n";
tout << "m = "; _().print_monic_with_vars(m, tout); tout << "\nab ="; _().print_factorization(ab, tout););
@ -230,9 +230,9 @@ void order::order_lemma_on_factorization(const monic& m, const factorization& ab
void order::order_lemma_on_ac_explore(const monic& rm, const factorization& ac, bool k) {
const factor c = ac[k];
TRACE("nla_solver", tout << "c = "; _().print_factor_with_vars(c, tout); );
TRACE(nla_solver, tout << "c = "; _().print_factor_with_vars(c, tout); );
if (c.is_var()) {
TRACE("nla_solver", tout << "var(c) = " << var(c););
TRACE(nla_solver, tout << "var(c) = " << var(c););
for (monic const& bc : _().emons().get_use_list(c.var())) {
if (order_lemma_on_ac_and_bc(rm, ac, k, bc))
return;
@ -278,7 +278,7 @@ void order::generate_ol(const monic& ac,
const factor& b) {
new_lemma lemma(_(), __FUNCTION__);
TRACE("nla_solver", _().trace_print_ol(ac, a, c, bc, b, tout););
TRACE(nla_solver, _().trace_print_ol(ac, a, c, bc, b, tout););
IF_VERBOSE(10, verbose_stream() << var_val(ac) << "(" << mul_val(ac) << "): " << ac
<< " " << var_val(bc) << "(" << mul_val(bc) << "): " << bc << "\n"
<< " a " << "*v" << var(a) << " " << val(a) << "\n"
@ -344,7 +344,7 @@ void order::order_lemma_on_ab_gt(new_lemma& lemma, const monic& m, const rationa
lemma b != val(b) || sign*m >= a*val(b)
*/
void order::order_lemma_on_ab_lt(new_lemma& lemma, const monic& m, const rational& sign, lpvar a, lpvar b) {
TRACE("nla_solver", tout << "sign = " << sign << ", m = "; c().print_monic(m, tout) << ", a = "; c().print_var(a, tout) <<
TRACE(nla_solver, tout << "sign = " << sign << ", m = "; c().print_monic(m, tout) << ", a = "; c().print_var(a, tout) <<
", b = "; c().print_var(b, tout) << "\n";);
SASSERT(sign * var_val(m) < val(a) * val(b));
// negate b == val(b)

View file

@ -79,7 +79,7 @@ am().set(rval, am_value(r));
namespace nla {
lbool powers::check(lpvar r, lpvar x, lpvar y, vector<lemma>& lemmas) {
TRACE("nla", tout << r << " == " << x << "^" << y << "\n");
TRACE(nla, tout << r << " == " << x << "^" << y << "\n");
core& c = m_core;
if (x == null_lpvar || y == null_lpvar || r == null_lpvar)
return l_undef;

View file

@ -50,7 +50,7 @@ public:
void operator()() {
get_points();
TRACE("nla_solver", print_tangent_domain(tout << "tang domain = ") << std::endl;);
TRACE(nla_solver, print_tangent_domain(tout << "tang domain = ") << std::endl;);
generate_line1();
generate_line2();
generate_plane(m_a);
@ -113,7 +113,7 @@ private:
rational delta = rational(1);
if (!all_ints )
delta = std::min(delta, abs(m_correct_v - m_v));
TRACE("nla_solver", tout << "delta = " << delta << "\n";);
TRACE(nla_solver, tout << "delta = " << delta << "\n";);
if (!m_below){
m_a = point(x - delta, y + delta);
m_b = point(x + delta, y - delta);
@ -140,9 +140,9 @@ private:
while (steps-- && !c().done()) {
del *= rational(2);
point na = m_xy + del;
TRACE("nla_solver_tp", tout << "del = " << del << std::endl;);
TRACE(nla_solver_tp, tout << "del = " << del << std::endl;);
if (!plane_is_correct_cut(na)) {
TRACE("nla_solver_tp", tout << "exit\n";);
TRACE(nla_solver_tp, tout << "exit\n";);
return;
}
a = na;
@ -155,11 +155,11 @@ private:
void get_points() {
get_initial_points();
TRACE("nla_solver", tout << "xy = " << m_xy << ", correct val = " << m_correct_v;
TRACE(nla_solver, tout << "xy = " << m_xy << ", correct val = " << m_correct_v;
print_tangent_domain(tout << "\ntang points:") << std::endl;);
push_point(m_a);
push_point(m_b);
TRACE("nla_solver",
TRACE(nla_solver,
tout << "pushed a = " << m_a << std::endl
<< "pushed b = " << m_b << std::endl
<< "tang_plane(a) = " << tang_plane(m_a) << " , val = " << m_a << ", "
@ -171,7 +171,7 @@ private:
}
bool plane_is_correct_cut(const point& plane) const {
TRACE("nla_solver", tout << "plane = " << plane << "\n";
TRACE(nla_solver, tout << "plane = " << plane << "\n";
tout << "tang_plane() = " << tang_plane(plane) << ", v = " << m_v << ", correct_v = " << m_correct_v << "\n";);
SASSERT((m_below && m_v < m_correct_v) ||
((!m_below) && m_v > m_correct_v));

View file

@ -160,7 +160,7 @@ struct solver::imp {
for (unsigned i : m_term_set)
add_term(i);
TRACE("nra", m_nlsat->display(tout));
TRACE(nra, m_nlsat->display(tout));
smt_params_helper p(m_params);
if (p.arith_nl_log()) {
@ -194,7 +194,7 @@ struct solver::imp {
}
}
m_nlsat->collect_statistics(st);
TRACE("nra",
TRACE(nra,
m_nlsat->display(tout << r << "\n");
display(tout);
for (auto [j, x] : m_lp2nl) tout << "j" << j << " := x" << x << "\n";);
@ -224,7 +224,7 @@ struct solver::imp {
for (auto c : core) {
unsigned idx = static_cast<unsigned>(static_cast<imp*>(c) - this);
ex.push_back(idx);
TRACE("nra", lra.display_constraint(tout << "ex: " << idx << ": ", idx) << "\n";);
TRACE(nra, lra.display_constraint(tout << "ex: " << idx << ": ", idx) << "\n";);
}
nla::new_lemma lemma(m_nla_core, __FUNCTION__);
lemma &= ex;

View file

@ -34,7 +34,7 @@ random_updater::random_updater(
m_range(100000) {
for (unsigned j : column_indices)
m_var_set.insert(j);
TRACE("lar_solver_rand", tout << "size = " << m_var_set.size() << "\n";);
TRACE(lar_solver_rand, tout << "size = " << m_var_set.size() << "\n";);
}
@ -62,7 +62,7 @@ void random_updater::update() {
}
for (auto j : columns) {
if (!m_var_set.contains(j)) {
TRACE("lar_solver_rand", tout << "skipped " << j << "\n";);
TRACE(lar_solver_rand, tout << "skipped " << j << "\n";);
continue;
}
if (!m_lar_solver.is_base(j))
@ -78,7 +78,7 @@ void random_updater::update() {
}
}
}
TRACE("lar_solver_rand", tout << "m_var_set.size() = " << m_var_set.size() << "\n";);
TRACE(lar_solver_rand, tout << "m_var_set.size() = " << m_var_set.size() << "\n";);
}
}

View file

@ -116,7 +116,7 @@ public:
unsigned max_i = std::max(v1.index(), v2.index()) + 2;
m_eqs.reserve(max_i);
while (m_uf.get_num_vars() <= max_i) m_uf.mk_var();
TRACE("nla_solver_mons", tout << v1 << " == " << v2 << " " << m_uf.find(v1.index()) << " == " << m_uf.find(v2.index()) << "\n";);
TRACE(nla_solver_mons, tout << v1 << " == " << v2 << " " << m_uf.find(v1.index()) << " == " << m_uf.find(v2.index()) << "\n";);
m_trail.push_back(std::make_pair(v1, v2));
m_uf.merge(v1.index(), v2.index());
m_uf.merge((~v1).index(), (~v2).index());