mirror of
https://github.com/Z3Prover/z3
synced 2025-08-03 18:00:23 +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:
parent
d766292dab
commit
0a93ff515d
583 changed files with 8698 additions and 7299 deletions
|
@ -351,7 +351,7 @@ public:
|
|||
//
|
||||
void compress() {
|
||||
SASSERT(!m_delta.empty());
|
||||
TRACE("seq", display(tout););
|
||||
TRACE(seq, display(tout););
|
||||
for (unsigned i = 0; i < m_delta.size(); ++i) {
|
||||
for (unsigned j = 0; j < m_delta[i].size(); ++j) {
|
||||
move const& mv = m_delta[i][j];
|
||||
|
@ -443,7 +443,7 @@ public:
|
|||
}
|
||||
}
|
||||
else {
|
||||
TRACE("seq", tout << "epsilon not removed " << out_degree(src) << " " << is_final_state(src) << " " << is_final_state(dst) << "\n";);
|
||||
TRACE(seq, tout << "epsilon not removed " << out_degree(src) << " " << is_final_state(src) << " " << is_final_state(dst) << "\n";);
|
||||
continue;
|
||||
}
|
||||
remove(src, dst, nullptr);
|
||||
|
@ -464,7 +464,7 @@ public:
|
|||
}
|
||||
}
|
||||
sinkify_dead_states();
|
||||
TRACE("seq", display(tout););
|
||||
TRACE(seq, display(tout););
|
||||
}
|
||||
|
||||
bool is_sequence(unsigned& length) const {
|
||||
|
@ -624,11 +624,11 @@ private:
|
|||
}
|
||||
to_remove.reset();
|
||||
}
|
||||
TRACE("seq", tout << "remove: " << dead_states << "\n";
|
||||
TRACE(seq, tout << "remove: " << dead_states << "\n";
|
||||
tout << "final: " << m_final_states << "\n";
|
||||
);
|
||||
for (unsigned s : dead_states) {
|
||||
CTRACE("seq", !m_delta[s].empty(), tout << "live state " << s << "\n";);
|
||||
CTRACE(seq, !m_delta[s].empty(), tout << "live state " << s << "\n";);
|
||||
m_delta[s].reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ symbolic_automata<T, M>::mk_determinstic_param(automaton_t& a, bool flip_accepta
|
|||
unsigned_vector new_final_states; // new final states
|
||||
unsigned p_state_id = 0; // next state identifier
|
||||
|
||||
TRACE("seq", tout << "mk-deterministic " << flip_acceptance << " " << set << " " << a.is_final_configuration(set) << "\n";);
|
||||
TRACE(seq, tout << "mk-deterministic " << flip_acceptance << " " << set << " " << a.is_final_configuration(set) << "\n";);
|
||||
// adds non-final states of a to final if flipping and final otherwise
|
||||
unsigned_vector init_states;
|
||||
a.get_epsilon_closure(a.init(), init_states);
|
||||
|
@ -347,7 +347,7 @@ symbolic_automata<T, M>::mk_determinstic_param(automaton_t& a, bool flip_accepta
|
|||
|
||||
bool is_new = !s2id.contains(set);
|
||||
if (is_new) {
|
||||
TRACE("seq", tout << "mk-deterministic " << flip_acceptance << " " << set << " " << a.is_final_configuration(set) << "\n";);
|
||||
TRACE(seq, tout << "mk-deterministic " << flip_acceptance << " " << set << " " << a.is_final_configuration(set) << "\n";);
|
||||
if (a.is_final_configuration(set) != flip_acceptance) {
|
||||
new_final_states.push_back(p_state_id);
|
||||
}
|
||||
|
|
|
@ -305,7 +305,7 @@ namespace dd {
|
|||
goto go_down;
|
||||
}
|
||||
go_up:
|
||||
TRACE("bdd", tout << "sift up " << lvl << "\n";);
|
||||
TRACE(bdd, tout << "sift up " << lvl << "\n";);
|
||||
while (lvl < max_lvl) {
|
||||
sift_up(lvl++);
|
||||
double cost = current_cost();
|
||||
|
@ -326,7 +326,7 @@ namespace dd {
|
|||
return;
|
||||
}
|
||||
go_down:
|
||||
TRACE("bdd", tout << "sift down " << lvl << "\n";);
|
||||
TRACE(bdd, tout << "sift down " << lvl << "\n";);
|
||||
while (lvl > 0) {
|
||||
sift_up(--lvl);
|
||||
double cost = current_cost();
|
||||
|
@ -370,7 +370,7 @@ namespace dd {
|
|||
reorder_decref(h);
|
||||
m_T.push_back(n);
|
||||
}
|
||||
TRACE("bdd", tout << "remove " << n << "\n";);
|
||||
TRACE(bdd, tout << "remove " << n << "\n";);
|
||||
m_node_table.remove(m_nodes[n]);
|
||||
}
|
||||
m_level2nodes[lvl + 1].reset();
|
||||
|
@ -384,7 +384,7 @@ namespace dd {
|
|||
m_to_free.push_back(n);
|
||||
}
|
||||
else {
|
||||
TRACE("bdd", tout << "set level " << n << " to " << lvl + 1 << "\n";);
|
||||
TRACE(bdd, tout << "set level " << n << " to " << lvl + 1 << "\n";);
|
||||
m_node_table.insert(node);
|
||||
m_level2nodes[lvl + 1].push_back(n);
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ namespace dd {
|
|||
m_nodes[n].m_hi = bd;
|
||||
reorder_incref(ac);
|
||||
reorder_incref(bd);
|
||||
TRACE("bdd", tout << "transform " << n << " " << " " << a << " " << b << " " << c << " " << d << " " << ac << " " << bd << "\n";);
|
||||
TRACE(bdd, tout << "transform " << n << " " << " " << a << " " << b << " " << c << " " << d << " " << ac << " " << bd << "\n";);
|
||||
m_node_table.insert(m_nodes[n]);
|
||||
}
|
||||
unsigned v = m_level2var[lvl];
|
||||
|
@ -467,7 +467,7 @@ namespace dd {
|
|||
}
|
||||
}
|
||||
}
|
||||
TRACE("bdd", tout << "sift " << lvl << "\n"; display(tout); );
|
||||
TRACE(bdd, tout << "sift " << lvl << "\n"; display(tout); );
|
||||
DEBUG_CODE(
|
||||
for (unsigned i = 0; i < m_level2nodes.size(); ++i) {
|
||||
for (unsigned n : m_level2nodes[i]) {
|
||||
|
@ -476,7 +476,7 @@ namespace dd {
|
|||
}
|
||||
});
|
||||
|
||||
TRACE("bdd",
|
||||
TRACE(bdd,
|
||||
for (unsigned i = 0; i < m_nodes.size(); ++i) {
|
||||
if (m_reorder_rc[i] != 0) {
|
||||
tout << i << " " << m_reorder_rc[i] << "\n";
|
||||
|
@ -503,7 +503,7 @@ namespace dd {
|
|||
reorder_incref(n.m_lo);
|
||||
reorder_incref(n.m_hi);
|
||||
}
|
||||
TRACE("bdd",
|
||||
TRACE(bdd,
|
||||
display(tout);
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
bdd_node const& n = m_nodes[i];
|
||||
|
|
|
@ -427,7 +427,7 @@ bool grobner::is_eq_monomial_body(monomial const * m1, monomial const * m2) {
|
|||
\remark This method assumes the monomials are sorted.
|
||||
*/
|
||||
void grobner::merge_monomials(ptr_vector<monomial> & monomials) {
|
||||
TRACE("grobner", tout << "before merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.data()); tout << "\n";);
|
||||
TRACE(grobner, tout << "before merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.data()); tout << "\n";);
|
||||
unsigned j = 0;
|
||||
unsigned sz = monomials.size();
|
||||
if (sz == 0)
|
||||
|
@ -459,7 +459,7 @@ void grobner::merge_monomials(ptr_vector<monomial> & monomials) {
|
|||
j++;
|
||||
monomials.shrink(j);
|
||||
del_monomials(to_delete);
|
||||
TRACE("grobner", tout << "after merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.data()); tout << "\n";);
|
||||
TRACE(grobner, tout << "after merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.data()); tout << "\n";);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -538,7 +538,7 @@ bool grobner::is_subset(monomial const * m1, monomial const * m2, ptr_vector<exp
|
|||
if (i1 >= sz1) {
|
||||
for (; i2 < sz2; i2++)
|
||||
rest.push_back(m2->m_vars[i2]);
|
||||
TRACE("grobner",
|
||||
TRACE(grobner,
|
||||
tout << "monomial: "; display_monomial(tout, *m1); tout << " is a subset of ";
|
||||
display_monomial(tout, *m2); tout << "\n";
|
||||
tout << "rest: "; display_vars(tout, rest.size(), rest.data()); tout << "\n";);
|
||||
|
@ -563,7 +563,7 @@ bool grobner::is_subset(monomial const * m1, monomial const * m2, ptr_vector<exp
|
|||
}
|
||||
}
|
||||
// is not subset
|
||||
TRACE("grobner", tout << "monomial: "; display_monomial(tout, *m1); tout << " is not a subset of ";
|
||||
TRACE(grobner, tout << "monomial: "; display_monomial(tout, *m1); tout << " is not a subset of ";
|
||||
display_monomial(tout, *m2); tout << "\n";);
|
||||
return false;
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ grobner::equation * grobner::copy_equation(equation const * eq) {
|
|||
Return new_equation if source->m_scope_lvl > target->m_scope_lvl, moreover target is freezed, and new_equation contains the result.
|
||||
*/
|
||||
grobner::equation * grobner::simplify(equation const * source, equation * target) {
|
||||
TRACE("grobner", tout << "simplifying: "; display_equation(tout, *target); tout << "using: "; display_equation(tout, *source););
|
||||
TRACE(grobner, tout << "simplifying: "; display_equation(tout, *target); tout << "using: "; display_equation(tout, *source););
|
||||
if (source->get_num_monomials() == 0)
|
||||
return nullptr;
|
||||
if (!m_manager.inc())
|
||||
|
@ -673,7 +673,7 @@ grobner::equation * grobner::simplify(equation const * source, equation * target
|
|||
}
|
||||
}
|
||||
while (simplified && m_manager.inc());
|
||||
TRACE("grobner", tout << "result: "; display_equation(tout, *target););
|
||||
TRACE(grobner, tout << "result: "; display_equation(tout, *target););
|
||||
return result ? target : nullptr;
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ grobner::equation * grobner::simplify(equation const * source, equation * target
|
|||
grobner::equation * grobner::simplify_using_processed(equation * eq) {
|
||||
bool result = false;
|
||||
bool simplified;
|
||||
TRACE("grobner", tout << "simplifying: "; display_equation(tout, *eq); tout << "using already processed equalities\n";);
|
||||
TRACE(grobner, tout << "simplifying: "; display_equation(tout, *eq); tout << "using already processed equalities\n";);
|
||||
do {
|
||||
simplified = false;
|
||||
for (equation const* p : m_processed) {
|
||||
|
@ -702,7 +702,7 @@ grobner::equation * grobner::simplify_using_processed(equation * eq) {
|
|||
}
|
||||
}
|
||||
while (simplified);
|
||||
TRACE("grobner", tout << "simplification result: "; display_equation(tout, *eq););
|
||||
TRACE(grobner, tout << "simplification result: "; display_equation(tout, *eq););
|
||||
return result ? eq : nullptr;
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ grobner::equation * grobner::pick_next() {
|
|||
del_equation(e);
|
||||
if (r)
|
||||
m_to_process.erase(r);
|
||||
TRACE("grobner", tout << "selected equation: "; if (!r) tout << "<null>\n"; else display_equation(tout, *r););
|
||||
TRACE(grobner, tout << "selected equation: "; if (!r) tout << "<null>\n"; else display_equation(tout, *r););
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -819,7 +819,7 @@ void grobner::simplify_to_process(equation * eq) {
|
|||
\brief If m1 = (* c M M1) and m2 = (* d M M2) and M is non empty, then return true and store M1 in rest1 and M2 in rest2.
|
||||
*/
|
||||
bool grobner::unify(monomial const * m1, monomial const * m2, ptr_vector<expr> & rest1, ptr_vector<expr> & rest2) {
|
||||
TRACE("grobner", tout << "unifying: "; display_monomial(tout, *m1); tout << " "; display_monomial(tout, *m2); tout << "\n";);
|
||||
TRACE(grobner, tout << "unifying: "; display_monomial(tout, *m1); tout << " "; display_monomial(tout, *m2); tout << "\n";);
|
||||
bool found_M = false;
|
||||
unsigned i1 = 0;
|
||||
unsigned i2 = 0;
|
||||
|
@ -872,7 +872,7 @@ void grobner::superpose(equation * eq1, equation * eq2) {
|
|||
ptr_vector<expr> & rest2 = m_tmp_vars2;
|
||||
rest2.reset();
|
||||
if (unify(eq1->m_monomials[0], eq2->m_monomials[0], rest1, rest2)) {
|
||||
TRACE("grobner", tout << "superposing:\n"; display_equation(tout, *eq1); display_equation(tout, *eq2);
|
||||
TRACE(grobner, tout << "superposing:\n"; display_equation(tout, *eq1); display_equation(tout, *eq2);
|
||||
tout << "rest1: "; display_vars(tout, rest1.size(), rest1.data()); tout << "\n";
|
||||
tout << "rest2: "; display_vars(tout, rest2.size(), rest2.data()); tout << "\n";);
|
||||
ptr_vector<monomial> & new_monomials = m_tmp_monomials;
|
||||
|
@ -882,7 +882,7 @@ void grobner::superpose(equation * eq1, equation * eq2) {
|
|||
c.neg();
|
||||
mul_append(1, eq2, c, rest1, new_monomials);
|
||||
simplify(new_monomials);
|
||||
TRACE("grobner", tout << "resulting monomials: "; display_monomials(tout, new_monomials.size(), new_monomials.data()); tout << "\n";);
|
||||
TRACE(grobner, tout << "resulting monomials: "; display_monomials(tout, new_monomials.size(), new_monomials.data()); tout << "\n";);
|
||||
if (new_monomials.empty())
|
||||
return;
|
||||
m_num_new_equations++;
|
||||
|
@ -929,7 +929,7 @@ bool grobner::compute_basis_step() {
|
|||
superpose(eq);
|
||||
m_processed.insert(eq);
|
||||
simplify_to_process(eq);
|
||||
TRACE("grobner", tout << "end of iteration:\n"; display(tout););
|
||||
TRACE(grobner, tout << "end of iteration:\n"; display(tout););
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace dd {
|
|||
simplify_exlin() ||
|
||||
false)) {
|
||||
DEBUG_CODE(s.invariant(););
|
||||
TRACE("dd.solver", s.display(tout););
|
||||
TRACE(dd_solver, s.display(tout););
|
||||
}
|
||||
}
|
||||
catch (pdd_manager::mem_out) {
|
||||
|
@ -88,7 +88,7 @@ namespace dd {
|
|||
};
|
||||
|
||||
bool simplifier::simplify_linear_step(bool binary) {
|
||||
TRACE("dd.solver", tout << "binary " << binary << "\n";);
|
||||
TRACE(dd_solver, tout << "binary " << binary << "\n";);
|
||||
IF_VERBOSE(3, verbose_stream() << "binary " << binary << "\n");
|
||||
equation_vector linear;
|
||||
for (equation* e : s.m_to_simplify) {
|
||||
|
@ -132,7 +132,7 @@ namespace dd {
|
|||
continue;
|
||||
unsigned v = src->poly().var();
|
||||
equation_vector const& uses = use_list[v];
|
||||
TRACE("dd.solver",
|
||||
TRACE(dd_solver,
|
||||
s.display(tout << "uses of: ", *src) << "\n";
|
||||
for (equation* e : uses) s.display(tout, *e) << "\n";);
|
||||
bool changed_leading_term;
|
||||
|
@ -184,7 +184,7 @@ namespace dd {
|
|||
since px = ry
|
||||
*/
|
||||
bool simplifier::simplify_cc_step() {
|
||||
TRACE("dd.solver", tout << "cc\n";);
|
||||
TRACE(dd_solver, tout << "cc\n";);
|
||||
IF_VERBOSE(3, verbose_stream() << "cc\n");
|
||||
u_map<equation*> los;
|
||||
bool reduced = false;
|
||||
|
@ -215,7 +215,7 @@ namespace dd {
|
|||
\brief remove ax+b from p if x occurs as a leaf in p and a is a constant.
|
||||
*/
|
||||
bool simplifier::simplify_leaf_step() {
|
||||
TRACE("dd.solver", tout << "leaf\n";);
|
||||
TRACE(dd_solver, tout << "leaf\n";);
|
||||
IF_VERBOSE(3, verbose_stream() << "leaf\n");
|
||||
use_list_t use_list = get_use_list();
|
||||
equation_vector leaves;
|
||||
|
@ -257,7 +257,7 @@ namespace dd {
|
|||
\brief treat equations as processed if top variable occurs only once.
|
||||
*/
|
||||
bool simplifier::simplify_elim_pure_step() {
|
||||
TRACE("dd.solver", tout << "pure\n";);
|
||||
TRACE(dd_solver, tout << "pure\n";);
|
||||
IF_VERBOSE(3, verbose_stream() << "pure\n");
|
||||
use_list_t use_list = get_use_list();
|
||||
solver::scoped_update sc(s.m_to_simplify);
|
||||
|
@ -426,7 +426,7 @@ namespace dd {
|
|||
unsigned modest_num_eqs = std::max(eqs.size(), 500u);
|
||||
unsigned max_xlin_eqs = modest_num_eqs;
|
||||
unsigned max_degree = 5;
|
||||
TRACE("dd.solver", tout << "augment " << nv << "\n";
|
||||
TRACE(dd_solver, tout << "augment " << nv << "\n";
|
||||
for (auto const& o : orbits) tout << o.num_elems() << "\n";);
|
||||
vector<pdd> n_eqs;
|
||||
unsigned start = rand();
|
||||
|
@ -475,7 +475,7 @@ namespace dd {
|
|||
end_of_new_eqs:
|
||||
s.m_config.m_random_seed = rand();
|
||||
eqs.append(n_eqs);
|
||||
TRACE("dd.solver", for (pdd const& p : eqs) tout << p << "\n";);
|
||||
TRACE(dd_solver, for (pdd const& p : eqs) tout << p << "\n";);
|
||||
}
|
||||
|
||||
void simplifier::simplify_exlin(vector<uint_set> const& orbits, vector<pdd> const& eqs, vector<pdd>& simp_eqs) {
|
||||
|
@ -570,12 +570,12 @@ namespace dd {
|
|||
}
|
||||
}
|
||||
|
||||
TRACE("dd.solver", tout << bm << "\n";);
|
||||
TRACE(dd_solver, tout << bm << "\n";);
|
||||
IF_VERBOSE(10, verbose_stream() << "bit-matrix solving\n");
|
||||
|
||||
bm.solve();
|
||||
|
||||
TRACE("dd.solver", tout << bm << "\n";);
|
||||
TRACE(dd_solver, tout << bm << "\n";);
|
||||
IF_VERBOSE(10, verbose_stream() << "bit-matrix solved\n");
|
||||
|
||||
for (auto const& r : bm) {
|
||||
|
@ -603,7 +603,7 @@ namespace dd {
|
|||
}
|
||||
}
|
||||
if (!p.is_zero()) {
|
||||
TRACE("dd.solver", tout << "new linear: " << p << "\n";);
|
||||
TRACE(dd_solver, tout << "new linear: " << p << "\n";);
|
||||
simp_eqs.push_back(p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,10 +93,10 @@ namespace dd {
|
|||
if (done())
|
||||
return;
|
||||
init_saturate();
|
||||
TRACE("dd.solver", display(tout););
|
||||
TRACE(dd_solver, display(tout););
|
||||
try {
|
||||
while (!done() && step()) {
|
||||
TRACE("dd.solver", display(tout););
|
||||
TRACE(dd_solver, display(tout););
|
||||
DEBUG_CODE(invariant(););
|
||||
IF_VERBOSE(3, display_statistics(verbose_stream()));
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace dd {
|
|||
if (eq.poly().is_unary() && eq.poly().hi().val() < 0)
|
||||
eq = -eq.poly();
|
||||
|
||||
TRACE("dd.solver", display(tout << "simplification result: ", eq););
|
||||
TRACE(dd_solver, display(tout << "simplification result: ", eq););
|
||||
}
|
||||
|
||||
void solver::well_formed() {
|
||||
|
@ -229,7 +229,7 @@ namespace dd {
|
|||
m_too_complex = true;
|
||||
return false;
|
||||
}
|
||||
TRACE("dd.solver",
|
||||
TRACE(dd_solver,
|
||||
tout << "reduce: " << dst.poly() << "\n";
|
||||
tout << "using: " << t << "\n";
|
||||
tout << "to: " << r << "\n";);
|
||||
|
@ -246,7 +246,7 @@ namespace dd {
|
|||
pdd t = src.poly();
|
||||
pdd r = dst.poly().reduce(t);
|
||||
changed_leading_term = dst.state() == processed && m.different_leading_term(r, dst.poly());
|
||||
TRACE("dd.solver",
|
||||
TRACE(dd_solver,
|
||||
tout << "reduce: " << dst.poly() << "\n";
|
||||
tout << "using: " << t << "\n";
|
||||
tout << "to: " << r << "\n";);
|
||||
|
@ -261,7 +261,7 @@ namespace dd {
|
|||
let eq1: ab+q=0, and eq2: ac+e=0, then qc - eb = 0
|
||||
*/
|
||||
void solver::superpose(equation const& eq1, equation const& eq2) {
|
||||
TRACE("dd.solver_d", display(tout << "eq1=", eq1); display(tout << "eq2=", eq2););
|
||||
TRACE(dd_solver_d, display(tout << "eq1=", eq1); display(tout << "eq2=", eq2););
|
||||
pdd r(m);
|
||||
if (m.try_spoly(eq1.poly(), eq2.poly(), r) && !r.is_zero()) {
|
||||
if (is_too_complex(r)) {
|
||||
|
@ -297,7 +297,7 @@ namespace dd {
|
|||
simplify_using(m_processed, eq);
|
||||
if (done())
|
||||
return false;
|
||||
TRACE("dd.solver", display(tout << "eq = ", eq););
|
||||
TRACE(dd_solver, display(tout << "eq = ", eq););
|
||||
superpose(eq);
|
||||
simplify_using(m_to_simplify, eq);
|
||||
if (done())
|
||||
|
|
|
@ -833,7 +833,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
|
|||
m_zero.reset();
|
||||
m_index->reset(m_current_ineq+1);
|
||||
int_table support;
|
||||
TRACE("hilbert_basis", display_ineq(tout, ineq, is_eq););
|
||||
TRACE(hilbert_basis, display_ineq(tout, ineq, is_eq););
|
||||
iterator it = begin();
|
||||
for (; it != end(); ++it) {
|
||||
offset_t idx = *it;
|
||||
|
@ -847,7 +847,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
|
|||
support.insert(idx.m_offset);
|
||||
}
|
||||
}
|
||||
TRACE("hilbert_basis", display(tout););
|
||||
TRACE(hilbert_basis, display(tout););
|
||||
// resolve passive into active
|
||||
offset_t j = alloc_vector();
|
||||
while (!m_passive->empty()) {
|
||||
|
@ -855,7 +855,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
|
|||
return l_undef;
|
||||
}
|
||||
offset_t idx = m_passive->pop();
|
||||
TRACE("hilbert_basis", display(tout););
|
||||
TRACE(hilbert_basis, display(tout););
|
||||
if (is_subsumed(idx)) {
|
||||
recycle(idx);
|
||||
continue;
|
||||
|
@ -886,7 +886,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
|
|||
m_active.reset();
|
||||
m_passive->reset();
|
||||
m_zero.reset();
|
||||
TRACE("hilbert_basis", display(tout););
|
||||
TRACE(hilbert_basis, display(tout););
|
||||
return m_basis.empty()?l_false:l_true;
|
||||
}
|
||||
|
||||
|
@ -906,7 +906,7 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
|
|||
m_index->reset(m_current_ineq+1);
|
||||
m_passive2->reset();
|
||||
m_sos.reset();
|
||||
TRACE("hilbert_basis", display_ineq(tout, ineq, is_eq););
|
||||
TRACE(hilbert_basis, display_ineq(tout, ineq, is_eq););
|
||||
unsigned init_basis_size = 0;
|
||||
for (unsigned i = 0; i < m_basis.size(); ++i) {
|
||||
offset_t idx = m_basis[i];
|
||||
|
@ -937,12 +937,12 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
|
|||
}
|
||||
}
|
||||
|
||||
TRACE("hilbert_basis", display(tout););
|
||||
TRACE(hilbert_basis, display(tout););
|
||||
// resolve passive into active
|
||||
offset_t idx = alloc_vector();
|
||||
while (checkpoint() && !m_passive2->empty()) {
|
||||
offset_t sos, pas;
|
||||
TRACE("hilbert_basis", display(tout); );
|
||||
TRACE(hilbert_basis, display(tout); );
|
||||
unsigned offset = m_passive2->pop(sos, pas);
|
||||
SASSERT(can_resolve(sos, pas, true));
|
||||
resolve(sos, pas, idx);
|
||||
|
@ -978,7 +978,7 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
|
|||
m_basis.append(m_zero);
|
||||
std::sort(m_basis.begin(), m_basis.end(), vector_lt_t(*this));
|
||||
m_zero.reset();
|
||||
TRACE("hilbert_basis", display(tout););
|
||||
TRACE(hilbert_basis, display(tout););
|
||||
return m_basis.empty()?l_false:l_true;
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ void hilbert_basis::resolve(offset_t i, offset_t j, offset_t r) {
|
|||
for (unsigned k = 0; k < m_current_ineq; ++k) {
|
||||
u.weight(k) = v.weight(k) + w.weight(k);
|
||||
}
|
||||
TRACE("hilbert_basis_verbose",
|
||||
TRACE(hilbert_basis_verbose,
|
||||
display(tout, i);
|
||||
display(tout, j);
|
||||
display(tout, r);
|
||||
|
@ -1115,7 +1115,7 @@ bool hilbert_basis::checkpoint() {
|
|||
}
|
||||
|
||||
bool hilbert_basis::add_goal(offset_t idx) {
|
||||
TRACE("hilbert_basis", display(tout, idx););
|
||||
TRACE(hilbert_basis, display(tout, idx););
|
||||
values v = vec(idx);
|
||||
if (is_subsumed(idx)) {
|
||||
return false;
|
||||
|
@ -1308,7 +1308,7 @@ bool hilbert_basis::is_subsumed(offset_t i, offset_t j) const {
|
|||
for (unsigned k = 0; r && k < m_current_ineq; ++k) {
|
||||
r = v.weight(k) >= w.weight(k);
|
||||
}
|
||||
CTRACE("hilbert_basis", r,
|
||||
CTRACE(hilbert_basis, r,
|
||||
display(tout, i);
|
||||
tout << " <= \n";
|
||||
display(tout, j);
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
else {
|
||||
m_imanager.power(a, n, b);
|
||||
}
|
||||
TRACE("dep_intervals", tout << "power of "; display(tout, a) << " = ";
|
||||
TRACE(dep_intervals, tout << "power of "; display(tout, a) << " = ";
|
||||
display(tout, b) << "\n"; );
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
if (!separated_from_zero_on_lower(i)) {
|
||||
return false;
|
||||
}
|
||||
TRACE("dep_intervals", display(tout, i););
|
||||
TRACE(dep_intervals, display(tout, i););
|
||||
dep = m_dep_manager.mk_join(dep, i.m_lower_dep);
|
||||
T expl;
|
||||
linearize(dep, expl);
|
||||
|
@ -328,7 +328,7 @@ public:
|
|||
bool check_interval_for_conflict_on_zero_upper(const interval& i, u_dependency* dep, std::function<void (const T&)> f) {
|
||||
if (!separated_from_zero_on_upper(i))
|
||||
return false;
|
||||
TRACE("dep_intervals", display(tout, i););
|
||||
TRACE(dep_intervals, display(tout, i););
|
||||
dep = m_dep_manager.mk_join(dep, i.m_upper_dep);
|
||||
T expl;
|
||||
linearize(dep, expl);
|
||||
|
|
|
@ -200,7 +200,7 @@ void interval_manager<C>::nth_root(numeral const & a, unsigned n, numeral const
|
|||
m().abs(A);
|
||||
|
||||
nth_root_pos(A, n, p, lo, hi);
|
||||
STRACE("nth_root_trace",
|
||||
STRACE(nth_root_trace,
|
||||
tout << "[nth-root] ("; m().display(tout, A); tout << ")^(1/" << n << ") >= "; m().display(tout, lo); tout << "\n";
|
||||
tout << "[nth-root] ("; m().display(tout, A); tout << ")^(1/" << n << ") <= "; m().display(tout, hi); tout << "\n";);
|
||||
if (is_neg) {
|
||||
|
@ -309,7 +309,7 @@ void interval_manager<C>::approx_nth_root(numeral const & A, unsigned n, numeral
|
|||
m().div(x_prime, _n, x_prime);
|
||||
m().sub(x_prime, x, d);
|
||||
m().abs(d);
|
||||
TRACE("nth_root",
|
||||
TRACE(nth_root,
|
||||
tout << "A: "; m().display(tout, A); tout << "\n";
|
||||
tout << "x: "; m().display(tout, x); tout << "\n";
|
||||
tout << "x_prime: "; m().display(tout, x_prime); tout << "\n";
|
||||
|
@ -338,7 +338,7 @@ void interval_manager<C>::nth_root_pos(numeral const & A, unsigned n, numeral co
|
|||
else {
|
||||
// Check if hi is really a upper bound for A^(n-1)
|
||||
A_div_x_n(A, hi, n-1, true /* lo will be greater than the actual lower bound */, lo);
|
||||
TRACE("nth_root_bug",
|
||||
TRACE(nth_root_bug,
|
||||
tout << "Assuming upper\n";
|
||||
tout << "A: "; m().display(tout, A); tout << "\n";
|
||||
tout << "hi: "; m().display(tout, hi); tout << "\n";
|
||||
|
@ -387,7 +387,7 @@ void interval_manager<C>::fact(unsigned n, numeral & o) {
|
|||
for (unsigned i = 2; i <= n; i++) {
|
||||
m().set(aux, static_cast<int>(i));
|
||||
m().mul(aux, o, o);
|
||||
TRACE("fact_bug", tout << "i: " << i << ", o: " << m().to_rational_string(o) << "\n";);
|
||||
TRACE(fact_bug, tout << "i: " << i << ", o: " << m().to_rational_string(o) << "\n";);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,24 +407,24 @@ void interval_manager<C>::sine_series(numeral const & a, unsigned k, bool upper,
|
|||
bool sign = true;
|
||||
bool upper_factor = !upper; // since the first sign is negative, we must minimize factor to maximize result
|
||||
for (unsigned i = 3; i <= k; i+=2) {
|
||||
TRACE("sine_bug", tout << "[begin-loop] o: " << m().to_rational_string(o) << "\ni: " << i << "\n";
|
||||
TRACE(sine_bug, tout << "[begin-loop] o: " << m().to_rational_string(o) << "\ni: " << i << "\n";
|
||||
tout << "upper: " << upper << ", upper_factor: " << upper_factor << "\n";
|
||||
tout << "o (default): " << m().to_string(o) << "\n";);
|
||||
set_rounding(upper_factor);
|
||||
m().power(a, i, f);
|
||||
TRACE("sine_bug", tout << "a^i " << m().to_rational_string(f) << "\n";);
|
||||
TRACE(sine_bug, tout << "a^i " << m().to_rational_string(f) << "\n";);
|
||||
set_rounding(!upper_factor);
|
||||
fact(i, aux);
|
||||
TRACE("sine_bug", tout << "i! " << m().to_rational_string(aux) << "\n";);
|
||||
TRACE(sine_bug, tout << "i! " << m().to_rational_string(aux) << "\n";);
|
||||
set_rounding(upper_factor);
|
||||
m().div(f, aux, f);
|
||||
TRACE("sine_bug", tout << "a^i/i! " << m().to_rational_string(f) << "\n";);
|
||||
TRACE(sine_bug, tout << "a^i/i! " << m().to_rational_string(f) << "\n";);
|
||||
set_rounding(upper);
|
||||
if (sign)
|
||||
m().sub(o, f, o);
|
||||
else
|
||||
m().add(o, f, o);
|
||||
TRACE("sine_bug", tout << "o: " << m().to_rational_string(o) << "\n";);
|
||||
TRACE(sine_bug, tout << "o: " << m().to_rational_string(o) << "\n";);
|
||||
sign = !sign;
|
||||
upper_factor = !upper_factor;
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ void interval_manager<C>::sine_series(numeral const & a, unsigned k, bool upper,
|
|||
|
||||
template<typename C>
|
||||
void interval_manager<C>::sine(numeral const & a, unsigned k, numeral & lo, numeral & hi) {
|
||||
TRACE("sine", tout << "sine(a), a: " << m().to_rational_string(a) << "\na: " << m().to_string(a) << "\n";);
|
||||
TRACE(sine, tout << "sine(a), a: " << m().to_rational_string(a) << "\na: " << m().to_string(a) << "\n";);
|
||||
SASSERT(&lo != &hi);
|
||||
if (m().is_zero(a)) {
|
||||
m().reset(lo);
|
||||
|
@ -456,13 +456,13 @@ void interval_manager<C>::sine(numeral const & a, unsigned k, numeral & lo, nume
|
|||
if (m().is_neg(error))
|
||||
m().neg(error);
|
||||
m().power(error, k+1, error);
|
||||
TRACE("sine", tout << "a^(k+1): " << m().to_rational_string(error) << "\nk : " << k << "\n";);
|
||||
TRACE(sine, tout << "a^(k+1): " << m().to_rational_string(error) << "\nk : " << k << "\n";);
|
||||
round_to_minus_inf();
|
||||
fact(k+1, aux);
|
||||
TRACE("sine", tout << "(k+1)!: " << m().to_rational_string(aux) << "\n";);
|
||||
TRACE(sine, tout << "(k+1)!: " << m().to_rational_string(aux) << "\n";);
|
||||
round_to_plus_inf();
|
||||
m().div(error, aux, error);
|
||||
TRACE("sine", tout << "error: " << m().to_rational_string(error) << "\n";);
|
||||
TRACE(sine, tout << "error: " << m().to_rational_string(error) << "\n";);
|
||||
|
||||
// Taylor series up to k with rounding to -oo
|
||||
sine_series(a, k, false, lo);
|
||||
|
@ -480,10 +480,10 @@ void interval_manager<C>::sine(numeral const & a, unsigned k, numeral & lo, nume
|
|||
}
|
||||
else {
|
||||
// We must recompute the series with rounding to +oo
|
||||
TRACE("sine", tout << "lo before -error: " << m().to_rational_string(lo) << "\n";);
|
||||
TRACE(sine, tout << "lo before -error: " << m().to_rational_string(lo) << "\n";);
|
||||
round_to_minus_inf();
|
||||
m().sub(lo, error, lo);
|
||||
TRACE("sine", tout << "lo: " << m().to_rational_string(lo) << "\n";);
|
||||
TRACE(sine, tout << "lo: " << m().to_rational_string(lo) << "\n";);
|
||||
if (m().lt(lo, m_minus_one)) {
|
||||
m().set(lo, -1);
|
||||
m().set(hi, 1);
|
||||
|
@ -492,7 +492,7 @@ void interval_manager<C>::sine(numeral const & a, unsigned k, numeral & lo, nume
|
|||
sine_series(a, k, true, hi);
|
||||
round_to_plus_inf();
|
||||
m().add(hi, error, hi);
|
||||
TRACE("sine", tout << "hi: " << m().to_rational_string(hi) << "\n";);
|
||||
TRACE(sine, tout << "hi: " << m().to_rational_string(hi) << "\n";);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ void interval_manager<C>::cosine_series(numeral const & a, unsigned k, bool uppe
|
|||
|
||||
template<typename C>
|
||||
void interval_manager<C>::cosine(numeral const & a, unsigned k, numeral & lo, numeral & hi) {
|
||||
TRACE("cosine", tout << "cosine(a): "; m().display_decimal(tout, a, 32); tout << "\n";);
|
||||
TRACE(cosine, tout << "cosine(a): "; m().display_decimal(tout, a, 32); tout << "\n";);
|
||||
SASSERT(&lo != &hi);
|
||||
if (m().is_zero(a)) {
|
||||
m().set(lo, 1);
|
||||
|
@ -559,7 +559,7 @@ void interval_manager<C>::cosine(numeral const & a, unsigned k, numeral & lo, nu
|
|||
fact(k+1, aux);
|
||||
round_to_plus_inf();
|
||||
m().div(error, aux, error);
|
||||
TRACE("sine", tout << "error: "; m().display_decimal(tout, error, 32); tout << "\n";);
|
||||
TRACE(sine, tout << "error: "; m().display_decimal(tout, error, 32); tout << "\n";);
|
||||
|
||||
// Taylor series up to k with rounding to -oo
|
||||
cosine_series(a, k, false, lo);
|
||||
|
@ -1049,7 +1049,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
if (is_N(i2)) {
|
||||
// x <= b <= 0, y <= d <= 0 --> b*d <= x*y
|
||||
// a <= x <= b <= 0, c <= y <= d <= 0 --> x*y <= a*c (we can use the fact that x or y is always negative (i.e., b is neg or d is neg))
|
||||
TRACE("interval_bug", tout << "(N, N) #" << call_id << "\n"; display(tout, i1); tout << "\n"; display(tout, i2); tout << "\n";
|
||||
TRACE(interval_bug, tout << "(N, N) #" << call_id << "\n"; display(tout, i1); tout << "\n"; display(tout, i2); tout << "\n";
|
||||
tout << "a: "; m().display(tout, a); tout << "\n";
|
||||
tout << "b: "; m().display(tout, b); tout << "\n";
|
||||
tout << "c: "; m().display(tout, c); tout << "\n";
|
||||
|
@ -1069,7 +1069,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
else if (is_M(i2)) {
|
||||
// a <= x <= b <= 0, y <= d, d > 0 --> a*d <= x*y (uses the fact that b is not positive)
|
||||
// a <= x <= b <= 0, c <= y, c < 0 --> x*y <= a*c (uses the fact that b is not positive)
|
||||
TRACE("interval_bug", tout << "(N, M) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(N, M) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, a_o || d_o);
|
||||
set_upper_is_open(r, a_o || c_o);
|
||||
|
@ -1082,7 +1082,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
else {
|
||||
// a <= x <= b <= 0, 0 <= c <= y <= d --> a*d <= x*y (uses the fact that x is neg (b is not positive) or y is pos (c is not negative))
|
||||
// x <= b <= 0, 0 <= c <= y --> x*y <= b*c
|
||||
TRACE("interval_bug", tout << "(N, P) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(N, P) #" << call_id << "\n";);
|
||||
SASSERT(is_P(i2));
|
||||
|
||||
// must update upper_is_open first, since value of is_N0(i1) and is_P0(i2) may be affected by update
|
||||
|
@ -1099,7 +1099,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
if (is_N(i2)) {
|
||||
// b > 0, x <= b, c <= y <= d <= 0 --> b*c <= x*y (uses the fact that d is not positive)
|
||||
// a < 0, a <= x, c <= y <= d <= 0 --> x*y <= a*c (uses the fact that d is not positive)
|
||||
TRACE("interval_bug", tout << "(M, N) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(M, N) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, b_o || c_o);
|
||||
set_upper_is_open(r, a_o || c_o);
|
||||
|
@ -1153,7 +1153,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
else {
|
||||
// a < 0, a <= x, 0 <= c <= y <= d --> a*d <= x*y (uses the fact that c is not negative)
|
||||
// b > 0, x <= b, 0 <= c <= y <= d --> x*y <= b*d (uses the fact that c is not negative)
|
||||
TRACE("interval_bug", tout << "(M, P) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(M, P) #" << call_id << "\n";);
|
||||
SASSERT(is_P(i2));
|
||||
|
||||
set_lower_is_open(r, a_o || d_o);
|
||||
|
@ -1170,7 +1170,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
if (is_N(i2)) {
|
||||
// 0 <= a <= x <= b, c <= y <= d <= 0 --> x*y <= b*c (uses the fact that x is pos (a is not neg) or y is neg (d is not pos))
|
||||
// 0 <= a <= x, y <= d <= 0 --> a*d <= x*y
|
||||
TRACE("interval_bug", tout << "(P, N) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(P, N) #" << call_id << "\n";);
|
||||
|
||||
// must update upper_is_open first, since value of is_P0(i1) and is_N0(i2) may be affected by update
|
||||
set_upper_is_open(r, (is_P0(i1) || is_N0(i2)) ? false : a_o || d_o);
|
||||
|
@ -1184,7 +1184,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
else if (is_M(i2)) {
|
||||
// 0 <= a <= x <= b, c <= y --> b*c <= x*y (uses the fact that a is not negative)
|
||||
// 0 <= a <= x <= b, y <= d --> x*y <= b*d (uses the fact that a is not negative)
|
||||
TRACE("interval_bug", tout << "(P, M) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(P, M) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, b_o || c_o);
|
||||
set_upper_is_open(r, b_o || d_o);
|
||||
|
@ -1198,7 +1198,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
SASSERT(is_P(i2));
|
||||
// 0 <= a <= x, 0 <= c <= y --> a*c <= x*y
|
||||
// x <= b, y <= d --> x*y <= b*d (uses the fact that x is pos (a is not negative) or y is pos (c is not negative))
|
||||
TRACE("interval_bug", tout << "(P, P) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(P, P) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, (is_P0(i1) || is_P0(i2)) ? false : a_o || c_o);
|
||||
set_upper_is_open(r, b_o || d_o);
|
||||
|
@ -1215,7 +1215,7 @@ void interval_manager<C>::mul(interval const & i1, interval const & i2, interval
|
|||
set_lower_is_inf(r, new_l_kind == EN_MINUS_INFINITY);
|
||||
set_upper_is_inf(r, new_u_kind == EN_PLUS_INFINITY);
|
||||
SASSERT(!(i1_contains_zero || i2_contains_zero) || contains_zero(r));
|
||||
TRACE("interval_bug", tout << "result: "; display(tout, r); tout << "\n";);
|
||||
TRACE(interval_bug, tout << "result: "; display(tout, r); tout << "\n";);
|
||||
#ifdef _TRACE
|
||||
call_id++;
|
||||
#endif
|
||||
|
@ -1336,7 +1336,7 @@ void interval_manager<C>::power(interval const & a, unsigned n, interval & b) {
|
|||
else {
|
||||
// [l, u]^n = [0, max{l^n, u^n}] otherwise
|
||||
// we need both bounds to justify upper bound
|
||||
TRACE("interval_bug", tout << "(M) #" << call_id << "\n"; display(tout, a); tout << "\nn:" << n << "\n";);
|
||||
TRACE(interval_bug, tout << "(M) #" << call_id << "\n"; display(tout, a); tout << "\nn:" << n << "\n";);
|
||||
|
||||
ext_numeral_kind un1_kind = lower_kind(a), un2_kind = upper_kind(a);
|
||||
numeral & un1 = m_result_lower;
|
||||
|
@ -1383,7 +1383,7 @@ void interval_manager<C>::power(interval const & a, unsigned n, interval & b) {
|
|||
set_upper_is_open(b, upper_is_open(a));
|
||||
}
|
||||
}
|
||||
TRACE("interval_bug", tout << "result: "; display(tout, b); tout << "\n";);
|
||||
TRACE(interval_bug, tout << "result: "; display(tout, b); tout << "\n";);
|
||||
#ifdef _TRACE
|
||||
call_id++;
|
||||
#endif
|
||||
|
@ -1432,7 +1432,7 @@ void interval_manager<C>::nth_root(interval const & a, unsigned n, numeral const
|
|||
set_upper_is_open(b, upper_is_open(a) && m().eq(lo, hi));
|
||||
m().set(upper(b), hi);
|
||||
}
|
||||
TRACE("interval_nth_root", display(tout, a); tout << " --> "; display(tout, b); tout << "\n";);
|
||||
TRACE(interval_nth_root, display(tout, a); tout << " --> "; display(tout, b); tout << "\n";);
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
@ -1464,7 +1464,7 @@ void interval_manager<C>::xn_eq_y(interval const & y, unsigned n, numeral const
|
|||
nth_root(upper(y), n, p, lo, hi);
|
||||
// result is [-hi, hi]
|
||||
// result is open if upper(y) is open and lo == hi
|
||||
TRACE("interval_xn_eq_y", tout << "x^n = "; display(tout, y); tout << "\n";
|
||||
TRACE(interval_xn_eq_y, tout << "x^n = "; display(tout, y); tout << "\n";
|
||||
tout << "sqrt(y) in "; m().display(tout, lo); tout << " "; m().display(tout, hi); tout << "\n";);
|
||||
bool open = upper_is_open(y) && m().eq(lo, hi);
|
||||
set_lower_is_inf(x, false);
|
||||
|
@ -1475,7 +1475,7 @@ void interval_manager<C>::xn_eq_y(interval const & y, unsigned n, numeral const
|
|||
round_to_minus_inf();
|
||||
m().set(lower(x), hi);
|
||||
m().neg(lower(x));
|
||||
TRACE("interval_xn_eq_y", tout << "interval for x: "; display(tout, x); tout << "\n";);
|
||||
TRACE(interval_xn_eq_y, tout << "interval for x: "; display(tout, x); tout << "\n";);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1527,7 +1527,7 @@ void interval_manager<C>::inv(interval const & a, interval & b) {
|
|||
#endif
|
||||
// If the interval [l,u] does not contain 0, then 1/[l,u] = [1/u, 1/l]
|
||||
SASSERT(!contains_zero(a));
|
||||
TRACE("interval_bug", tout << "(inv) #" << call_id << "\n"; display(tout, a); tout << "\n";);
|
||||
TRACE(interval_bug, tout << "(inv) #" << call_id << "\n"; display(tout, a); tout << "\n";);
|
||||
|
||||
numeral & new_l_val = m_result_lower;
|
||||
numeral & new_u_val = m_result_upper;
|
||||
|
@ -1594,7 +1594,7 @@ void interval_manager<C>::inv(interval const & a, interval & b) {
|
|||
else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
TRACE("interval_bug", tout << "result: "; display(tout, b); tout << "\n";);
|
||||
TRACE(interval_bug, tout << "result: "; display(tout, b); tout << "\n";);
|
||||
#ifdef _TRACE
|
||||
call_id++;
|
||||
#endif
|
||||
|
@ -1676,7 +1676,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
SASSERT(&i1 != &r);
|
||||
|
||||
if (is_zero(i1)) {
|
||||
TRACE("interval_bug", tout << "div #" << call_id << "\n"; display(tout, i1); tout << "\n"; display(tout, i2); tout << "\n";);
|
||||
TRACE(interval_bug, tout << "div #" << call_id << "\n"; display(tout, i1); tout << "\n"; display(tout, i2); tout << "\n";);
|
||||
|
||||
// 0/other = 0 if other != 0
|
||||
m().reset(lower(r));
|
||||
|
@ -1701,7 +1701,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
numeral & new_u_val = m_result_upper;
|
||||
ext_numeral_kind new_l_kind, new_u_kind;
|
||||
|
||||
TRACE("interval_bug", tout << "div #" << call_id << "\n"; display(tout, i1); tout << "\n"; display(tout, i2); tout << "\n";
|
||||
TRACE(interval_bug, tout << "div #" << call_id << "\n"; display(tout, i1); tout << "\n"; display(tout, i2); tout << "\n";
|
||||
tout << "a: "; m().display(tout, a); tout << "\n";
|
||||
tout << "b: "; m().display(tout, b); tout << "\n";
|
||||
tout << "c: "; m().display(tout, c); tout << "\n";
|
||||
|
@ -1712,7 +1712,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
if (is_N1(i2)) {
|
||||
// x <= b <= 0, c <= y <= d < 0 --> b/c <= x/y
|
||||
// a <= x <= b <= 0, y <= d < 0 --> x/y <= a/d
|
||||
TRACE("interval_bug", tout << "(N, N) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(N, N) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, is_N0(i1) ? false : b_o || c_o);
|
||||
set_upper_is_open(r, a_o || d_o);
|
||||
|
@ -1732,7 +1732,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
else {
|
||||
// a <= x, a < 0, 0 < c <= y --> a/c <= x/y
|
||||
// x <= b <= 0, 0 < c <= y <= d --> x/y <= b/d
|
||||
TRACE("interval_bug", tout << "(N, P) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(N, P) #" << call_id << "\n";);
|
||||
SASSERT(is_P1(i2));
|
||||
|
||||
set_upper_is_open(r, is_N0(i1) ? false : (b_o || d_o));
|
||||
|
@ -1755,7 +1755,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
if (is_N1(i2)) {
|
||||
// 0 < a <= x <= b < 0, y <= d < 0 --> b/d <= x/y
|
||||
// 0 < a <= x <= b < 0, y <= d < 0 --> x/y <= a/d
|
||||
TRACE("interval_bug", tout << "(M, N) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(M, N) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, b_o || d_o);
|
||||
set_upper_is_open(r, a_o || d_o);
|
||||
|
@ -1771,14 +1771,14 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
::div(m(), b, b_k, d, d_k, new_l_val, new_l_kind);
|
||||
round_to_plus_inf();
|
||||
::div(m(), a, a_k, d, d_k, new_u_val, new_u_kind);
|
||||
TRACE("interval_bug", tout << "new_l_kind: " << new_l_kind << ", new_u_kind: " << new_u_kind << "\n";);
|
||||
TRACE(interval_bug, tout << "new_l_kind: " << new_l_kind << ", new_u_kind: " << new_u_kind << "\n";);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 0 < a <= x <= b < 0, 0 < c <= y --> a/c <= x/y
|
||||
// 0 < a <= x <= b < 0, 0 < c <= y --> x/y <= b/c
|
||||
|
||||
TRACE("interval_bug", tout << "(M, P) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(M, P) #" << call_id << "\n";);
|
||||
SASSERT(is_P1(i2));
|
||||
|
||||
set_lower_is_open(r, a_o || c_o);
|
||||
|
@ -1803,7 +1803,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
if (is_N1(i2)) {
|
||||
// b > 0, x <= b, c <= y <= d < 0 --> b/d <= x/y
|
||||
// 0 <= a <= x, c <= y <= d < 0 --> x/y <= a/c
|
||||
TRACE("interval_bug", tout << "(P, N) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(P, N) #" << call_id << "\n";);
|
||||
|
||||
set_upper_is_open(r, is_P0(i1) ? false : a_o || c_o);
|
||||
set_lower_is_open(r, b_o || d_o);
|
||||
|
@ -1824,7 +1824,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
SASSERT(is_P1(i2));
|
||||
// 0 <= a <= x, 0 < c <= y <= d --> a/d <= x/y
|
||||
// b > 0 x <= b, 0 < c <= y --> x/y <= b/c
|
||||
TRACE("interval_bug", tout << "(P, P) #" << call_id << "\n";);
|
||||
TRACE(interval_bug, tout << "(P, P) #" << call_id << "\n";);
|
||||
|
||||
set_lower_is_open(r, is_P0(i1) ? false : a_o || d_o);
|
||||
set_upper_is_open(r, b_o || c_o);
|
||||
|
@ -1848,7 +1848,7 @@ void interval_manager<C>::div(interval const & i1, interval const & i2, interval
|
|||
set_lower_is_inf(r, new_l_kind == EN_MINUS_INFINITY);
|
||||
set_upper_is_inf(r, new_u_kind == EN_PLUS_INFINITY);
|
||||
}
|
||||
TRACE("interval_bug", tout << "result: "; display(tout, r); tout << "\n";);
|
||||
TRACE(interval_bug, tout << "result: "; display(tout, r); tout << "\n";);
|
||||
#ifdef _TRACE
|
||||
call_id++;
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;);
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 ¬_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");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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););
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -287,7 +287,7 @@ namespace algebraic_numbers {
|
|||
return true;
|
||||
if (a.to_algebraic()->m_not_rational)
|
||||
return false; // we know for sure a is not a rational
|
||||
TRACE("algebraic_bug", tout << "is_rational(a):\n"; display_root(tout, a); tout << "\n"; display_interval(tout, a); tout << "\n";);
|
||||
TRACE(algebraic_bug, tout << "is_rational(a):\n"; display_root(tout, a); tout << "\n"; display_interval(tout, a); tout << "\n";);
|
||||
algebraic_cell * c = a.to_algebraic();
|
||||
save_intervals saved_a(*this, a);
|
||||
mpz & a_n = c->m_p[c->m_p_sz - 1];
|
||||
|
@ -299,7 +299,7 @@ namespace algebraic_numbers {
|
|||
unsigned k = qm().log2(abs_a_n);
|
||||
k++;
|
||||
|
||||
TRACE("algebraic_bug", tout << "abs(an): " << qm().to_string(abs_a_n) << ", k: " << k << "\n";);
|
||||
TRACE(algebraic_bug, tout << "abs(an): " << qm().to_string(abs_a_n) << ", k: " << k << "\n";);
|
||||
|
||||
// make sure the isolating interval size is less than 1/2^k
|
||||
if (!refine_until_prec(a, k)) {
|
||||
|
@ -307,7 +307,7 @@ namespace algebraic_numbers {
|
|||
return true;
|
||||
}
|
||||
|
||||
TRACE("algebraic_bug", tout << "interval after refinement: "; display_interval(tout, a); tout << "\n";);
|
||||
TRACE(algebraic_bug, tout << "interval after refinement: "; display_interval(tout, a); tout << "\n";);
|
||||
|
||||
// Find unique candidate rational in the isolating interval
|
||||
scoped_mpbq a_n_lower(bqm());
|
||||
|
@ -507,7 +507,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
SASSERT(acell_inv(*a.to_algebraic()));
|
||||
}
|
||||
TRACE("algebraic", tout << "a: "; display_root(tout, a); tout << "\n";);
|
||||
TRACE(algebraic, tout << "a: "; display_root(tout, a); tout << "\n";);
|
||||
}
|
||||
|
||||
void set(numeral & a, numeral const & b) {
|
||||
|
@ -552,7 +552,7 @@ namespace algebraic_numbers {
|
|||
scoped_upoly & up_sqf = m_isolate_tmp3;
|
||||
up_sqf.reset();
|
||||
upm().square_free(up.size(), up.data(), up_sqf);
|
||||
TRACE("algebraic", upm().display(tout, up_sqf.size(), up_sqf.data()); tout << "\n";);
|
||||
TRACE(algebraic, upm().display(tout, up_sqf.size(), up_sqf.data()); tout << "\n";);
|
||||
r.push_back(up_sqf, 1);
|
||||
return false;
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ namespace algebraic_numbers {
|
|||
(void)c_lt_a;
|
||||
// (a <= b & b <= c) => a <= c
|
||||
// b < a or c < b or !(c < a)
|
||||
CTRACE("algebraic_bug",
|
||||
CTRACE(algebraic_bug,
|
||||
(!b_lt_a && !c_lt_b && c_lt_a),
|
||||
display_root(tout << "a ", a) << "\n";
|
||||
display_root(tout << "b ", b) << "\n";
|
||||
|
@ -601,7 +601,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
void isolate_roots(scoped_upoly const & up, numeral_vector & roots) {
|
||||
TRACE("algebraic", upm().display(tout, up); tout << "\n";);
|
||||
TRACE(algebraic, upm().display(tout, up); tout << "\n";);
|
||||
if (up.empty())
|
||||
return; // ignore the zero polynomial
|
||||
factors & fs = m_isolate_factors;
|
||||
|
@ -622,12 +622,12 @@ namespace algebraic_numbers {
|
|||
upolynomial::numeral_vector const & f = fs[i];
|
||||
// polynomial f contains the non zero roots
|
||||
unsigned d = upm().degree(f);
|
||||
TRACE("algebraic", tout << "factor " << i << " degree: " << d << "\n";);
|
||||
TRACE(algebraic, tout << "factor " << i << " degree: " << d << "\n";);
|
||||
if (d == 0)
|
||||
continue; // found all roots of f
|
||||
scoped_mpq r(qm());
|
||||
if (d == 1) {
|
||||
TRACE("algebraic", tout << "linear polynomial...\n";);
|
||||
TRACE(algebraic, tout << "linear polynomial...\n";);
|
||||
// f is a linear polynomial ax + b
|
||||
// set r <- -b/a
|
||||
qm().set(r, f[0]);
|
||||
|
@ -640,7 +640,7 @@ namespace algebraic_numbers {
|
|||
upm().sqf_isolate_roots(f.size(), f.data(), bqm(), m_isolate_roots, m_isolate_lowers, m_isolate_uppers);
|
||||
// collect rational/basic roots
|
||||
unsigned sz = m_isolate_roots.size();
|
||||
TRACE("algebraic", tout << "isolated roots: " << sz << "\n";);
|
||||
TRACE(algebraic, tout << "isolated roots: " << sz << "\n";);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
to_mpq(qm(), m_isolate_roots[i], r);
|
||||
roots.push_back(numeral(mk_basic_cell(r)));
|
||||
|
@ -670,7 +670,7 @@ namespace algebraic_numbers {
|
|||
|
||||
void isolate_roots(polynomial_ref const & p, numeral_vector & roots) {
|
||||
SASSERT(is_univariate(p));
|
||||
TRACE("algebraic", tout << "isolating roots of: " << p << "\n";);
|
||||
TRACE(algebraic, tout << "isolating roots of: " << p << "\n";);
|
||||
if (::is_zero(p))
|
||||
return; // ignore the zero polynomial
|
||||
scoped_upoly & up = m_isolate_tmp1;
|
||||
|
@ -688,7 +688,7 @@ namespace algebraic_numbers {
|
|||
scoped_numeral_vector roots(m_wrapper);
|
||||
isolate_roots(up, roots);
|
||||
unsigned num_roots = roots.size();
|
||||
TRACE("algebraic", tout << "num-roots: " << num_roots << "\n";
|
||||
TRACE(algebraic, tout << "num-roots: " << num_roots << "\n";
|
||||
for (unsigned i = 0; i < num_roots; i++) {
|
||||
display_interval(tout, roots[i]);
|
||||
tout << "\n";
|
||||
|
@ -701,7 +701,7 @@ namespace algebraic_numbers {
|
|||
void mk_root(polynomial_ref const & p, unsigned i, numeral & r) {
|
||||
SASSERT(i != 0);
|
||||
SASSERT(is_univariate(p));
|
||||
TRACE("algebraic", tout << "isolating roots of: " << p << "\n";);
|
||||
TRACE(algebraic, tout << "isolating roots of: " << p << "\n";);
|
||||
scoped_upoly & up = m_isolate_tmp1;
|
||||
upm().to_numeral_vector(p, up);
|
||||
mk_root(up, i, r);
|
||||
|
@ -711,7 +711,7 @@ namespace algebraic_numbers {
|
|||
SASSERT(i != 0);
|
||||
scoped_upoly & up = m_isolate_tmp1;
|
||||
sexpr2upolynomial(upm(), p, up);
|
||||
TRACE("algebraic", tout << "mk_root " << i << "\n"; upm().display(tout, up); tout << "\n";);
|
||||
TRACE(algebraic, tout << "mk_root " << i << "\n"; upm().display(tout, up); tout << "\n";);
|
||||
mk_root(up, i, r);
|
||||
}
|
||||
|
||||
|
@ -985,13 +985,13 @@ namespace algebraic_numbers {
|
|||
\pre lV and uV are the sign variations (in seq) for r_i.lower() and r_i.upper()
|
||||
*/
|
||||
void set_core(numeral & c, scoped_upoly & p, mpbqi & r_i, upolynomial::scoped_upolynomial_sequence & seq, int lV, int uV, bool minimal) {
|
||||
TRACE("algebraic", tout << "set_core p: "; upm().display(tout, p); tout << "\n";);
|
||||
TRACE(algebraic, tout << "set_core p: "; upm().display(tout, p); tout << "\n";);
|
||||
if (bqim().contains_zero(r_i)) {
|
||||
if (upm().has_zero_roots(p.size(), p.data())) {
|
||||
// zero is a root of p, and r_i is an isolating interval containing zero,
|
||||
// then c is zero
|
||||
reset(c);
|
||||
TRACE("algebraic", tout << "resetting\nresult: "; display_root(tout, c); tout << "\n";);
|
||||
TRACE(algebraic, tout << "resetting\nresult: "; display_root(tout, c); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
int zV = upm().sign_variations_at_zero(seq);
|
||||
|
@ -1024,7 +1024,7 @@ namespace algebraic_numbers {
|
|||
set(c, r);
|
||||
}
|
||||
else {
|
||||
TRACE("algebraic", tout << "set_core...\n";);
|
||||
TRACE(algebraic, tout << "set_core...\n";);
|
||||
set(c, nz_p.size(), nz_p.data(), r_i.lower(), r_i.upper(), minimal);
|
||||
}
|
||||
}
|
||||
|
@ -1052,14 +1052,14 @@ namespace algebraic_numbers {
|
|||
scoped_upoly p(upm());
|
||||
scoped_upoly f(upm());
|
||||
mk_poly(cell_a, cell_b, p);
|
||||
TRACE("anum_mk_binary", tout << "a: "; display_root(tout, a); tout << "\nb: "; display_root(tout, b); tout << "\np: ";
|
||||
TRACE(anum_mk_binary, tout << "a: "; display_root(tout, a); tout << "\nb: "; display_root(tout, b); tout << "\np: ";
|
||||
upm().display(tout, p); tout << "\n";);
|
||||
factors fs(upm());
|
||||
bool full_fact = factor(p, fs);
|
||||
unsigned num_fs = fs.distinct_factors();
|
||||
scoped_ptr_vector<typename upolynomial::scoped_upolynomial_sequence> seqs;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
TRACE("anum_mk_binary", tout << "factor " << i << "\n"; upm().display(tout, fs[i]); tout << "\n";);
|
||||
TRACE(anum_mk_binary, tout << "factor " << i << "\n"; upm().display(tout, fs[i]); tout << "\n";);
|
||||
typename upolynomial::scoped_upolynomial_sequence * seq = alloc(typename upolynomial::scoped_upolynomial_sequence, upm());
|
||||
upm().sturm_seq(fs[i].size(), fs[i].data(), *seq);
|
||||
seqs.push_back(seq);
|
||||
|
@ -1082,11 +1082,11 @@ namespace algebraic_numbers {
|
|||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
if (seqs[i] == nullptr)
|
||||
continue; // sequence was discarded because it does not contain the root.
|
||||
TRACE("anum_mk_binary", tout << "sequence " << i << "\n"; upm().display(tout, *(seqs[i])); tout << "\n";);
|
||||
TRACE(anum_mk_binary, tout << "sequence " << i << "\n"; upm().display(tout, *(seqs[i])); tout << "\n";);
|
||||
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
|
||||
int uV = upm().sign_variations_at(*(seqs[i]), r_i.upper());
|
||||
int V = lV - uV;
|
||||
TRACE("algebraic", tout << "r_i: "; bqim().display(tout, r_i); tout << "\n";
|
||||
TRACE(algebraic, tout << "r_i: "; bqim().display(tout, r_i); tout << "\n";
|
||||
tout << "lV: " << lV << ", uV: " << uV << "\n";
|
||||
tout << "a.m_interval: "; bqim().display(tout, cell_a->m_interval); tout << "\n";
|
||||
tout << "b.m_interval: "; bqim().display(tout, cell_b->m_interval); tout << "\n";
|
||||
|
@ -1108,7 +1108,7 @@ namespace algebraic_numbers {
|
|||
|
||||
if (num_rem == 1 && target_i != UINT_MAX) {
|
||||
// found isolating interval
|
||||
TRACE("anum_mk_binary", tout << "target_i: " << target_i << "\n";);
|
||||
TRACE(anum_mk_binary, tout << "target_i: " << target_i << "\n";);
|
||||
saved_a.restore_if_too_small();
|
||||
saved_b.restore_if_too_small();
|
||||
upm().set(fs[target_i].size(), fs[target_i].data(), f);
|
||||
|
@ -1163,7 +1163,7 @@ namespace algebraic_numbers {
|
|||
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
|
||||
int uV = upm().sign_variations_at(*(seqs[i]), r_i.upper());
|
||||
int V = lV - uV;
|
||||
TRACE("algebraic", tout << "r_i: "; bqim().display(tout, r_i); tout << "\n";
|
||||
TRACE(algebraic, tout << "r_i: "; bqim().display(tout, r_i); tout << "\n";
|
||||
tout << "lV: " << lV << ", uV: " << uV << "\n";
|
||||
tout << "a.m_interval: "; bqim().display(tout, cell_a->m_interval); tout << "\n";
|
||||
);
|
||||
|
@ -1319,7 +1319,7 @@ namespace algebraic_numbers {
|
|||
|
||||
if (qm().root(a_val, k, r_a_val)) {
|
||||
// the result is rational
|
||||
TRACE("root_core", tout << "r_a_val: " << r_a_val << " a_val: "; qm().display(tout, a_val); tout << "\n";);
|
||||
TRACE(root_core, tout << "r_a_val: " << r_a_val << " a_val: "; qm().display(tout, a_val); tout << "\n";);
|
||||
set(b, r_a_val);
|
||||
return;
|
||||
}
|
||||
|
@ -1360,7 +1360,7 @@ namespace algebraic_numbers {
|
|||
bqm().add(upper, mpz(1), upper); // make sure (a_val)^{1/k} < upper
|
||||
}
|
||||
SASSERT(bqm().lt(lower, upper));
|
||||
TRACE("algebraic", tout << "root_core:\n"; upm().display(tout, p.size(), p.data()); tout << "\n";);
|
||||
TRACE(algebraic, tout << "root_core:\n"; upm().display(tout, p.size(), p.data()); tout << "\n";);
|
||||
// p is not necessarily a minimal polynomial.
|
||||
// So, we set the m_minimal flag to false. TODO: try to factor.
|
||||
set(b, p.size(), p.data(), lower, upper, false);
|
||||
|
@ -1434,7 +1434,7 @@ namespace algebraic_numbers {
|
|||
|
||||
template<bool IsAdd>
|
||||
void add(algebraic_cell * a, basic_cell * b, numeral & c) {
|
||||
TRACE("algebraic", tout << "adding algebraic and basic cells:\n";
|
||||
TRACE(algebraic, tout << "adding algebraic and basic cells:\n";
|
||||
tout << "a: "; upm().display(tout, a->m_p_sz, a->m_p); tout << " "; bqim().display(tout, a->m_interval); tout << "\n";
|
||||
tout << "b: "; qm().display(tout, b->m_value); tout << "\n";);
|
||||
scoped_mpq nbv(qm());
|
||||
|
@ -1457,18 +1457,18 @@ namespace algebraic_numbers {
|
|||
scoped_mpq iu(qm());
|
||||
to_mpq(qm(), i.lower(), il);
|
||||
to_mpq(qm(), i.upper(), iu);
|
||||
TRACE("algebraic",
|
||||
TRACE(algebraic,
|
||||
tout << "nbv: " << nbv << "\n";
|
||||
tout << "il: " << il << ", iu: " << iu << "\n";);
|
||||
qm().add(il, nbv, il);
|
||||
qm().add(iu, nbv, iu);
|
||||
// (il, iu) is an isolating refinable (rational) interval for the new polynomial.
|
||||
if (!upm().convert_q2bq_interval(m_add_tmp.size(), m_add_tmp.data(), il, iu, bqm(), l, u)) {
|
||||
TRACE("algebraic", tout << "conversion failed\n");
|
||||
TRACE(algebraic, tout << "conversion failed\n");
|
||||
}
|
||||
|
||||
}
|
||||
TRACE("algebraic",
|
||||
TRACE(algebraic,
|
||||
upm().display(tout, m_add_tmp.size(), m_add_tmp.data());
|
||||
tout << ", l: " << l << ", u: " << u << "\n";
|
||||
tout << "l_sign: " << upm().eval_sign_at(m_add_tmp.size(), m_add_tmp.data(), l) << "\n";
|
||||
|
@ -1541,7 +1541,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
void mul(algebraic_cell * a, basic_cell * b, numeral & c) {
|
||||
TRACE("algebraic", tout << "mult algebraic and basic cells:\n";
|
||||
TRACE(algebraic, tout << "mult algebraic and basic cells:\n";
|
||||
tout << "a: "; upm().display(tout, a->m_p_sz, a->m_p); tout << " "; bqim().display(tout, a->m_interval); tout << "\n";
|
||||
tout << "b: "; qm().display(tout, b->m_value); tout << "\n";);
|
||||
SASSERT(upm().eval_sign_at(a->m_p_sz, a->m_p, lower(a)) == -upm().eval_sign_at(a->m_p_sz, a->m_p, upper(a)));
|
||||
|
@ -1568,7 +1568,7 @@ namespace algebraic_numbers {
|
|||
scoped_mpq iu(qm());
|
||||
to_mpq(qm(), i.lower(), il);
|
||||
to_mpq(qm(), i.upper(), iu);
|
||||
TRACE("algebraic",
|
||||
TRACE(algebraic,
|
||||
tout << "nbv: " << nbv << "\n";
|
||||
tout << "il: " << il << ", iu: " << iu << "\n";);
|
||||
qm().mul(il, nbv, il);
|
||||
|
@ -1577,10 +1577,10 @@ namespace algebraic_numbers {
|
|||
qm().swap(il, iu);
|
||||
// (il, iu) is an isolating refinable (rational) interval for the new polynomial.
|
||||
if (!upm().convert_q2bq_interval(mulp.size(), mulp.data(), il, iu, bqm(), l, u)) {
|
||||
TRACE("algebraic", tout << "conversion failed\n");
|
||||
TRACE(algebraic, tout << "conversion failed\n");
|
||||
}
|
||||
}
|
||||
TRACE("algebraic",
|
||||
TRACE(algebraic,
|
||||
upm().display(tout, mulp.size(), mulp.data());
|
||||
tout << ", l: " << l << ", u: " << u << "\n";
|
||||
tout << "l_sign: " << upm().eval_sign_at(mulp.size(), mulp.data(), l) << "\n";
|
||||
|
@ -1679,7 +1679,7 @@ namespace algebraic_numbers {
|
|||
qm().inv(a.to_basic()->m_value);
|
||||
}
|
||||
else {
|
||||
TRACE("algebraic_bug", tout << "before inv: "; display_root(tout, a); tout << "\n"; display_interval(tout, a); tout << "\n";);
|
||||
TRACE(algebraic_bug, tout << "before inv: "; display_root(tout, a); tout << "\n"; display_interval(tout, a); tout << "\n";);
|
||||
algebraic_cell * cell_a = a.to_algebraic();
|
||||
upm().p_1_div_x(cell_a->m_p_sz, cell_a->m_p);
|
||||
// convert binary rational bounds into rational bounds
|
||||
|
@ -1690,13 +1690,13 @@ namespace algebraic_numbers {
|
|||
qm().inv(inv_lower);
|
||||
qm().inv(inv_upper);
|
||||
qm().swap(inv_lower, inv_upper);
|
||||
TRACE("algebraic_bug", tout << "inv new_bounds: " << qm().to_string(inv_lower) << ", " << qm().to_string(inv_upper) << "\n";);
|
||||
TRACE(algebraic_bug, tout << "inv new_bounds: " << qm().to_string(inv_lower) << ", " << qm().to_string(inv_upper) << "\n";);
|
||||
// convert isolating interval back as a binary rational bound
|
||||
if (!upm().convert_q2bq_interval(cell_a->m_p_sz, cell_a->m_p, inv_lower, inv_upper, bqm(), lower(cell_a), upper(cell_a))) {
|
||||
TRACE("algebraic_bug", tout << "root isolation failed\n");
|
||||
TRACE(algebraic_bug, tout << "root isolation failed\n");
|
||||
throw algebraic_exception("inversion of algebraic number failed");
|
||||
}
|
||||
TRACE("algebraic_bug", tout << "after inv: "; display_root(tout, a); tout << "\n"; display_interval(tout, a); tout << "\n";);
|
||||
TRACE(algebraic_bug, tout << "after inv: "; display_root(tout, a); tout << "\n"; display_interval(tout, a); tout << "\n";);
|
||||
update_sign_lower(cell_a);
|
||||
SASSERT(acell_inv(*cell_a));
|
||||
}
|
||||
|
@ -1792,7 +1792,7 @@ namespace algebraic_numbers {
|
|||
return sign_zero;
|
||||
}
|
||||
|
||||
TRACE("algebraic", tout << "comparing\n";
|
||||
TRACE(algebraic, tout << "comparing\n";
|
||||
tout << "a: "; upm().display(tout, cell_a->m_p_sz, cell_a->m_p); tout << "\n"; bqim().display(tout, cell_a->m_interval);
|
||||
tout << "\ncell_a->m_minimal: " << cell_a->m_minimal << "\n";
|
||||
tout << "b: "; upm().display(tout, cell_b->m_p_sz, cell_b->m_p); tout << "\n"; bqim().display(tout, cell_b->m_interval);
|
||||
|
@ -1893,7 +1893,7 @@ namespace algebraic_numbers {
|
|||
unsigned V1 = upm().sign_variations_at(seq, a_lower);
|
||||
unsigned V2 = upm().sign_variations_at(seq, a_upper);
|
||||
int V = V1 - V2;
|
||||
TRACE("algebraic", tout << "comparing using sturm\n";
|
||||
TRACE(algebraic, tout << "comparing using sturm\n";
|
||||
display_interval(tout, a) << "\n";
|
||||
display_interval(tout, b) << "\n";
|
||||
tout << "V: " << V << " V1 " << V1 << " V2 " << V2
|
||||
|
@ -1943,7 +1943,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
::sign compare(numeral & a, numeral & b) {
|
||||
TRACE("algebraic", tout << "comparing: "; display_interval(tout, a); tout << " "; display_interval(tout, b); tout << "\n";);
|
||||
TRACE(algebraic, tout << "comparing: "; display_interval(tout, a); tout << " "; display_interval(tout, b); tout << "\n";);
|
||||
if (a.is_basic()) {
|
||||
if (b.is_basic())
|
||||
return compare(basic_value(a), basic_value(b));
|
||||
|
@ -2058,7 +2058,7 @@ namespace algebraic_numbers {
|
|||
mpq const & operator()(polynomial::var x) const override {
|
||||
anum const & v = m_x2v(x);
|
||||
SASSERT(v.is_basic());
|
||||
TRACE("var2basic", tout << "getting value of x" << x << " -> " << m().to_string(m_imp.basic_value(v)) << "\n";);
|
||||
TRACE(var2basic, tout << "getting value of x" << x << " -> " << m().to_string(m_imp.basic_value(v)) << "\n";);
|
||||
return m_imp.basic_value(v);
|
||||
}
|
||||
};
|
||||
|
@ -2082,7 +2082,7 @@ namespace algebraic_numbers {
|
|||
polynomial::var_vector m_eval_sign_vars;
|
||||
sign eval_sign_at(polynomial_ref const & p, polynomial::var2anum const & x2v) {
|
||||
polynomial::manager & ext_pm = p.m();
|
||||
TRACE("anum_eval_sign", tout << "evaluating sign of: " << p << "\n";);
|
||||
TRACE(anum_eval_sign, tout << "evaluating sign of: " << p << "\n";);
|
||||
while (true) {
|
||||
bool restart = false;
|
||||
// Optimistic: maybe x2v contains only rational values
|
||||
|
@ -2090,7 +2090,7 @@ namespace algebraic_numbers {
|
|||
opt_var2basic x2v_basic(*this, x2v);
|
||||
scoped_mpq r(qm());
|
||||
ext_pm.eval(p, x2v_basic, r);
|
||||
TRACE("anum_eval_sign", tout << "all variables are assigned to rationals, value of p: " << r << "\n";);
|
||||
TRACE(anum_eval_sign, tout << "all variables are assigned to rationals, value of p: " << r << "\n";);
|
||||
return ::to_sign(qm().sign(r));
|
||||
}
|
||||
catch (const opt_var2basic::failed &) {
|
||||
|
@ -2101,7 +2101,7 @@ namespace algebraic_numbers {
|
|||
polynomial_ref p_prime(ext_pm);
|
||||
var2basic x2v_basic(*this, x2v);
|
||||
p_prime = ext_pm.substitute(p, x2v_basic);
|
||||
TRACE("anum_eval_sign", tout << "p after eliminating rationals: " << p_prime << "\n";);
|
||||
TRACE(anum_eval_sign, tout << "p after eliminating rationals: " << p_prime << "\n";);
|
||||
|
||||
if (ext_pm.is_zero(p_prime)) {
|
||||
// polynomial vanished after substituting rational values.
|
||||
|
@ -2125,7 +2125,7 @@ namespace algebraic_numbers {
|
|||
while (true) {
|
||||
checkpoint();
|
||||
ext_pm.eval(p_prime, x2v_interval, ri);
|
||||
TRACE("anum_eval_sign", tout << "evaluating using intervals: " << ri << "\n";);
|
||||
TRACE(anum_eval_sign, tout << "evaluating using intervals: " << ri << "\n";);
|
||||
if (!bqim().contains_zero(ri)) {
|
||||
return bqim().is_pos(ri) ? sign_pos : sign_neg;
|
||||
}
|
||||
|
@ -2144,7 +2144,7 @@ namespace algebraic_numbers {
|
|||
restart = true;
|
||||
break;
|
||||
}
|
||||
TRACE("anum_eval_sign", tout << "refined algebraic interval\n";);
|
||||
TRACE(anum_eval_sign, tout << "refined algebraic interval\n";);
|
||||
SASSERT(!v.is_basic());
|
||||
refined = true;
|
||||
}
|
||||
|
@ -2158,7 +2158,7 @@ namespace algebraic_numbers {
|
|||
if (restart) {
|
||||
// Some non-basic value became basic.
|
||||
// So, restarting the whole process
|
||||
TRACE("anum_eval_sign", tout << "restarting some algebraic_cell became basic\n";);
|
||||
TRACE(anum_eval_sign, tout << "restarting some algebraic_cell became basic\n";);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2174,7 +2174,7 @@ namespace algebraic_numbers {
|
|||
// Evaluating sign using algebraic arithmetic
|
||||
scoped_anum ra(m_wrapper);
|
||||
ext_pm.eval(p_prime, x2v, ra);
|
||||
TRACE("anum_eval_sign", tout << "value of p as algebraic number " << ra << "\n";);
|
||||
TRACE(anum_eval_sign, tout << "value of p as algebraic number " << ra << "\n";);
|
||||
if (is_zero(ra))
|
||||
return 0;
|
||||
return is_pos(ra) ? 1 : -1;
|
||||
|
@ -2234,7 +2234,7 @@ namespace algebraic_numbers {
|
|||
scoped_upoly & _R = m_eval_sign_tmp;
|
||||
upm().to_numeral_vector(R, _R);
|
||||
unsigned k = upm().nonzero_root_lower_bound(_R.size(), _R.data());
|
||||
TRACE("anum_eval_sign", tout << "R: " << R << "\nk: " << k << "\nri: "<< ri << "\n";);
|
||||
TRACE(anum_eval_sign, tout << "R: " << R << "\nk: " << k << "\nri: "<< ri << "\n";);
|
||||
scoped_mpbq mL(bqm()), L(bqm());
|
||||
bqm().set(mL, -1);
|
||||
bqm().set(L, 1);
|
||||
|
@ -2261,7 +2261,7 @@ namespace algebraic_numbers {
|
|||
while (!restart) {
|
||||
checkpoint();
|
||||
ext_pm.eval(p_prime, x2v_interval, ri);
|
||||
TRACE("anum_eval_sign", tout << "evaluating using intervals: " << ri << "\n";
|
||||
TRACE(anum_eval_sign, tout << "evaluating using intervals: " << ri << "\n";
|
||||
tout << "zero lower bound is: " << L << "\n";);
|
||||
if (!bqim().contains_zero(ri)) {
|
||||
return bqim().is_pos(ri) ? sign_pos : sign_neg;
|
||||
|
@ -2279,7 +2279,7 @@ namespace algebraic_numbers {
|
|||
restart = true;
|
||||
break;
|
||||
}
|
||||
TRACE("anum_eval_sign", tout << "refined algebraic interval\n";);
|
||||
TRACE(anum_eval_sign, tout << "refined algebraic interval\n";);
|
||||
SASSERT(!v.is_basic());
|
||||
}
|
||||
}
|
||||
|
@ -2332,7 +2332,7 @@ namespace algebraic_numbers {
|
|||
|
||||
// Remove from roots any solution r such that p does not evaluate to 0 at x2v extended with x->r.
|
||||
void filter_roots(polynomial_ref const & p, polynomial::var2anum const & x2v, polynomial::var x, numeral_vector & roots) {
|
||||
TRACE("isolate_roots", tout << "before filtering roots, x: x" << x << "\n";
|
||||
TRACE(isolate_roots, tout << "before filtering roots, x: x" << x << "\n";
|
||||
for (unsigned i = 0; i < roots.size(); i++) {
|
||||
display_root(tout, roots[i]); tout << "\n";
|
||||
});
|
||||
|
@ -2342,9 +2342,9 @@ namespace algebraic_numbers {
|
|||
for (unsigned i = 0; i < sz; i++) {
|
||||
checkpoint();
|
||||
ext_var2num ext_x2v(m_wrapper, x2v, x, roots[i]);
|
||||
TRACE("isolate_roots", tout << "filter_roots i: " << i << ", ext_x2v: x" << x << " -> "; display_root(tout, roots[i]); tout << "\n";);
|
||||
TRACE(isolate_roots, tout << "filter_roots i: " << i << ", ext_x2v: x" << x << " -> "; display_root(tout, roots[i]); tout << "\n";);
|
||||
sign sign = eval_sign_at(p, ext_x2v);
|
||||
TRACE("isolate_roots", tout << "filter_roots i: " << i << ", result sign: " << sign << "\n";);
|
||||
TRACE(isolate_roots, tout << "filter_roots i: " << i << ", result sign: " << sign << "\n";);
|
||||
if (sign != 0)
|
||||
continue;
|
||||
if (i != j)
|
||||
|
@ -2355,7 +2355,7 @@ namespace algebraic_numbers {
|
|||
del(roots[i]);
|
||||
roots.shrink(j);
|
||||
|
||||
TRACE("isolate_roots", tout << "after filtering roots:\n";
|
||||
TRACE(isolate_roots, tout << "after filtering roots:\n";
|
||||
for (unsigned i = 0; i < roots.size(); i++) {
|
||||
display_root(tout, roots[i]); tout << "\n";
|
||||
});
|
||||
|
@ -2381,16 +2381,16 @@ namespace algebraic_numbers {
|
|||
|
||||
polynomial::var_vector m_isolate_roots_vars;
|
||||
void isolate_roots(polynomial_ref const & p, polynomial::var2anum const & x2v, numeral_vector & roots, bool nested_call = false) {
|
||||
TRACE("isolate_roots", tout << "isolating roots of: " << p << "\n";);
|
||||
TRACE(isolate_roots, tout << "isolating roots of: " << p << "\n";);
|
||||
SASSERT(roots.empty());
|
||||
polynomial::manager & ext_pm = p.m();
|
||||
if (ext_pm.is_zero(p) || ext_pm.is_const(p)) {
|
||||
TRACE("isolate_roots", tout << "p is zero or the constant polynomial\n";);
|
||||
TRACE(isolate_roots, tout << "p is zero or the constant polynomial\n";);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ext_pm.is_univariate(p)) {
|
||||
TRACE("isolate_roots", tout << "p is univariate, using univariate procedure\n";);
|
||||
TRACE(isolate_roots, tout << "p is univariate, using univariate procedure\n";);
|
||||
isolate_roots(p, roots);
|
||||
return;
|
||||
}
|
||||
|
@ -2399,10 +2399,10 @@ namespace algebraic_numbers {
|
|||
polynomial_ref p_prime(ext_pm);
|
||||
var2basic x2v_basic(*this, x2v);
|
||||
p_prime = ext_pm.substitute(p, x2v_basic);
|
||||
TRACE("isolate_roots", tout << "p after applying (rational fragment of) x2v:\n" << p_prime << "\n";);
|
||||
TRACE(isolate_roots, tout << "p after applying (rational fragment of) x2v:\n" << p_prime << "\n";);
|
||||
|
||||
if (ext_pm.is_zero(p_prime) || ext_pm.is_const(p_prime)) {
|
||||
TRACE("isolate_roots", tout << "p is zero or the constant polynomial after applying (rational fragment of) x2v\n";);
|
||||
TRACE(isolate_roots, tout << "p is zero or the constant polynomial after applying (rational fragment of) x2v\n";);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2413,7 +2413,7 @@ namespace algebraic_numbers {
|
|||
// So, the polynomial does not have any roots
|
||||
return;
|
||||
}
|
||||
TRACE("isolate_roots", tout << "p is univariate after applying (rational fragment of) x2v... using univariate procedure\n";);
|
||||
TRACE(isolate_roots, tout << "p is univariate after applying (rational fragment of) x2v... using univariate procedure\n";);
|
||||
isolate_roots(p_prime, roots);
|
||||
return;
|
||||
}
|
||||
|
@ -2425,7 +2425,7 @@ namespace algebraic_numbers {
|
|||
|
||||
// sort variables by the degree of the values
|
||||
std::stable_sort(xs.begin(), xs.end(), var_degree_lt(*this, x2v));
|
||||
TRACE("isolate_roots", tout << "there are " << (xs.size() - 1) << " variables assigned to nonbasic numbers...\n";);
|
||||
TRACE(isolate_roots, tout << "there are " << (xs.size() - 1) << " variables assigned to nonbasic numbers...\n";);
|
||||
|
||||
// last variables is the one not assigned by x2v, or the unassigned variable vanished
|
||||
polynomial::var x = xs.back();
|
||||
|
@ -2453,7 +2453,7 @@ namespace algebraic_numbers {
|
|||
algebraic_cell * c = v.to_algebraic();
|
||||
p_y = ext_pm.to_polynomial(c->m_p_sz, c->m_p, y);
|
||||
ext_pm.resultant(q, p_y, y, q);
|
||||
TRACE("isolate_roots", tout << "resultant loop i: " << i << ", y: x" << y << "\np_y: " << p_y << "\n";
|
||||
TRACE(isolate_roots, tout << "resultant loop i: " << i << ", y: x" << y << "\np_y: " << p_y << "\n";
|
||||
tout << "q: " << q << "\n";);
|
||||
if (ext_pm.is_zero(q)) {
|
||||
SASSERT(!nested_call);
|
||||
|
@ -2462,7 +2462,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
if (ext_pm.is_zero(q)) {
|
||||
TRACE("isolate_roots", tout << "q vanished\n";);
|
||||
TRACE(isolate_roots, tout << "q vanished\n";);
|
||||
// q may vanish at some of the other roots of the polynomial defining the values.
|
||||
// To decide if p_prime vanishes at x2v or not, we start evaluating each coefficient of p_prime at x2v
|
||||
// until we find one that is not zero at x2v.
|
||||
|
@ -2473,7 +2473,7 @@ namespace algebraic_numbers {
|
|||
SASSERT(n > 0);
|
||||
if (n == 1) {
|
||||
// p_prime is linear on p, so we just evaluate the coefficients...
|
||||
TRACE("isolate_roots", tout << "p is linear after applying (rational fragment) of x2v\n";);
|
||||
TRACE(isolate_roots, tout << "p is linear after applying (rational fragment) of x2v\n";);
|
||||
polynomial_ref c0(ext_pm);
|
||||
polynomial_ref c1(ext_pm);
|
||||
c0 = ext_pm.coeff(p_prime, x, 0);
|
||||
|
@ -2484,14 +2484,14 @@ namespace algebraic_numbers {
|
|||
ext_pm.eval(c1, x2v, a1);
|
||||
// the root must be - a0/a1 if a1 != 0
|
||||
if (is_zero(a1)) {
|
||||
TRACE("isolate_roots", tout << "coefficient of degree 1 vanished, so p does not have roots at x2v\n";);
|
||||
TRACE(isolate_roots, tout << "coefficient of degree 1 vanished, so p does not have roots at x2v\n";);
|
||||
// p_prime does not have any root
|
||||
return;
|
||||
}
|
||||
roots.push_back(anum());
|
||||
div(a0, a1, roots[0]);
|
||||
neg(roots[0]);
|
||||
TRACE("isolate_roots", tout << "after trivial solving p has only one root:\n"; display_root(tout, roots[0]); tout << "\n";);
|
||||
TRACE(isolate_roots, tout << "after trivial solving p has only one root:\n"; display_root(tout, roots[0]); tout << "\n";);
|
||||
}
|
||||
else {
|
||||
polynomial_ref c(ext_pm);
|
||||
|
@ -2506,7 +2506,7 @@ namespace algebraic_numbers {
|
|||
if (i == 0) {
|
||||
// all coefficients of x vanished, so
|
||||
// the polynomial has no roots
|
||||
TRACE("isolate_roots", tout << "all coefficients vanished... polynomial does not have roots\n";);
|
||||
TRACE(isolate_roots, tout << "all coefficients vanished... polynomial does not have roots\n";);
|
||||
return;
|
||||
}
|
||||
SASSERT(!is_zero(a));
|
||||
|
@ -2527,7 +2527,7 @@ namespace algebraic_numbers {
|
|||
xi_p = pm().mk_polynomial(x, i);
|
||||
z_p = pm().mk_polynomial(z);
|
||||
q2 = z_p*xi_p + q2;
|
||||
TRACE("isolate_roots", tout << "invoking isolate_roots with q2:\n" << q2 << "\n";
|
||||
TRACE(isolate_roots, tout << "invoking isolate_roots with q2:\n" << q2 << "\n";
|
||||
tout << "z: x" << z << " -> "; display_root(tout, a); tout << "\n";);
|
||||
// extend x2p with z->a
|
||||
ext_var2num ext_x2v(m_wrapper, x2v, z, a);
|
||||
|
@ -2536,7 +2536,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
else if (ext_pm.is_const(q)) {
|
||||
// q does not have any roots, so p_prime also does not have roots at x2v.
|
||||
TRACE("isolate_roots", tout << "q is the constant polynomial, so p does not contain any roots at x2v\n";);
|
||||
TRACE(isolate_roots, tout << "q is the constant polynomial, so p does not contain any roots at x2v\n";);
|
||||
}
|
||||
else {
|
||||
SASSERT(is_univariate(q));
|
||||
|
@ -2619,7 +2619,7 @@ namespace algebraic_numbers {
|
|||
// Select a numeral between prev and curr.
|
||||
// Pre: prev < curr
|
||||
void select(numeral & prev, numeral & curr, numeral & result) {
|
||||
TRACE("algebraic_select",
|
||||
TRACE(algebraic_select,
|
||||
tout << "prev: "; display_interval(tout, prev); tout << "\n";
|
||||
tout << "curr: "; display_interval(tout, curr); tout << "\n";);
|
||||
SASSERT(lt(prev, curr));
|
||||
|
@ -2674,7 +2674,7 @@ namespace algebraic_numbers {
|
|||
signs.push_back(s);
|
||||
}
|
||||
else {
|
||||
TRACE("isolate_roots_bug", tout << "p: " << p << "\n";
|
||||
TRACE(isolate_roots_bug, tout << "p: " << p << "\n";
|
||||
polynomial::var_vector xs;
|
||||
p.m().vars(p, xs);
|
||||
for (unsigned i = 0; i < xs.size(); i++) {
|
||||
|
@ -2694,7 +2694,7 @@ namespace algebraic_numbers {
|
|||
|
||||
scoped_anum w(m_wrapper);
|
||||
int_lt(roots[0], w);
|
||||
TRACE("isolate_roots_bug", tout << "w: "; display_root(tout, w); tout << "\n";);
|
||||
TRACE(isolate_roots_bug, tout << "w: "; display_root(tout, w); tout << "\n";);
|
||||
{
|
||||
ext2_var2num ext_x2v(m_wrapper, x2v, w);
|
||||
auto s = eval_sign_at(p, ext_x2v);
|
||||
|
@ -2996,15 +2996,15 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
void manager::power(numeral const & a, unsigned k, numeral & b) {
|
||||
TRACE("anum_detail", display_root(tout, a); tout << "^" << k << "\n";);
|
||||
TRACE(anum_detail, display_root(tout, a); tout << "^" << k << "\n";);
|
||||
m_imp->power(const_cast<numeral&>(a), k, b);
|
||||
TRACE("anum_detail", tout << "^ result: "; display_root(tout, b); tout << "\n";);
|
||||
TRACE(anum_detail, tout << "^ result: "; display_root(tout, b); tout << "\n";);
|
||||
}
|
||||
|
||||
void manager::add(numeral const & a, numeral const & b, numeral & c) {
|
||||
TRACE("anum_detail", display_root(tout, a); tout << " + "; display_root(tout, b); tout << "\n";);
|
||||
TRACE(anum_detail, display_root(tout, a); tout << " + "; display_root(tout, b); tout << "\n";);
|
||||
m_imp->add(const_cast<numeral&>(a), const_cast<numeral&>(b), c);
|
||||
TRACE("anum_detail", tout << "+ result: "; display_root(tout, c); tout << "\n";);
|
||||
TRACE(anum_detail, tout << "+ result: "; display_root(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void manager::add(numeral const & a, mpz const & b, numeral & c) {
|
||||
|
@ -3014,15 +3014,15 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
void manager::sub(numeral const & a, numeral const & b, numeral & c) {
|
||||
TRACE("anum_detail", display_root(tout, a); tout << " - "; display_root(tout, b); tout << "\n";);
|
||||
TRACE(anum_detail, display_root(tout, a); tout << " - "; display_root(tout, b); tout << "\n";);
|
||||
m_imp->sub(const_cast<numeral&>(a), const_cast<numeral&>(b), c);
|
||||
TRACE("anum_detail", tout << "- result: "; display_root(tout, c); tout << "\n";);
|
||||
TRACE(anum_detail, tout << "- result: "; display_root(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void manager::mul(numeral const & a, numeral const & b, numeral & c) {
|
||||
TRACE("anum_detail", display_root(tout, a); tout << " * "; display_root(tout, b); tout << "\n";);
|
||||
TRACE(anum_detail, display_root(tout, a); tout << " * "; display_root(tout, b); tout << "\n";);
|
||||
m_imp->mul(const_cast<numeral&>(a), const_cast<numeral&>(b), c);
|
||||
TRACE("anum_detail", tout << "* result: "; display_root(tout, c); tout << "\n";);
|
||||
TRACE(anum_detail, tout << "* result: "; display_root(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void manager::div(numeral const & a, numeral const & b, numeral & c) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
// Return false if the matrix is singular
|
||||
bool solve(numeral * xs) {
|
||||
for (unsigned k = 0; k < n; k++) {
|
||||
TRACE("linear_eq_solver", tout << "iteration " << k << "\n"; display(tout););
|
||||
TRACE(linear_eq_solver, tout << "iteration " << k << "\n"; display(tout););
|
||||
// find pivot
|
||||
unsigned i = k;
|
||||
for (; i < n; i++) {
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
unsigned k = n;
|
||||
while (k > 0) {
|
||||
--k;
|
||||
TRACE("linear_eq_solver", tout << "iteration " << k << "\n"; display(tout););
|
||||
TRACE(linear_eq_solver, tout << "iteration " << k << "\n"; display(tout););
|
||||
SASSERT(m.is_one(A[k][k]));
|
||||
// save result
|
||||
m.set(xs[k], b[k]);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -386,7 +386,7 @@ namespace upolynomial {
|
|||
#ifdef Z3DEBUG
|
||||
scoped_numeral tmp(m());
|
||||
m().mul(g, p[i], tmp);
|
||||
CTRACE("div_bug", !m().eq(tmp, old_p_i), tout << "old(p[i]): " << m().to_string(old_p_i) << ", g: " << m().to_string(g) << ", p[i]: " <<
|
||||
CTRACE(div_bug, !m().eq(tmp, old_p_i), tout << "old(p[i]): " << m().to_string(old_p_i) << ", g: " << m().to_string(g) << ", p[i]: " <<
|
||||
m().to_string(p[i]) << ", tmp: " << m().to_string(tmp) << "\n";);
|
||||
SASSERT(tmp == old_p_i);
|
||||
#endif
|
||||
|
@ -403,7 +403,7 @@ namespace upolynomial {
|
|||
if (m().is_one(b))
|
||||
return;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
CTRACE("upolynomial", !m().divides(b, p[i]), tout << "b: " << m().to_string(b) << ", p[i]: " << m().to_string(p[i]) << "\n";);
|
||||
CTRACE(upolynomial, !m().divides(b, p[i]), tout << "b: " << m().to_string(b) << ", p[i]: " << m().to_string(p[i]) << "\n";);
|
||||
SASSERT(m().divides(b, p[i]));
|
||||
m().div(p[i], b, p[i]);
|
||||
}
|
||||
|
@ -527,10 +527,10 @@ namespace upolynomial {
|
|||
SASSERT(!m().is_zero(b_n));
|
||||
scoped_numeral a_m(m());
|
||||
while (m_limit.inc()) {
|
||||
TRACE("rem_bug", tout << "rem loop, p2:\n"; display(tout, sz2, p2); tout << "\nbuffer:\n"; display(tout, buffer); tout << "\n";);
|
||||
TRACE(rem_bug, tout << "rem loop, p2:\n"; display(tout, sz2, p2); tout << "\nbuffer:\n"; display(tout, buffer); tout << "\n";);
|
||||
sz1 = buffer.size();
|
||||
if (sz1 < sz2) {
|
||||
TRACE("rem_bug", tout << "finished\n";);
|
||||
TRACE(rem_bug, tout << "finished\n";);
|
||||
return;
|
||||
}
|
||||
unsigned m_n = sz1 - sz2;
|
||||
|
@ -546,7 +546,7 @@ namespace upolynomial {
|
|||
// p2: b_n * x^n + b_{n-1} * x^{n-1} + ... + b_0
|
||||
d++;
|
||||
m().set(a_m, buffer[sz1 - 1]);
|
||||
TRACE("rem_bug", tout << "a_m: " << m().to_string(a_m) << ", b_n: " << m().to_string(b_n) << "\n";);
|
||||
TRACE(rem_bug, tout << "a_m: " << m().to_string(a_m) << ", b_n: " << m().to_string(b_n) << "\n";);
|
||||
// don't need to update position sz1 - 1, since it will become 0
|
||||
for (unsigned i = 0; i < sz1 - 1; i++) {
|
||||
m().mul(buffer[i], b_n, buffer[i]);
|
||||
|
@ -619,11 +619,11 @@ namespace upolynomial {
|
|||
_r.reserve(deg+1);
|
||||
numeral_vector & _p1 = m_div_tmp1;
|
||||
// std::cerr << "dividing with "; display(std::cerr, _p1); std::cerr << std::endl;
|
||||
TRACE("factor_bug", tout << "sz1: " << sz1 << " p1: " << p1 << ", _p1.c_ptr(): " << _p1.data() << ", _p1.size(): " << _p1.size() << "\n";);
|
||||
TRACE(factor_bug, tout << "sz1: " << sz1 << " p1: " << p1 << ", _p1.c_ptr(): " << _p1.data() << ", _p1.size(): " << _p1.size() << "\n";);
|
||||
set(sz1, p1, _p1);
|
||||
SASSERT(_p1.size() == sz1);
|
||||
while (true) {
|
||||
TRACE("upolynomial", tout << "exact_div loop...\n"; display(tout, _p1); tout << "\n"; display(tout, _r); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "exact_div loop...\n"; display(tout, _p1); tout << "\n"; display(tout, _r); tout << "\n";);
|
||||
// std::cerr << "dividing with "; display(std::cerr, _p1); std::cerr << std::endl;
|
||||
if (sz1 == 0) {
|
||||
set_size(deg+1, _r);
|
||||
|
@ -672,12 +672,12 @@ namespace upolynomial {
|
|||
// inv2 is the inverse of b2 mod b1
|
||||
m().m().mod(inv1, b2, inv1);
|
||||
m().m().mod(inv2, b1, inv2);
|
||||
TRACE("CRA", tout << "inv1: " << inv1 << ", inv2: " << inv2 << "\n";);
|
||||
TRACE(CRA, tout << "inv1: " << inv1 << ", inv2: " << inv2 << "\n";);
|
||||
scoped_numeral a1(m());
|
||||
scoped_numeral a2(m());
|
||||
m().mul(b2, inv2, a1); // a1 is the multiplicator for coefficients of C1
|
||||
m().mul(b1, inv1, a2); // a2 is the multiplicator for coefficients of C2
|
||||
TRACE("CRA", tout << "a1: " << a1 << ", a2: " << a2 << "\n";);
|
||||
TRACE(CRA, tout << "a1: " << a1 << ", a2: " << a2 << "\n";);
|
||||
// new bound
|
||||
scoped_numeral new_bound(m());
|
||||
m().mul(b1, b2, new_bound);
|
||||
|
@ -687,7 +687,7 @@ namespace upolynomial {
|
|||
m().div(new_bound, 2, upper);
|
||||
m().set(lower, upper);
|
||||
m().neg(lower);
|
||||
TRACE("CRA", tout << "lower: " << lower << ", upper: " << upper << "\n";);
|
||||
TRACE(CRA, tout << "lower: " << lower << ", upper: " << upper << "\n";);
|
||||
|
||||
#define ADD(A1, A2) { \
|
||||
m().mul(A1, a1, tmp1); \
|
||||
|
@ -721,7 +721,7 @@ namespace upolynomial {
|
|||
void core_manager::mod_gcd(unsigned sz_u, numeral const * u,
|
||||
unsigned sz_v, numeral const * v,
|
||||
numeral_vector & result) {
|
||||
TRACE("mgcd", tout << "u: "; display_star(tout, sz_u, u); tout << "\nv: "; display_star(tout, sz_v, v); tout << "\n";);
|
||||
TRACE(mgcd, tout << "u: "; display_star(tout, sz_u, u); tout << "\nv: "; display_star(tout, sz_v, v); tout << "\n";);
|
||||
SASSERT(sz_u > 0 && sz_v > 0);
|
||||
SASSERT(!m().modular());
|
||||
scoped_numeral c_u(m()), c_v(m());
|
||||
|
@ -747,17 +747,17 @@ namespace upolynomial {
|
|||
|
||||
for (unsigned i = 0; i < NUM_BIG_PRIMES; i++) {
|
||||
m().set(p, polynomial::g_big_primes[i]);
|
||||
TRACE("mgcd", tout << "trying prime: " << p << "\n";);
|
||||
TRACE(mgcd, tout << "trying prime: " << p << "\n";);
|
||||
{
|
||||
scoped_set_zp setZp(*this, p);
|
||||
set(pp_u.size(), pp_u.data(), u_Zp);
|
||||
set(pp_v.size(), pp_v.data(), v_Zp);
|
||||
if (degree(u_Zp) < d_u) {
|
||||
TRACE("mgcd", tout << "bad prime, leading coefficient vanished\n";);
|
||||
TRACE(mgcd, tout << "bad prime, leading coefficient vanished\n";);
|
||||
continue; // bad prime
|
||||
}
|
||||
if (degree(v_Zp) < d_v) {
|
||||
TRACE("mgcd", tout << "bad prime, leading coefficient vanished\n";);
|
||||
TRACE(mgcd, tout << "bad prime, leading coefficient vanished\n";);
|
||||
continue; // bad prime
|
||||
}
|
||||
euclid_gcd(u_Zp.size(), u_Zp.data(), v_Zp.size(), v_Zp.data(), q);
|
||||
|
@ -767,9 +767,9 @@ namespace upolynomial {
|
|||
m().set(c, lc_g);
|
||||
mul(q, c);
|
||||
}
|
||||
TRACE("mgcd", tout << "new q:\n"; display_star(tout, q); tout << "\n";);
|
||||
TRACE(mgcd, tout << "new q:\n"; display_star(tout, q); tout << "\n";);
|
||||
if (is_const(q)) {
|
||||
TRACE("mgcd", tout << "done, modular gcd is one\n";);
|
||||
TRACE(mgcd, tout << "done, modular gcd is one\n";);
|
||||
reset(result);
|
||||
result.push_back(numeral());
|
||||
m().set(result.back(), c_g);
|
||||
|
@ -781,27 +781,27 @@ namespace upolynomial {
|
|||
}
|
||||
else if (q.size() < C.size() || m().m().is_even(p) || m().m().is_even(bound)) {
|
||||
// discard accumulated image, it was affected by unlucky primes
|
||||
TRACE("mgcd", tout << "discarding image\n";);
|
||||
TRACE(mgcd, tout << "discarding image\n";);
|
||||
set(q.size(), q.data(), C);
|
||||
m().set(bound, p);
|
||||
}
|
||||
else {
|
||||
CRA_combine_images(q, p, C, bound);
|
||||
TRACE("mgcd", tout << "new combined:\n"; display_star(tout, C); tout << "\n";);
|
||||
TRACE(mgcd, tout << "new combined:\n"; display_star(tout, C); tout << "\n";);
|
||||
}
|
||||
numeral_vector & candidate = q;
|
||||
get_primitive(C, candidate);
|
||||
TRACE("mgcd", tout << "candidate:\n"; display_star(tout, candidate); tout << "\n";);
|
||||
TRACE(mgcd, tout << "candidate:\n"; display_star(tout, candidate); tout << "\n";);
|
||||
SASSERT(candidate.size() > 0);
|
||||
numeral const & lc_candidate = candidate[candidate.size() - 1];
|
||||
if (m().divides(lc_candidate, lc_g) &&
|
||||
divides(pp_u, candidate) &&
|
||||
divides(pp_v, candidate)) {
|
||||
TRACE("mgcd", tout << "found GCD\n";);
|
||||
TRACE(mgcd, tout << "found GCD\n";);
|
||||
mul(candidate, c_g);
|
||||
flip_sign_if_lm_neg(candidate);
|
||||
candidate.swap(result);
|
||||
TRACE("mgcd", tout << "r: "; display_star(tout, result); tout << "\n";);
|
||||
TRACE(mgcd, tout << "r: "; display_star(tout, result); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -828,10 +828,10 @@ namespace upolynomial {
|
|||
numeral_vector & R = buffer;
|
||||
set(sz1, p1, A);
|
||||
set(sz2, p2, B);
|
||||
TRACE("upolynomial", tout << "sz1: " << sz1 << ", p1: " << p1 << ", sz2: " << sz2 << ", p2: " << p2 << "\nB.size(): " << B.size() <<
|
||||
TRACE(upolynomial, tout << "sz1: " << sz1 << ", p1: " << p1 << ", sz2: " << sz2 << ", p2: " << p2 << "\nB.size(): " << B.size() <<
|
||||
", B.c_ptr(): " << B.data() << "\n";);
|
||||
while (m_limit.inc()) {
|
||||
TRACE("upolynomial", tout << "A: "; display(tout, A); tout <<"\nB: "; display(tout, B); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "A: "; display(tout, A); tout <<"\nB: "; display(tout, B); tout << "\n";);
|
||||
if (B.empty()) {
|
||||
normalize(A);
|
||||
buffer.swap(A);
|
||||
|
@ -842,7 +842,7 @@ namespace upolynomial {
|
|||
else {
|
||||
flip_sign_if_lm_neg(buffer);
|
||||
}
|
||||
TRACE("upolynomial", tout << "GCD\n"; display(tout, sz1, p1); tout << "\n"; display(tout, sz2, p2); tout << "\n--->\n";
|
||||
TRACE(upolynomial, tout << "GCD\n"; display(tout, sz1, p1); tout << "\n"; display(tout, sz2, p2); tout << "\n--->\n";
|
||||
display(tout, buffer); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ namespace upolynomial {
|
|||
A.swap(B);
|
||||
while (true) {
|
||||
SASSERT(A.size() >= B.size());
|
||||
TRACE("upolynomial", tout << "A: "; display(tout, A); tout <<"\nB: "; display(tout, B); tout << "\n";
|
||||
TRACE(upolynomial, tout << "A: "; display(tout, A); tout <<"\nB: "; display(tout, B); tout << "\n";
|
||||
tout << "g: " << m().to_string(g) << ", h: " << m().to_string(h) << "\n";);
|
||||
if (B.empty()) {
|
||||
normalize(A);
|
||||
|
@ -911,7 +911,7 @@ namespace upolynomial {
|
|||
else {
|
||||
flip_sign_if_lm_neg(buffer);
|
||||
}
|
||||
TRACE("upolynomial", tout << "subresultant GCD\n"; display(tout, sz1, p1); tout << "\n"; display(tout, sz2, p2); tout << "\n--->\n";
|
||||
TRACE(upolynomial, tout << "subresultant GCD\n"; display(tout, sz1, p1); tout << "\n"; display(tout, sz2, p2); tout << "\n--->\n";
|
||||
display(tout, buffer); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ namespace upolynomial {
|
|||
mul(R, aux);
|
||||
}
|
||||
d = pseudo_div_d;
|
||||
TRACE("upolynomial", tout << "R: "; display(tout, R); tout << "\nd: " << d << "\n";);
|
||||
TRACE(upolynomial, tout << "R: "; display(tout, R); tout << "\nd: " << d << "\n";);
|
||||
// aux <- g*h^d
|
||||
m().power(h, d, aux);
|
||||
m().mul(g, aux, aux);
|
||||
|
@ -1407,14 +1407,14 @@ namespace upolynomial {
|
|||
// Basic idea: apply descartes_bound_0_1 to p2(x) where
|
||||
// p1(x) = p(x+a)
|
||||
// p2(x) = p1((b-a)*x)
|
||||
TRACE("upolynomial", tout << "pos interval... " << bqm.to_string(a) << ", " << bqm.to_string(b) << "\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "pos interval... " << bqm.to_string(a) << ", " << bqm.to_string(b) << "\n"; display(tout, sz, p); tout << "\n";);
|
||||
numeral_vector & p_aux = m_dbab_tmp1;
|
||||
translate_bq(sz, p, a, p_aux);
|
||||
TRACE("upolynomial", tout << "after translation\n"; display(tout, p_aux); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after translation\n"; display(tout, p_aux); tout << "\n";);
|
||||
scoped_mpbq b_a(bqm);
|
||||
bqm.sub(b, a, b_a);
|
||||
compose_p_b_x(p_aux.size(), p_aux.data(), b_a);
|
||||
TRACE("upolynomial", tout << "after composition: " << bqm.to_string(b_a) << "\n"; display(tout, p_aux); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after composition: " << bqm.to_string(b_a) << "\n"; display(tout, p_aux); tout << "\n";);
|
||||
unsigned result = descartes_bound_0_1(p_aux.size(), p_aux.data());
|
||||
return result;
|
||||
}
|
||||
|
@ -1538,7 +1538,7 @@ namespace upolynomial {
|
|||
return;
|
||||
// Step 1
|
||||
compose_2kn_p_x_div_2k(sz, p, b.k());
|
||||
TRACE("upolynomial", tout << "after compose 2kn_p_x_div_2k\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after compose 2kn_p_x_div_2k\n"; display(tout, sz, p); tout << "\n";);
|
||||
// Step 2
|
||||
numeral const & c = b.numerator();
|
||||
unsigned n = sz - 1;
|
||||
|
@ -1551,7 +1551,7 @@ namespace upolynomial {
|
|||
}
|
||||
m().mul2k(p[n], b.k());
|
||||
}
|
||||
TRACE("upolynomial", tout << "after special translation\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after special translation\n"; display(tout, sz, p); tout << "\n";);
|
||||
}
|
||||
|
||||
// Similar to translate_bq but for rationals
|
||||
|
@ -1560,7 +1560,7 @@ namespace upolynomial {
|
|||
return;
|
||||
// Step 1
|
||||
compose_an_p_x_div_a(sz, p, b.denominator());
|
||||
TRACE("upolynomial", tout << "after compose_an_p_x_div_a\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after compose_an_p_x_div_a\n"; display(tout, sz, p); tout << "\n";);
|
||||
// Step 2
|
||||
numeral const & c = b.numerator();
|
||||
unsigned n = sz - 1;
|
||||
|
@ -1573,7 +1573,7 @@ namespace upolynomial {
|
|||
}
|
||||
m().mul(p[n], b.denominator(), p[n]);
|
||||
}
|
||||
TRACE("upolynomial", tout << "after special translation\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after special translation\n"; display(tout, sz, p); tout << "\n";);
|
||||
}
|
||||
|
||||
// p(x) := 2^n*p(x/2) where n = sz-1
|
||||
|
@ -2146,7 +2146,7 @@ namespace upolynomial {
|
|||
unsigned idx = frame_stack.size() - 1;
|
||||
while (idx != UINT_MAX) {
|
||||
drs_frame const & fr = frame_stack[idx];
|
||||
TRACE("upolynomial",
|
||||
TRACE(upolynomial,
|
||||
tout << "normalizing...\n";
|
||||
tout << "idx: " << idx << ", left: " << fr.m_left << ", l: " << bqm.to_string(l) << ", u: " << bqm.to_string(u) << "\n";);
|
||||
if (fr.m_left) {
|
||||
|
@ -2161,7 +2161,7 @@ namespace upolynomial {
|
|||
}
|
||||
idx = fr.m_parent_idx;
|
||||
}
|
||||
TRACE("upolynomial", tout << "adding normalized interval (" << bqm.to_string(l) << ", " << bqm.to_string(u) << ")\n";);
|
||||
TRACE(upolynomial, tout << "adding normalized interval (" << bqm.to_string(l) << ", " << bqm.to_string(u) << ")\n";);
|
||||
lowers.push_back(mpbq());
|
||||
uppers.push_back(mpbq());
|
||||
swap(lowers.back(), l);
|
||||
|
@ -2187,32 +2187,32 @@ namespace upolynomial {
|
|||
}
|
||||
idx = fr.m_parent_idx;
|
||||
}
|
||||
TRACE("upolynomial", tout << "adding normalized root: " << bqm.to_string(u) << "\n";);
|
||||
TRACE(upolynomial, tout << "adding normalized root: " << bqm.to_string(u) << "\n";);
|
||||
roots.push_back(mpbq());
|
||||
swap(roots.back(), u);
|
||||
}
|
||||
|
||||
// Isolate roots in the interval (0, 1)
|
||||
void manager::drs_isolate_0_1_roots(unsigned sz, numeral const * p, mpbq_manager & bqm, mpbq_vector & roots, mpbq_vector & lowers, mpbq_vector & uppers) {
|
||||
TRACE("upolynomial", tout << "isolating (0,1) roots of:\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "isolating (0,1) roots of:\n"; display(tout, sz, p); tout << "\n";);
|
||||
unsigned k = descartes_bound_0_1(sz, p);
|
||||
// easy cases...
|
||||
if (k == 0) {
|
||||
TRACE("upolynomial", tout << "polynomial does not have any roots\n";);
|
||||
TRACE(upolynomial, tout << "polynomial does not have any roots\n";);
|
||||
return;
|
||||
}
|
||||
if (k == 1) {
|
||||
TRACE("upolynomial", tout << "polynomial has one root in (0, 1)\n";);
|
||||
TRACE(upolynomial, tout << "polynomial has one root in (0, 1)\n";);
|
||||
lowers.push_back(mpbq(0));
|
||||
uppers.push_back(mpbq(1));
|
||||
return;
|
||||
}
|
||||
TRACE("upolynomial", tout << "polynomial has more than one root in (0, 1), starting search...\n";);
|
||||
TRACE(upolynomial, tout << "polynomial has more than one root in (0, 1), starting search...\n";);
|
||||
scoped_numeral_vector q(m());
|
||||
scoped_numeral_vector p_stack(m());
|
||||
svector<drs_frame> frame_stack;
|
||||
if (has_one_half_root(sz, p)) {
|
||||
TRACE("upolynomial", tout << "polynomial has a 1/2 root\n";);
|
||||
TRACE(upolynomial, tout << "polynomial has a 1/2 root\n";);
|
||||
roots.push_back(mpbq(1, 1));
|
||||
remove_one_half_root(sz, p, q);
|
||||
push_child_frames(q.size(), q.data(), p_stack, frame_stack);
|
||||
|
@ -2227,7 +2227,7 @@ namespace upolynomial {
|
|||
unsigned sz = fr.m_size;
|
||||
SASSERT(sz <= p_stack.size());
|
||||
numeral const * p = p_stack.data() + p_stack.size() - sz;
|
||||
TRACE("upolynomial", tout << "processing frame #" << frame_stack.size() - 1 << "\n"
|
||||
TRACE(upolynomial, tout << "processing frame #" << frame_stack.size() - 1 << "\n"
|
||||
<< "first: " << fr.m_first << ", left: " << fr.m_left << ", sz: " << fr.m_size << ", parent_idx: ";
|
||||
if (fr.m_parent_idx == UINT_MAX) tout << "<null>"; else tout << fr.m_parent_idx;
|
||||
tout << "\np: "; display(tout, sz, p); tout << "\n";);
|
||||
|
@ -2238,19 +2238,19 @@ namespace upolynomial {
|
|||
fr.m_first = false;
|
||||
unsigned k = descartes_bound_0_1(sz, p);
|
||||
if (k == 0) {
|
||||
TRACE("upolynomial", tout << "(0, 1) does not have roots\n";);
|
||||
TRACE(upolynomial, tout << "(0, 1) does not have roots\n";);
|
||||
pop_top_frame(p_stack, frame_stack);
|
||||
continue;
|
||||
}
|
||||
if (k == 1) {
|
||||
TRACE("upolynomial", tout << "(0, 1) is isolating interval\n";);
|
||||
TRACE(upolynomial, tout << "(0, 1) is isolating interval\n";);
|
||||
add_isolating_interval(frame_stack, bqm, lowers, uppers);
|
||||
pop_top_frame(p_stack, frame_stack);
|
||||
continue;
|
||||
}
|
||||
TRACE("upolynomial", tout << "polynomial has more than one root in (0, 1) creating child frames...\n";);
|
||||
TRACE(upolynomial, tout << "polynomial has more than one root in (0, 1) creating child frames...\n";);
|
||||
if (has_one_half_root(sz, p)) {
|
||||
TRACE("upolynomial", tout << "1/2 is a root\n";);
|
||||
TRACE(upolynomial, tout << "1/2 is a root\n";);
|
||||
add_root(frame_stack, bqm, roots);
|
||||
remove_one_half_root(sz, p, q);
|
||||
push_child_frames(q.size(), q.data(), p_stack, frame_stack);
|
||||
|
@ -2295,7 +2295,7 @@ namespace upolynomial {
|
|||
|
||||
// p(x) := p(2^{pos_k} * x)
|
||||
// Since the desired positive roots of p(x) are in (0, 2^pos_k),
|
||||
TRACE("upolynomial", tout << "searching at (0, 1)\n";);
|
||||
TRACE(upolynomial, tout << "searching at (0, 1)\n";);
|
||||
unsigned old_roots_sz = roots.size();
|
||||
unsigned old_lowers_sz = lowers.size();
|
||||
drs_isolate_0_1_roots(sz, aux_p.data(), bqm, roots, lowers, uppers);
|
||||
|
@ -2308,7 +2308,7 @@ namespace upolynomial {
|
|||
// p(x) := p(-x)
|
||||
p_minus_x(sz, p);
|
||||
compose_p_2k_x(sz, p, neg_k);
|
||||
TRACE("upolynomial", tout << "searching at (-1, 0) using:\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "searching at (-1, 0) using:\n"; display(tout, sz, p); tout << "\n";);
|
||||
old_roots_sz = roots.size();
|
||||
old_lowers_sz = lowers.size();
|
||||
drs_isolate_0_1_roots(sz, p, bqm, roots, lowers, uppers);
|
||||
|
@ -2328,7 +2328,7 @@ namespace upolynomial {
|
|||
set(sz, p, p1);
|
||||
normalize(p1);
|
||||
|
||||
TRACE("upolynomial",
|
||||
TRACE(upolynomial,
|
||||
scoped_numeral U(m());
|
||||
root_upper_bound(p1.size(), p1.data(), U);
|
||||
unsigned U_k = m().log2(U) + 1;
|
||||
|
@ -2395,7 +2395,7 @@ namespace upolynomial {
|
|||
scoped_mpbq curr_upper(bqm);
|
||||
sturm_seq(sz, p, seq);
|
||||
ss_frame_stack s(bqm);
|
||||
TRACE("upolynomial", tout << "p: "; display(tout, sz, p); tout << "\nSturm seq:\n"; display(tout, seq); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "p: "; display(tout, sz, p); tout << "\nSturm seq:\n"; display(tout, seq); tout << "\n";);
|
||||
|
||||
unsigned lower_sv = sign_variations_at_minus_inf(seq);
|
||||
unsigned zero_sv = sign_variations_at_zero(seq);
|
||||
|
@ -2449,7 +2449,7 @@ namespace upolynomial {
|
|||
SASSERT(lower_sv > upper_sv + 1);
|
||||
bqm.add(curr_lower, curr_upper, mid);
|
||||
bqm.div2(mid);
|
||||
TRACE("upolynomial",
|
||||
TRACE(upolynomial,
|
||||
tout << "depth: " << s.size() << "\n";
|
||||
tout << "lower_sv: " << lower_sv << "\n";
|
||||
tout << "upper_sv: " << upper_sv << "\n";
|
||||
|
@ -2495,7 +2495,7 @@ namespace upolynomial {
|
|||
roots.push_back(mpbq(0));
|
||||
scoped_numeral_vector nz_p(m());
|
||||
remove_zero_roots(sz, p, nz_p);
|
||||
TRACE("upolynomial", tout << "after removing zero root:\n"; display(tout, nz_p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "after removing zero root:\n"; display(tout, nz_p); tout << "\n";);
|
||||
SASSERT(!has_zero_roots(nz_p.size(), nz_p.data()));
|
||||
sqf_nz_isolate_roots(nz_p.size(), nz_p.data(), bqm, roots, lowers, uppers);
|
||||
}
|
||||
|
@ -2506,10 +2506,10 @@ namespace upolynomial {
|
|||
|
||||
void manager::isolate_roots(unsigned sz, numeral const * p, mpbq_manager & bqm, mpbq_vector & roots, mpbq_vector & lowers, mpbq_vector & uppers) {
|
||||
SASSERT(sz > 0);
|
||||
TRACE("upolynomial", tout << "isolating roots of:\n"; display(tout, sz, p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "isolating roots of:\n"; display(tout, sz, p); tout << "\n";);
|
||||
scoped_numeral_vector sqf_p(m());
|
||||
square_free(sz, p, sqf_p);
|
||||
TRACE("upolynomial", tout << "square free part:\n"; display(tout, sqf_p); tout << "\n";);
|
||||
TRACE(upolynomial, tout << "square free part:\n"; display(tout, sqf_p); tout << "\n";);
|
||||
sqf_isolate_roots(sqf_p.size(), sqf_p.data(), bqm, roots, lowers, uppers);
|
||||
}
|
||||
|
||||
|
@ -2596,7 +2596,7 @@ namespace upolynomial {
|
|||
bool manager::isolating2refinable(unsigned sz, numeral const * p, mpbq_manager & bqm, mpbq & a, mpbq & b) {
|
||||
int sign_a = eval_sign_at(sz, p, a);
|
||||
int sign_b = eval_sign_at(sz, p, b);
|
||||
TRACE("upolynomial", tout << "sign_a: " << sign_a << ", sign_b: " << sign_b << "\n";);
|
||||
TRACE(upolynomial, tout << "sign_a: " << sign_a << ", sign_b: " << sign_b << "\n";);
|
||||
if (sign_a != 0 && sign_b != 0) {
|
||||
// CASE 1
|
||||
SASSERT(sign_a == -sign_b); // p is square free
|
||||
|
@ -2609,7 +2609,7 @@ namespace upolynomial {
|
|||
bqm.add(a, b, new_a);
|
||||
bqm.div2(new_a);
|
||||
while (true) {
|
||||
TRACE("upolynomial", tout << "CASE 2, a: " << bqm.to_string(a) << ", b: " << bqm.to_string(b) << ", new_a: " << bqm.to_string(new_a) << "\n";);
|
||||
TRACE(upolynomial, tout << "CASE 2, a: " << bqm.to_string(a) << ", b: " << bqm.to_string(b) << ", new_a: " << bqm.to_string(new_a) << "\n";);
|
||||
int sign_new_a = eval_sign_at(sz, p, new_a);
|
||||
if (sign_new_a != sign_b) {
|
||||
swap(new_a, a);
|
||||
|
@ -2634,7 +2634,7 @@ namespace upolynomial {
|
|||
bqm.add(a, b, new_b);
|
||||
bqm.div2(new_b);
|
||||
while (true) {
|
||||
TRACE("upolynomial", tout << "CASE 3, a: " << bqm.to_string(a) << ", b: " << bqm.to_string(b) << ", new_b: " << bqm.to_string(new_b) << "\n";);
|
||||
TRACE(upolynomial, tout << "CASE 3, a: " << bqm.to_string(a) << ", b: " << bqm.to_string(b) << ", new_b: " << bqm.to_string(new_b) << "\n";);
|
||||
int sign_new_b = eval_sign_at(sz, p, new_b);
|
||||
if (sign_new_b != sign_a) {
|
||||
SASSERT(sign_new_b == 0 || // found the actual root
|
||||
|
@ -2687,7 +2687,7 @@ namespace upolynomial {
|
|||
bqm.div2(new_b2);
|
||||
|
||||
while (true) {
|
||||
TRACE("upolynomial",
|
||||
TRACE(upolynomial,
|
||||
tout << "CASE 4\na1: " << bqm.to_string(a1) << ", b1: " << bqm.to_string(b1) << ", new_a1: " << bqm.to_string(new_a1) << "\n";
|
||||
tout << "a2: " << bqm.to_string(a2) << ", b2: " << bqm.to_string(b2) << ", new_b2: " << bqm.to_string(new_b2) << "\n";);
|
||||
int sign_new_a1 = eval_sign_at(sz, p, new_a1);
|
||||
|
@ -2814,14 +2814,14 @@ namespace upolynomial {
|
|||
SASSERT(!::is_zero(sign_a) && !::is_zero(sign_b));
|
||||
SASSERT(sign_a == -sign_b);
|
||||
bool found_d = false;
|
||||
TRACE("convert_bug",
|
||||
TRACE(convert_bug,
|
||||
tout << "a: " << m().to_string(a.numerator()) << "/" << m().to_string(a.denominator()) << "\n";
|
||||
tout << "b: " << m().to_string(b.numerator()) << "/" << m().to_string(b.denominator()) << "\n";
|
||||
tout << "sign_a: " << sign_a << "\n";
|
||||
tout << "sign_b: " << sign_b << "\n";);
|
||||
scoped_mpbq lower(bqm), upper(bqm);
|
||||
if (bqm.to_mpbq(a, lower)) {
|
||||
TRACE("convert_bug", tout << "found c: " << lower << "\n";);
|
||||
TRACE(convert_bug, tout << "found c: " << lower << "\n";);
|
||||
// found c
|
||||
swap(c, lower);
|
||||
SASSERT(bqm.eq(c, a));
|
||||
|
@ -2832,7 +2832,7 @@ namespace upolynomial {
|
|||
bqm.mul2(upper);
|
||||
if (m_manager.is_neg(a.numerator()))
|
||||
::swap(lower, upper);
|
||||
TRACE("convert_bug",
|
||||
TRACE(convert_bug,
|
||||
tout << "a: "; m().display(tout, a.numerator()); tout << "/"; m().display(tout, a.denominator()); tout << "\n";
|
||||
tout << "lower: "; bqm.display(tout, lower); tout << ", upper: "; bqm.display(tout, upper); tout << "\n";);
|
||||
SASSERT(bqm.lt(lower, a));
|
||||
|
@ -2958,12 +2958,12 @@ namespace upolynomial {
|
|||
|
||||
void manager::factor_2_sqf_pp(numeral_vector & p, factors & r, unsigned k) {
|
||||
SASSERT(p.size() == 3); // p has degree 2
|
||||
TRACE("factor", tout << "factor square free (degree == 2):\n"; display(tout, p); tout << "\n";);
|
||||
TRACE(factor, tout << "factor square free (degree == 2):\n"; display(tout, p); tout << "\n";);
|
||||
|
||||
numeral const & a = p[2];
|
||||
numeral const & b = p[1];
|
||||
numeral const & c = p[0];
|
||||
TRACE("factor", tout << "a: " << m().to_string(a) << "\nb: " << m().to_string(b) << "\nc: " << m().to_string(c) << "\n";);
|
||||
TRACE(factor, tout << "a: " << m().to_string(a) << "\nb: " << m().to_string(b) << "\nc: " << m().to_string(c) << "\n";);
|
||||
// Create the discriminant: b^2 - 4*a*c
|
||||
scoped_numeral b2(m());
|
||||
scoped_numeral ac(m());
|
||||
|
@ -2979,7 +2979,7 @@ namespace upolynomial {
|
|||
r.push_back(p, k);
|
||||
return;
|
||||
}
|
||||
TRACE("factor", tout << "disc_sqrt: " << m().to_string(disc_sqrt) << "\n";);
|
||||
TRACE(factor, tout << "disc_sqrt: " << m().to_string(disc_sqrt) << "\n";);
|
||||
// p = cont*(2*a*x + b - disc_sqrt)*(2*a*x + b + disc_sqrt)
|
||||
scoped_numeral_vector f1(m());
|
||||
scoped_numeral_vector f2(m());
|
||||
|
@ -2992,7 +2992,7 @@ namespace upolynomial {
|
|||
set_size(2, f2);
|
||||
normalize(f1);
|
||||
normalize(f2);
|
||||
TRACE("factor", tout << "f1: "; display(tout, f1); tout << "\nf2: "; display(tout, f2); tout << "\n";);
|
||||
TRACE(factor, tout << "f1: "; display(tout, f1); tout << "\nf2: "; display(tout, f2); tout << "\n";);
|
||||
DEBUG_CODE({
|
||||
scoped_numeral_vector f1f2(m());
|
||||
mul(f1, f2, f1f2);
|
||||
|
@ -3064,12 +3064,12 @@ namespace upolynomial {
|
|||
else {
|
||||
// B is of the form P_2 * P_3^2 * ... * P_k^{k-1}
|
||||
VERIFY(exact_div(C, B, A));
|
||||
TRACE("factor_bug", tout << "C: "; display(tout, C); tout << "\nB: "; display(tout, B); tout << "\nA: "; display(tout, A); tout << "\n";);
|
||||
TRACE(factor_bug, tout << "C: "; display(tout, C); tout << "\nB: "; display(tout, B); tout << "\nA: "; display(tout, A); tout << "\n";);
|
||||
// A is of the form P_1 * P_2 * ... * P_k
|
||||
unsigned j = 1;
|
||||
while (!is_const(A)) {
|
||||
checkpoint();
|
||||
TRACE("factor", tout << "factor_core main loop j: " << j << "\nA: "; display(tout, A); tout << "\nB: "; display(tout, B); tout << "\n";);
|
||||
TRACE(factor, tout << "factor_core main loop j: " << j << "\nA: "; display(tout, A); tout << "\nB: "; display(tout, B); tout << "\n";);
|
||||
// A is of the form P_j * P_{j+1} * P_{j+2} * ... * P_k
|
||||
// B is of the form P_{j+1} * P_{j+2}^2 * ... * P_k^{k - j - 2}
|
||||
gcd(A, B, D);
|
||||
|
@ -3082,20 +3082,20 @@ namespace upolynomial {
|
|||
result = false;
|
||||
}
|
||||
else {
|
||||
TRACE("factor", tout << "const C: "; display(tout, C); tout << "\n";);
|
||||
TRACE(factor, tout << "const C: "; display(tout, C); tout << "\n";);
|
||||
SASSERT(C.size() == 1);
|
||||
SASSERT(m().is_one(C[0]) || m().is_minus_one(C[0]));
|
||||
if (m().is_minus_one(C[0]) && j % 2 == 1)
|
||||
flip_sign(r);
|
||||
}
|
||||
TRACE("factor_bug", tout << "B: "; display(tout, B); tout << "\nD: "; display(tout, D); tout << "\n";);
|
||||
TRACE(factor_bug, tout << "B: "; display(tout, B); tout << "\nD: "; display(tout, D); tout << "\n";);
|
||||
VERIFY(exact_div(B, D, B));
|
||||
// B is of the form P_{j+2} * ... * P_k^{k - j - 3}
|
||||
A.swap(D);
|
||||
// D is of the form P_{j+1} * P_{j+2} * ... * P_k
|
||||
j++;
|
||||
}
|
||||
TRACE("factor_bug", tout << "A: "; display(tout, A); tout << "\n";);
|
||||
TRACE(factor_bug, tout << "A: "; display(tout, A); tout << "\n";);
|
||||
SASSERT(A.size() == 1 && m().is_one(A[0]));
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
m_row_pivot(m_size, -1) {
|
||||
unsigned p = get_p_from_manager(m_zpm);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt", tout << "polynomial::berlekamp_matrix("; m_upm.display(tout, f); tout << ", " << p << ")" << endl;);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "polynomial::berlekamp_matrix("; m_upm.display(tout, f); tout << ", " << p << ")" << endl;);
|
||||
|
||||
// the first row is always the vector [1, 0, ..., 0], since x^0 = 0 (modulo f)
|
||||
m_matrix.push_back(1);
|
||||
|
@ -139,7 +139,7 @@ public:
|
|||
m_zpm.dec(get(i, i));
|
||||
}
|
||||
|
||||
TRACE("polynomial::factorization::bughunt", tout << "polynomial::berlekamp_matrix():" << endl; display(tout); tout << endl;);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "polynomial::berlekamp_matrix():" << endl; display(tout); tout << endl;);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,7 +195,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
TRACE("polynomial::factorization::bughunt", tout << "polynomial::diagonalize():" << endl; display(tout); tout << endl;);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "polynomial::diagonalize():" << endl; display(tout); tout << endl;);
|
||||
|
||||
return null_rank;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
zp_numeral_manager & nm = upm.m();
|
||||
unsigned p = get_p_from_manager(upm.m());
|
||||
|
||||
TRACE("polynomial::factorization", tout << "polynomial::square_free_factor("; upm.display(tout, f); tout << ") over Z_" << p << endl;);
|
||||
TRACE(polynomial_factorization, tout << "polynomial::square_free_factor("; upm.display(tout, f); tout << ") over Z_" << p << endl;);
|
||||
|
||||
scoped_numeral_vector div_tmp(nm);
|
||||
|
||||
|
@ -265,7 +265,7 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
scoped_numeral constant(nm);
|
||||
upm.mk_monic(T_0.size(), T_0.data(), constant);
|
||||
sq_free_factors.set_constant(constant);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "Initial factors: " << sq_free_factors << endl;
|
||||
tout << "R.<x> = GF(" << p << ")['x']" << endl;
|
||||
tout << "T_0 = "; upm.display(tout, T_0); tout << endl;
|
||||
|
@ -282,25 +282,25 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
{
|
||||
// [initialize e-loop] T = gcd(T_0, T_0'), V / T_0/T, k = 0
|
||||
unsigned k = 0;
|
||||
TRACE("polynomial::factorization::bughunt", tout << "k = 0" << endl;);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "k = 0" << endl;);
|
||||
|
||||
// T_0_d = T_0'
|
||||
upm.derivative(T_0.size(), T_0.data(), T_0_d);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T_0_d = T_0.derivative(x)" << endl;
|
||||
tout << "T_0_d == "; upm.display(tout, T_0_d); tout << endl;
|
||||
);
|
||||
|
||||
// T = gcd(T_0, T_0')
|
||||
upm.gcd(T_0.size(), T_0.data(), T_0_d.size(), T_0_d.data(), T);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T = T_0.gcd(T_0_d)" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
|
||||
// V = T_0 / T
|
||||
upm.div(T_0.size(), T_0.data(), T.size(), T.data(), V);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "V = T_0.quo_rem(T)[0]" << endl;
|
||||
tout << "V == "; upm.display(tout, V); tout << endl;
|
||||
);
|
||||
|
@ -311,7 +311,7 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
++ k;
|
||||
// T = T/V
|
||||
upm.div(T.size(), T.data(), V.size(), V.data(), T);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T = T.quo_rem(V)[0]" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
|
@ -321,35 +321,35 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
|
||||
// W = gcd(T, V)
|
||||
upm.gcd(T.size(), T.data(), V.size(), V.data(), W);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "W = T.gcd(V)" << endl;
|
||||
upm.display(tout, W); tout << endl;
|
||||
);
|
||||
|
||||
// A_ek = V/W
|
||||
upm.div(V.size(), V.data(), W.size(), W.data(), A_ek);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "A_ek = V.quo_rem(W)[0]" << endl;
|
||||
tout << "A_ek == "; upm.display(tout, A_ek); tout << endl;
|
||||
);
|
||||
|
||||
// V = W
|
||||
V.swap(W);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "V = W" << endl;
|
||||
tout << "V == "; upm.display(tout, V); tout << endl;
|
||||
);
|
||||
|
||||
// T = T/V
|
||||
upm.div(T.size(), T.data(), V.size(), V.data(), T);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T = T.quo_rem(V)[0]" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
|
||||
// if not constant, we output it
|
||||
if (A_ek.size() > 1) {
|
||||
TRACE("polynomial::factorization::bughunt", tout << "Factor: ("; upm.display(tout, A_ek); tout << ")^" << e*k << endl;);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "Factor: ("; upm.display(tout, A_ek); tout << ")^" << e*k << endl;);
|
||||
sq_free_factors.push_back(A_ek, e*k);
|
||||
}
|
||||
}
|
||||
|
@ -361,18 +361,18 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
T_0.push_back(numeral());
|
||||
nm.set(T_0.back(), T[deg_p]);
|
||||
}
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T_0 = "; upm.display(tout, T_0); tout << endl;
|
||||
);
|
||||
}
|
||||
|
||||
TRACE("polynomial::factorization", tout << "polynomial::square_free_factor("; upm.display(tout, f); tout << ") => " << sq_free_factors << endl;);
|
||||
TRACE(polynomial_factorization, tout << "polynomial::square_free_factor("; upm.display(tout, f); tout << ") => " << sq_free_factors << endl;);
|
||||
}
|
||||
|
||||
bool zp_factor(zp_manager & upm, numeral_vector const & f, zp_factors & factors) {
|
||||
|
||||
|
||||
TRACE("polynomial::factorization",
|
||||
TRACE(polynomial_factorization,
|
||||
unsigned p = get_p_from_manager(upm.m());
|
||||
tout << "polynomial::factor("; upm.display(tout, f); tout << ") over Z_" << p << endl;);
|
||||
|
||||
|
@ -396,7 +396,7 @@ bool zp_factor(zp_manager & upm, numeral_vector const & f, zp_factors & factors)
|
|||
// add the constant
|
||||
factors.set_constant(sq_free_factors.get_constant());
|
||||
|
||||
TRACE("polynomial::factorization", tout << "polynomial::factor("; upm.display(tout, f); tout << ") => " << factors << endl;);
|
||||
TRACE(polynomial_factorization, tout << "polynomial::factor("; upm.display(tout, f); tout << ") => " << factors << endl;);
|
||||
|
||||
return factors.total_factors() > 1;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
mpzzp_manager & zpm = upm.m();
|
||||
unsigned p = get_p_from_manager(zpm);
|
||||
|
||||
TRACE("polynomial::factorization", tout << "upolynomial::factor_square_free_berlekamp("; upm.display(tout, f); tout << ", " << p << ")" << endl;);
|
||||
TRACE(polynomial_factorization, tout << "upolynomial::factor_square_free_berlekamp("; upm.display(tout, f); tout << ", " << p << ")" << endl;);
|
||||
SASSERT(zpm.is_one(f.back()));
|
||||
|
||||
// construct the berlekamp Q matrix to get the null space
|
||||
|
@ -425,11 +425,11 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
unsigned r = Q_I.diagonalize();
|
||||
if (r == 1) {
|
||||
// since r == 1 == number of factors, then f is irreducible
|
||||
TRACE("polynomial::factorization", tout << "upolynomial::factor_square_free_berlekamp("; upm.display(tout, f); tout << ", " << p << ") => " << factors << endl;);
|
||||
TRACE(polynomial_factorization, tout << "upolynomial::factor_square_free_berlekamp("; upm.display(tout, f); tout << ", " << p << ") => " << factors << endl;);
|
||||
return false;
|
||||
}
|
||||
|
||||
TRACE("polynomial::factorization::bughunt", tout << "upolynomial::factor_square_free_berlekamp(): computing factors, expecting " << r << endl;);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "upolynomial::factor_square_free_berlekamp(): computing factors, expecting " << r << endl;);
|
||||
|
||||
scoped_numeral_vector gcd(zpm);
|
||||
scoped_numeral_vector div(zpm);
|
||||
|
@ -440,7 +440,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
scoped_numeral_vector v_k(zpm);
|
||||
while (Q_I.next_null_space_vector(v_k)) {
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "null vector: ";
|
||||
for(unsigned j = 0; j < d; ++ j) {
|
||||
tout << zpm.to_string(v_k[j]) << " ";
|
||||
|
@ -449,7 +449,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
);
|
||||
|
||||
upm.trim(v_k);
|
||||
// TRACE("polynomial::factorization", tout << "v_k = "; upm.display(tout, v_k); tout << endl;);
|
||||
// TRACE(polynomial_factorization, tout << "v_k = "; upm.display(tout, v_k); tout << endl;);
|
||||
|
||||
unsigned current_factor_end = factors.distinct_factors();
|
||||
for (unsigned current_factor_i = first_factor; current_factor_i < current_factor_end; ++ current_factor_i) {
|
||||
|
@ -479,7 +479,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
// get the divisor also (no need to normalize the div, both are monic)
|
||||
upm.div(current_factor.size(), current_factor.data(), gcd.size(), gcd.data(), div);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "current_factor = "; upm.display(tout, current_factor); tout << endl;
|
||||
tout << "gcd_norm = "; upm.display(tout, gcd); tout << endl;
|
||||
tout << "div = "; upm.display(tout, div); tout << endl;
|
||||
|
@ -495,7 +495,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
|
||||
// at the point where we have all the factors, we are done
|
||||
if (factors.distinct_factors() - first_factor == r) {
|
||||
TRACE("polynomial::factorization", tout << "polynomial::factor("; upm.display(tout, f); tout << ", " << p << ") => " << factors << " of degree " << factors.get_degree() << endl;);
|
||||
TRACE(polynomial_factorization, tout << "polynomial::factor("; upm.display(tout, f); tout << ", " << p << ") => " << factors << " of degree " << factors.get_degree() << endl;);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C,
|
|||
upm.sub(C.size(), C.data(), test1.size(), test1.data(), test1);
|
||||
to_zp_manager(br_upm, test1);
|
||||
if (!test1.empty()) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "sage: R.<x> = ZZ['x']" << endl;
|
||||
tout << "sage: A = "; upm.display(tout, A); tout << endl;
|
||||
tout << "sage: B = "; upm.display(tout, B); tout << endl;
|
||||
|
@ -586,7 +586,7 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
|
||||
z_numeral_manager & nm = upm.zm();
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "polynomial::hensel_lift(";
|
||||
tout << "a = " << nm.to_string(a) << ", ";
|
||||
tout << "b = " << nm.to_string(b) << ", ";
|
||||
|
@ -611,7 +611,7 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
upm.sub(C.size(), C.data(), f.size(), f.data(), f);
|
||||
upm.div(f, b);
|
||||
to_zp_manager(r_upm, f);
|
||||
TRACE("polynomial::factorization",
|
||||
TRACE(polynomial_factorization,
|
||||
tout << "f = "; upm.display(tout, f); tout << endl;
|
||||
);
|
||||
|
||||
|
@ -634,33 +634,33 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
|
||||
// compute the S, T (compute in Z_r[x])
|
||||
scoped_numeral_vector Vf(r_upm.m()), t(r_upm.m()), S(r_upm.m());
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "V == "; upm.display(tout, V); tout << endl;
|
||||
);
|
||||
r_upm.mul(V.size(), V.data(), f.size(), f.data(), Vf);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "Vf = V*f" << endl;
|
||||
tout << "Vf == "; upm.display(tout, Vf); tout << endl;
|
||||
);
|
||||
r_upm.div_rem(Vf.size(), Vf.data(), A.size(), A.data(), t, S);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "[t, S] = Vf.quo_rem(A)" << endl;
|
||||
tout << "t == "; upm.display(tout, t); tout << endl;
|
||||
tout << "S == "; upm.display(tout, S); tout << endl;
|
||||
);
|
||||
scoped_numeral_vector T(r_upm.m()), tmp(r_upm.m());
|
||||
r_upm.mul(U.size(), U.data(), f.size(), f.data(), T); // T = fU
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T == U*f" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
r_upm.mul(B.size(), B.data(), t.size(), t.data(), tmp); // tmp = Bt
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "tmp = B*t" << endl;
|
||||
tout << "tmp == "; upm.display(tout, tmp); tout << endl;
|
||||
);
|
||||
r_upm.add(T.size(), T.data(), tmp.size(), tmp.data(), T); // T = Uf + Bt
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "T = B*tmp" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
|
@ -685,7 +685,7 @@ bool check_quadratic_hensel(zp_manager & zpe_upm, numeral_vector const & U, nume
|
|||
scoped_mpz_vector one(nm);
|
||||
zpe_upm.add(tmp1.size(), tmp1.data(), tmp2.size(), tmp2.data(), one);
|
||||
if (one.size() != 1 || !nm.is_one(one[0])) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "sage: R.<x> = Zmod(" << nm.to_string(zpe_upm.m().p()) << ")['x']" << endl;
|
||||
tout << "sage: A = "; zpe_upm.display(tout, A); tout << endl;
|
||||
tout << "sage: B = "; zpe_upm.display(tout, B); tout << endl;
|
||||
|
@ -710,7 +710,7 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
|
|||
zp_manager & zpe_upm, numeral_vector & A, numeral_vector & B, unsigned e) {
|
||||
z_numeral_manager & nm = upm.zm();
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "polynomial::hansel_lift_quadratic(";
|
||||
tout << "A = "; upm.display(tout, A); tout << ", ";
|
||||
tout << "B = "; upm.display(tout, B); tout << ", ";
|
||||
|
@ -741,7 +741,7 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
|
|||
|
||||
hensel_lift(upm, pe, pe, pe, U, A, V, B, C, A_lifted, B_lifted);
|
||||
// now we have C = AB (mod b*r)
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "A_lifted = "; upm.display(tout, A_lifted); tout << endl;
|
||||
tout << "B_lifted = "; upm.display(tout, B_lifted); tout << endl;
|
||||
tout << "C = "; upm.display(tout, C); tout << endl;
|
||||
|
@ -768,7 +768,7 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
|
|||
upm.sub(g.size(), g.data(), tmp1.size(), tmp1.data(), g); // g = 1 - UA - VB
|
||||
upm.div(g, pe);
|
||||
to_zp_manager(zpe_upm, g);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "g = (1 - A_lifted*U - B_lifted*V)/" << nm.to_string(pe) << endl;
|
||||
tout << "g == "; upm.display(tout, g); tout << endl;
|
||||
);
|
||||
|
@ -823,7 +823,7 @@ bool check_hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors con
|
|||
to_zp_manager(zp_upm, f, f_zp);
|
||||
zp_upm.mul(mult_zp, f_zp.back());
|
||||
if (!upm.eq(mult_zp, f_zp)) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "f = "; upm.display(tout, f); tout << endl;
|
||||
tout << "zp_fs = " << zp_fs << endl;
|
||||
tout << "sage: R.<x> = Zmod(" << nm.to_string(p) << ")['x']" << endl;
|
||||
|
@ -845,7 +845,7 @@ bool check_hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors con
|
|||
to_zp_manager(zpe_upm, f, f_zpe);
|
||||
zpe_upm.mul(mult_zpe, f_zpe.back());
|
||||
if (!upm.eq(mult_zpe, f_zpe)) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "f = "; upm.display(tout, f); tout << endl;
|
||||
tout << "zpe_fs = " << zpe_fs << endl;
|
||||
tout << "sage: R.<x> = Zmod(" << nm.to_string(pe) << ")['x']" << endl;
|
||||
|
@ -883,7 +883,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
zp_manager & zpe_upm = zpe_fs.upm();
|
||||
zpe_nm.set_zp(zp_nm.p());
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "polynomial::hansel_lift("; upm.display(tout, f); tout << ", " << zp_fs << ")" << endl;
|
||||
);
|
||||
|
||||
|
@ -903,7 +903,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
|
||||
// F_i = A (mod Z_p)
|
||||
zp_upm.set(zp_fs[i].size(), zp_fs[i].data(), A);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "A = "; upm.display(tout, A); tout << endl;
|
||||
);
|
||||
|
||||
|
@ -918,13 +918,13 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
zp_nm.set(lc, f.back());
|
||||
zp_upm.mul(C, lc);
|
||||
}
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "C = "; upm.display(tout, C); tout << endl;
|
||||
);
|
||||
|
||||
// we take B to be what's left from C and A
|
||||
zp_upm.div(C.size(), C.data(), A.size(), A.data(), B);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "B = "; upm.display(tout, B); tout << endl;
|
||||
);
|
||||
|
||||
|
@ -932,7 +932,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
zpe_nm.set_zp(zp_nm.p());
|
||||
hensel_lift_quadratic(upm, f_parts, zpe_upm, A, B, e);
|
||||
CASSERT("polynomial::factorizatio::bughunt", check_individual_lift(zp_upm, zp_fs[i], zpe_upm, A));
|
||||
TRACE("polynomial::factorization",
|
||||
TRACE(polynomial_factorization,
|
||||
tout << "lifted to " << nm.to_string(zpe_upm.m().p()) << endl;
|
||||
tout << "A = "; upm.display(tout, A); tout << endl;
|
||||
tout << "B = "; upm.display(tout, B); tout << endl;
|
||||
|
@ -957,7 +957,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
zpe_upm.mul(B, lc_inv);
|
||||
zpe_fs.push_back_swap(B, 1);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "polynomial::hansel_lift("; upm.display(tout, f); tout << ", " << zp_fs << ") => " << zpe_fs << endl;
|
||||
);
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ static unsigned mignotte_bound(z_manager & upm, numeral_vector const & f, numera
|
|||
This method also assumes f is primitive.
|
||||
*/
|
||||
bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, unsigned k, factor_params const & params) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "sage: f = "; upm.display(tout, f); tout << endl;
|
||||
tout << "sage: if (not f.is_squarefree()): print 'Error, f is not square-free'" << endl;
|
||||
tout << "sage: print 'Factoring :', f" << endl;
|
||||
|
@ -1049,7 +1049,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
}
|
||||
}
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "sage: f_pp = "; upm.display(tout, f_pp); tout << endl;
|
||||
tout << "sage: if (not (f_pp * 1 == f): print 'Error, content computation wrong'" << endl;
|
||||
);
|
||||
|
@ -1072,7 +1072,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
prime_iterator prime_it;
|
||||
scoped_numeral gcd_tmp(nm);
|
||||
unsigned trials = 0;
|
||||
TRACE("polynomial::factorization::bughunt", tout << "trials: " << params.m_p_trials << "\n";);
|
||||
TRACE(polynomial_factorization__bughunt, tout << "trials: " << params.m_p_trials << "\n";);
|
||||
while (trials <= params.m_p_trials) {
|
||||
upm.checkpoint();
|
||||
// construct prime to check
|
||||
|
@ -1086,7 +1086,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
|
||||
// we need gcd(lc(f_pp), p) = 1
|
||||
nm.gcd(p, f_pp.back(), gcd_tmp);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "sage: if (not (gcd(" << nm.to_string(p) << ", " << nm.to_string(f_pp.back()) << ")) == " <<
|
||||
nm.to_string(gcd_tmp) << "): print 'Error, wrong gcd'" << endl;
|
||||
);
|
||||
|
@ -1098,7 +1098,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
scoped_numeral_vector f_pp_zp(nm);
|
||||
to_zp_manager(zp_upm, f_pp, f_pp_zp);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "sage: Rp.<x_p> = GF(" << nm.to_string(p) << ")['x_p']"; tout << endl;
|
||||
tout << "sage: f_pp_zp = "; zp_upm.display(tout, f_pp_zp, "x_p"); tout << endl;
|
||||
);
|
||||
|
@ -1139,7 +1139,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
zp_fs.swap(current_fs);
|
||||
nm.set(zp_fs_p, p);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "best zp factorization (Z_" << nm.to_string(zp_fs_p) << "): ";
|
||||
tout << zp_fs << endl;
|
||||
tout << "best degree set: "; degree_set.display(tout); tout << endl;
|
||||
|
@ -1153,7 +1153,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
// make sure to set the zp_manager back to modulo zp_fs_p
|
||||
zp_upm.set_zp(zp_fs_p);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "best zp factorization (Z_" << nm.to_string(zp_fs_p) << "): " << zp_fs << endl;
|
||||
tout << "best degree set: "; degree_set.display(tout); tout << endl;
|
||||
);
|
||||
|
@ -1161,7 +1161,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
// get a bound on B for the factors of f_pp with degree less or equal to deg(f)/2
|
||||
// and then choose e to be smallest such that p^e > 2*lc(f)*B, we use the mignotte
|
||||
unsigned e = mignotte_bound(upm, f_pp, zp_fs_p);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "out p = " << nm.to_string(zp_fs_p) << ", and we'll work p^e for e = " << e << endl;
|
||||
);
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
ufactorization_combination_iterator it(zpe_fs, degree_set);
|
||||
scoped_numeral_vector trial_factor(nm), trial_factor_quo(nm);
|
||||
scoped_numeral trial_factor_cont(nm);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "STARTING TRIAL DIVISION" << endl;
|
||||
tout << "zpe_fs" << zpe_fs << endl;
|
||||
tout << "degree_set = "; degree_set.display(tout); tout << endl;
|
||||
|
@ -1237,14 +1237,14 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
|
||||
// add the lc(f_pp) to the trial divisor
|
||||
zpe_upm.mul(trial_factor, f_pp_lc);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "f_pp*lc(f_pp) = "; upm.display(tout, f_pp); tout << endl;
|
||||
tout << "trial_factor = "; upm.display(tout, trial_factor); tout << endl;
|
||||
);
|
||||
|
||||
bool true_factor = upm.exact_div(f_pp, trial_factor, trial_factor_quo);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "trial_factor = "; upm.display(tout, trial_factor); tout << endl;
|
||||
tout << "trial_factor_quo = "; upm.display(tout, trial_factor_quo); tout << endl;
|
||||
tout << "result = " << (true_factor ? "true" : "false") << endl;
|
||||
|
@ -1272,7 +1272,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
// don't remove this combination
|
||||
remove = false;
|
||||
}
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
TRACE(polynomial_factorization__bughunt,
|
||||
tout << "factors = " << fs << endl;
|
||||
tout << "f_pp*lc(f_pp) = "; upm.display(tout, f_pp); tout << endl;
|
||||
tout << "lc(f_pp) = " << f_pp_lc << endl;
|
||||
|
|
|
@ -218,7 +218,7 @@ bool mpz_matrix_manager::solve_core(mpz_matrix const & _A, mpz * b, bool int_sol
|
|||
scoped_mpz_matrix A(*this);
|
||||
set(A, _A);
|
||||
for (unsigned k = 0; k < A.m(); k++) {
|
||||
TRACE("mpz_matrix",
|
||||
TRACE(mpz_matrix,
|
||||
tout << "k: " << k << "\n" << A;
|
||||
tout << "b:";
|
||||
for (unsigned i = 0; i < A.m(); i++) {
|
||||
|
@ -359,7 +359,7 @@ unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsi
|
|||
for (unsigned i = 0; i < A.m(); i++)
|
||||
rows[i] = i;
|
||||
for (unsigned k1 = 0, k2 = 0; k1 < A.m(); k1++) {
|
||||
TRACE("mpz_matrix", tout << "k1: " << k1 << ", k2: " << k2 << "\n" << A;);
|
||||
TRACE(mpz_matrix, tout << "k1: " << k1 << ", k2: " << k2 << "\n" << A;);
|
||||
// find pivot
|
||||
unsigned pivot = UINT_MAX;
|
||||
for (unsigned i = k1; i < A.m(); i++) {
|
||||
|
|
|
@ -1300,7 +1300,7 @@ namespace realclosure {
|
|||
t->m_k++;
|
||||
t->m_proc(t->m_k, qim(), i);
|
||||
int m = magnitude(i);
|
||||
TRACE("rcf_transcendental",
|
||||
TRACE(rcf_transcendental,
|
||||
tout << "refine_transcendental_interval rational: " << m << "\nrational interval: ";
|
||||
qim().display(tout, i); tout << std::endl;);
|
||||
unsigned k;
|
||||
|
@ -1318,7 +1318,7 @@ namespace realclosure {
|
|||
|
||||
void refine_transcendental_interval(transcendental * t, unsigned prec) {
|
||||
while (!check_precision(t->interval(), prec)) {
|
||||
TRACE("rcf_transcendental", tout << "refine_transcendental_interval: " << magnitude(t->interval()) << std::endl;);
|
||||
TRACE(rcf_transcendental, tout << "refine_transcendental_interval: " << magnitude(t->interval()) << std::endl;);
|
||||
checkpoint();
|
||||
save_interval_if_too_small(t, prec);
|
||||
refine_transcendental_interval(t);
|
||||
|
@ -1675,7 +1675,7 @@ namespace realclosure {
|
|||
// Output values
|
||||
int & q_eq_0, int & q_gt_0, int & q_lt_0,
|
||||
value_ref_buffer & q2) {
|
||||
TRACE("rcf_count_signs",
|
||||
TRACE(rcf_count_signs,
|
||||
tout << "p: "; display_poly(tout, p_sz, p); tout << "\n";
|
||||
tout << "q: "; display_poly(tout, q_sz, q); tout << "\n";);
|
||||
SASSERT(num_roots > 0);
|
||||
|
@ -1989,7 +1989,7 @@ namespace realclosure {
|
|||
SASSERT(M_s.m() == M_s.n());
|
||||
SASSERT(M_s.m() == taqrs.size());
|
||||
SASSERT(M_s.m() == scs.size());
|
||||
TRACE("rcf_sign_det",
|
||||
TRACE(rcf_sign_det,
|
||||
tout << M_s;
|
||||
for (unsigned j = 0; j < scs.size(); j++) {
|
||||
display_sign_conditions(tout, scs[j]);
|
||||
|
@ -2007,7 +2007,7 @@ namespace realclosure {
|
|||
int q_eq_0, q_gt_0, q_lt_0;
|
||||
value_ref_buffer q2(*this);
|
||||
count_signs_at_zeros(p_sz, p, q_sz, q, iso_interval, num_roots, q_eq_0, q_gt_0, q_lt_0, q2);
|
||||
TRACE("rcf_sign_det",
|
||||
TRACE(rcf_sign_det,
|
||||
tout << "q: "; display_poly(tout, q_sz, q); tout << "\n";
|
||||
tout << "#(q == 0): " << q_eq_0 << ", #(q > 0): " << q_gt_0 << ", #(q < 0): " << q_lt_0 << "\n";);
|
||||
scoped_mpz_matrix M(mm());
|
||||
|
@ -2028,7 +2028,7 @@ namespace realclosure {
|
|||
// Solve
|
||||
// new_M_s * sc_cardinalities = new_taqrs
|
||||
VERIFY(mm().solve(new_M_s, sc_cardinalities.data(), new_taqrs.data()));
|
||||
TRACE("rcf_sign_det", tout << "solution: "; for (unsigned i = 0; i < sc_cardinalities.size(); i++) { tout << sc_cardinalities[i] << " "; } tout << "\n";);
|
||||
TRACE(rcf_sign_det, tout << "solution: "; for (unsigned i = 0; i < sc_cardinalities.size(); i++) { tout << sc_cardinalities[i] << " "; } tout << "\n";);
|
||||
// The solution must contain only positive values <= num_roots
|
||||
DEBUG_CODE(for (unsigned j = 0; j < sc_cardinalities.size(); j++) { SASSERT(0 <= sc_cardinalities[j] && sc_cardinalities[j] <= num_roots); });
|
||||
// We should keep q only if it discriminated something.
|
||||
|
@ -2085,7 +2085,7 @@ namespace realclosure {
|
|||
break;
|
||||
}
|
||||
}
|
||||
TRACE("rcf_sign_det",
|
||||
TRACE(rcf_sign_det,
|
||||
tout << "Final state\n";
|
||||
display_poly(tout, p_sz, p); tout << "\n";
|
||||
tout << M_s;
|
||||
|
@ -2284,7 +2284,7 @@ namespace realclosure {
|
|||
bool has_neg_upper = neg_root_upper_bound(n, p, neg_upper_N);
|
||||
bool has_pos_lower = pos_root_lower_bound(n, p, pos_lower_N);
|
||||
bool has_pos_upper = pos_root_upper_bound(n, p, pos_upper_N);
|
||||
TRACE("rcf_isolate",
|
||||
TRACE(rcf_isolate,
|
||||
display_poly(tout, n, p); tout << "\n";
|
||||
if (has_neg_lower) tout << "-2^" << neg_lower_N; else tout << "-oo";
|
||||
tout << " < neg-roots < ";
|
||||
|
@ -2302,7 +2302,7 @@ namespace realclosure {
|
|||
int num_sv_plus_inf = sign_variations_at_plus_inf(seq);
|
||||
int num_neg_roots = num_sv_minus_inf - num_sv_zero;
|
||||
int num_pos_roots = num_sv_zero - num_sv_plus_inf;
|
||||
TRACE("rcf_isolate",
|
||||
TRACE(rcf_isolate,
|
||||
tout << "num_neg_roots: " << num_neg_roots << "\n";
|
||||
tout << "num_pos_roots: " << num_pos_roots << "\n";);
|
||||
scoped_mpbqi pos_interval(bqim());
|
||||
|
@ -2392,7 +2392,7 @@ namespace realclosure {
|
|||
\brief Root isolation for polynomials where 0 is not a root.
|
||||
*/
|
||||
void nz_isolate_roots(unsigned n, value * const * p, numeral_vector & roots) {
|
||||
TRACE("rcf_isolate",
|
||||
TRACE(rcf_isolate,
|
||||
tout << "nz_isolate_roots\n";
|
||||
display_poly(tout, n, p); tout << "\n";);
|
||||
if (m_clean_denominators) {
|
||||
|
@ -2410,7 +2410,7 @@ namespace realclosure {
|
|||
\brief Root isolation entry point.
|
||||
*/
|
||||
void isolate_roots(unsigned n, numeral const * p, numeral_vector & roots) {
|
||||
TRACE("rcf_isolate_bug", tout << "isolate_roots: "; for (unsigned i = 0; i < n; i++) { display(tout, p[i]); tout << " "; } tout << "\n";);
|
||||
TRACE(rcf_isolate_bug, tout << "isolate_roots: "; for (unsigned i = 0; i < n; i++) { display(tout, p[i]); tout << " "; } tout << "\n";);
|
||||
SASSERT(n > 0);
|
||||
SASSERT(!is_zero(p[n-1]));
|
||||
if (n == 1) {
|
||||
|
@ -2903,7 +2903,7 @@ namespace realclosure {
|
|||
void rem(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
TRACE("rcf_rem",
|
||||
TRACE(rcf_rem,
|
||||
tout << "rem\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";);
|
||||
|
@ -2922,7 +2922,7 @@ namespace realclosure {
|
|||
checkpoint();
|
||||
sz1 = r.size();
|
||||
if (sz1 < sz2) {
|
||||
TRACE("rcf_rem", tout << "rem result\n"; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
TRACE(rcf_rem, tout << "rem result\n"; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
unsigned m_n = sz1 - sz2;
|
||||
|
@ -2947,7 +2947,7 @@ namespace realclosure {
|
|||
void prem(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, unsigned & d, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
TRACE("rcf_prem",
|
||||
TRACE(rcf_prem,
|
||||
tout << "prem\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";);
|
||||
|
@ -2967,7 +2967,7 @@ namespace realclosure {
|
|||
checkpoint();
|
||||
sz1 = r.size();
|
||||
if (sz1 < sz2) {
|
||||
TRACE("rcf_prem", tout << "prem result\n"; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
TRACE(rcf_prem, tout << "prem result\n"; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
unsigned m_n = sz1 - sz2;
|
||||
|
@ -3170,7 +3170,7 @@ namespace realclosure {
|
|||
*/
|
||||
void clean_denominators_core(value * a, value_ref & p, value_ref & q) {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_clean", tout << "clean_denominators_core [" << m_exec_depth << "]\na: "; display(tout, a, false); tout << "\n";);
|
||||
TRACE(rcf_clean, tout << "clean_denominators_core [" << m_exec_depth << "]\na: "; display(tout, a, false); tout << "\n";);
|
||||
p.reset(); q.reset();
|
||||
if (a == nullptr) {
|
||||
p = a;
|
||||
|
@ -3298,7 +3298,7 @@ namespace realclosure {
|
|||
}
|
||||
bool found_lt_eq = false;
|
||||
for (unsigned j = 0; j < p_sz; j++) {
|
||||
TRACE("rcf_clean_bug", tout << "j: " << j << " "; display(tout, m, false); tout << "\n";);
|
||||
TRACE(rcf_clean_bug, tout << "j: " << j << " "; display(tout, m, false); tout << "\n";);
|
||||
if (!dens[j])
|
||||
continue;
|
||||
if (i != j && !is_nz_rational(dens[j])) {
|
||||
|
@ -3663,7 +3663,7 @@ namespace realclosure {
|
|||
*/
|
||||
void gcd(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_gcd", tout << "GCD [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_gcd, tout << "GCD [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";);
|
||||
if (sz1 == 0) {
|
||||
|
@ -3681,13 +3681,13 @@ namespace realclosure {
|
|||
A.append(sz1, p1);
|
||||
B.append(sz2, p2);
|
||||
while (true) {
|
||||
TRACE("rcf_gcd",
|
||||
TRACE(rcf_gcd,
|
||||
tout << "A: "; display_poly(tout, A.size(), A.data()); tout << "\n";
|
||||
tout << "B: "; display_poly(tout, B.size(), B.data()); tout << "\n";);
|
||||
if (B.empty()) {
|
||||
mk_monic(A);
|
||||
r = A;
|
||||
TRACE("rcf_gcd",
|
||||
TRACE(rcf_gcd,
|
||||
tout << "gcd result: "; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
|
@ -3708,7 +3708,7 @@ namespace realclosure {
|
|||
|
||||
void prem_gcd(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_gcd", tout << "prem-GCD [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_gcd, tout << "prem-GCD [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";);
|
||||
SASSERT(p1 != r.data());
|
||||
|
@ -3728,14 +3728,14 @@ namespace realclosure {
|
|||
A.append(sz1, p1);
|
||||
B.append(sz2, p2);
|
||||
while (true) {
|
||||
TRACE("rcf_gcd",
|
||||
TRACE(rcf_gcd,
|
||||
tout << "A: "; display_poly(tout, A.size(), A.data()); tout << "\n";
|
||||
tout << "B: "; display_poly(tout, B.size(), B.data()); tout << "\n";);
|
||||
if (B.empty()) {
|
||||
normalize_int_coeffs(A);
|
||||
flip_sign_if_lc_neg(A);
|
||||
r = A;
|
||||
TRACE("rcf_gcd",
|
||||
TRACE(rcf_gcd,
|
||||
tout << "gcd result: "; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
|
@ -3805,7 +3805,7 @@ namespace realclosure {
|
|||
flet<bool> set(m_in_aux_values, true);
|
||||
|
||||
SASSERT(seq.size() >= 2);
|
||||
TRACE("rcf_sturm_seq",
|
||||
TRACE(rcf_sturm_seq,
|
||||
unsigned sz = seq.size();
|
||||
tout << "sturm_seq_core [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, seq.size(sz-2), seq.coeffs(sz-2)); tout << "\n";
|
||||
|
@ -3820,7 +3820,7 @@ namespace realclosure {
|
|||
else {
|
||||
srem(seq.size(sz-2), seq.coeffs(sz-2), seq.size(sz-1), seq.coeffs(sz-1), r);
|
||||
}
|
||||
TRACE("rcf_sturm_seq",
|
||||
TRACE(rcf_sturm_seq,
|
||||
tout << "sturm_seq_core [" << m_exec_depth << "], new polynomial\n";
|
||||
display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
if (r.empty())
|
||||
|
@ -4208,7 +4208,7 @@ namespace realclosure {
|
|||
*/
|
||||
int TaQ(unsigned p_sz, value * const * p, unsigned q_sz, value * const * q, mpbqi const & interval) {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_TaQ", tout << "TaQ [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_TaQ, tout << "TaQ [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, p_sz, p); tout << "\n";
|
||||
display_poly(tout, q_sz, q); tout << "\n";);
|
||||
scoped_polynomial_seq seq(*this);
|
||||
|
@ -4224,7 +4224,7 @@ namespace realclosure {
|
|||
*/
|
||||
int TaQ_1(unsigned p_sz, value * const * p, mpbqi const & interval) {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_TaQ", tout << "TaQ_1 [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_TaQ, tout << "TaQ_1 [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, p_sz, p); tout << "\n";);
|
||||
scoped_polynomial_seq seq(*this);
|
||||
sturm_seq(p_sz, p, seq);
|
||||
|
@ -4324,7 +4324,7 @@ namespace realclosure {
|
|||
refine_transcendental_interval(to_transcendental(v->ext()), _prec);
|
||||
update_rf_interval(v, prec);
|
||||
|
||||
TRACE("rcf_transcendental", tout << "after update_rf_interval: " << magnitude(v->interval()) << " ";
|
||||
TRACE(rcf_transcendental, tout << "after update_rf_interval: " << magnitude(v->interval()) << " ";
|
||||
bqim().display(tout, v->interval()); tout << std::endl;);
|
||||
|
||||
if (check_precision(v->interval(), prec))
|
||||
|
@ -4471,7 +4471,7 @@ namespace realclosure {
|
|||
return false;
|
||||
|
||||
update_rf_interval(v, prec);
|
||||
TRACE("rcf_algebraic", tout << "after update_rf_interval: " << magnitude(v->interval()) << " "; bqim().display(tout, v->interval()); tout << std::endl;);
|
||||
TRACE(rcf_algebraic, tout << "after update_rf_interval: " << magnitude(v->interval()) << " "; bqim().display(tout, v->interval()); tout << std::endl;);
|
||||
if (check_precision(v->interval(), prec))
|
||||
return true;
|
||||
_prec++;
|
||||
|
@ -4913,7 +4913,7 @@ namespace realclosure {
|
|||
bool expensive_determine_algebraic_sign(rational_function_value * v) {
|
||||
SASSERT(contains_zero(v->interval()));
|
||||
SASSERT(v->ext()->is_algebraic());
|
||||
TRACE("rcf_algebraic_sign",
|
||||
TRACE(rcf_algebraic_sign,
|
||||
tout << "expensive_determine_algebraic_sign\n"; display(tout, v, false);
|
||||
tout << "\ninterval: "; bqim().display(tout, v->interval()); tout << "\n";);
|
||||
algebraic * x = to_algebraic(v->ext());
|
||||
|
@ -4973,7 +4973,7 @@ namespace realclosure {
|
|||
UNREACHABLE();
|
||||
r = false;
|
||||
}
|
||||
TRACE("rcf_determine_sign_bug",
|
||||
TRACE(rcf_determine_sign_bug,
|
||||
tout << "result: " << r << "\n";
|
||||
display_compact(tout, v); tout << "\n";
|
||||
tout << "sign: " << sign(v) << "\n";);
|
||||
|
@ -4999,7 +4999,7 @@ namespace realclosure {
|
|||
*/
|
||||
void normalize_fraction(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & new_p1, value_ref_buffer & new_p2) {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_arith", tout << "normalize [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_arith, tout << "normalize [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";);
|
||||
SASSERT(sz1 > 0 && sz2 > 0);
|
||||
|
@ -5023,7 +5023,7 @@ namespace realclosure {
|
|||
normalize_num_monic_den(tmp1.size(), tmp1.data(), tmp2.size(), tmp2.data(), new_p1, new_p2);
|
||||
}
|
||||
}
|
||||
TRACE("normalize_fraction_bug",
|
||||
TRACE(normalize_fraction_bug,
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";
|
||||
tout << "====>\n";
|
||||
|
@ -5232,7 +5232,7 @@ namespace realclosure {
|
|||
}
|
||||
else {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_arith", tout << "add [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_arith, tout << "add [" << m_exec_depth << "]\n";
|
||||
display(tout, a, false); tout << "\n";
|
||||
display(tout, b, false); tout << "\n";);
|
||||
switch (compare_rank(a, b)) {
|
||||
|
@ -5440,7 +5440,7 @@ namespace realclosure {
|
|||
}
|
||||
else {
|
||||
INC_DEPTH();
|
||||
TRACE("rcf_arith", tout << "mul [" << m_exec_depth << "]\n";
|
||||
TRACE(rcf_arith, tout << "mul [" << m_exec_depth << "]\n";
|
||||
display(tout, a, false); tout << "\n";
|
||||
display(tout, b, false); tout << "\n";);
|
||||
switch (compare_rank(a, b)) {
|
||||
|
@ -5497,7 +5497,7 @@ namespace realclosure {
|
|||
The following procedure is essentially a special case of the extended polynomial GCD algorithm.
|
||||
*/
|
||||
bool inv_algebraic(unsigned q_sz, value * const * q, unsigned p_sz, value * const * p, value_ref_buffer & g, value_ref_buffer & h) {
|
||||
TRACE("inv_algebraic",
|
||||
TRACE(inv_algebraic,
|
||||
tout << "q: "; display_poly(tout, q_sz, q); tout << "\n";
|
||||
tout << "p: "; display_poly(tout, p_sz, p); tout << "\n";);
|
||||
SASSERT(q_sz > 0);
|
||||
|
@ -5517,7 +5517,7 @@ namespace realclosure {
|
|||
while (true) {
|
||||
// In every iteration of the loop we have
|
||||
// Q(alpha) * h(alpha) = R(alpha)
|
||||
TRACE("inv_algebraic",
|
||||
TRACE(inv_algebraic,
|
||||
tout << "Q: "; display_poly(tout, Q.size(), Q.data()); tout << "\n";
|
||||
tout << "R: "; display_poly(tout, R.size(), R.data()); tout << "\n";);
|
||||
if (Q.size() == 1) {
|
||||
|
@ -5525,7 +5525,7 @@ namespace realclosure {
|
|||
// We just divide R by Q[0].
|
||||
// h(alpha) = R(alpha) / Q[0]
|
||||
div(R.size(), R.data(), Q[0], h);
|
||||
TRACE("inv_algebraic", tout << "h: "; display_poly(tout, h.size(), h.data()); tout << "\n";);
|
||||
TRACE(inv_algebraic, tout << "h: "; display_poly(tout, h.size(), h.data()); tout << "\n";);
|
||||
// g <- 1
|
||||
g.reset(); g.push_back(one());
|
||||
return true;
|
||||
|
|
|
@ -203,7 +203,7 @@ namespace opt {
|
|||
return true;
|
||||
}
|
||||
|
||||
#define PASSERT(_e_) { CTRACE("qe", !(_e_), display(tout, r); display(tout);); SASSERT(_e_); }
|
||||
#define PASSERT(_e_) { CTRACE(qe, !(_e_), display(tout, r); display(tout);); SASSERT(_e_); }
|
||||
|
||||
bool model_based_opt::invariant(unsigned index, row const& r) {
|
||||
vector<var> const& vars = r.m_vars;
|
||||
|
@ -250,7 +250,7 @@ namespace opt {
|
|||
inf_eps model_based_opt::maximize() {
|
||||
SASSERT(invariant());
|
||||
unsigned_vector bound_trail, bound_vars;
|
||||
TRACE("opt", display(tout << "tableau\n"););
|
||||
TRACE(opt, display(tout << "tableau\n"););
|
||||
while (!objective().m_vars.empty()) {
|
||||
var v = objective().m_vars.back();
|
||||
unsigned x = v.m_id;
|
||||
|
@ -259,7 +259,7 @@ namespace opt {
|
|||
rational bound_coeff;
|
||||
if (find_bound(x, bound_row_index, bound_coeff, coeff.is_pos())) {
|
||||
SASSERT(!bound_coeff.is_zero());
|
||||
TRACE("opt", display(tout << "update: " << v << " ", objective());
|
||||
TRACE(opt, display(tout << "update: " << v << " ", objective());
|
||||
for (unsigned above : m_above) {
|
||||
display(tout << "resolve: ", m_rows[above]);
|
||||
});
|
||||
|
@ -280,7 +280,7 @@ namespace opt {
|
|||
bound_vars.push_back(x);
|
||||
}
|
||||
else {
|
||||
TRACE("opt", display(tout << "unbound: " << v << " ", objective()););
|
||||
TRACE(opt, display(tout << "unbound: " << v << " ", objective()););
|
||||
update_values(bound_vars, bound_trail);
|
||||
return inf_eps::infinity();
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ namespace opt {
|
|||
new_x_val += eps;
|
||||
}
|
||||
}
|
||||
TRACE("opt", display(tout << "v" << x
|
||||
TRACE(opt, display(tout << "v" << x
|
||||
<< " coeff_x: " << x_coeff
|
||||
<< " old_x_val: " << old_x_val
|
||||
<< " new_x_val: " << new_x_val
|
||||
|
@ -558,7 +558,7 @@ namespace opt {
|
|||
if (m_rows[row_dst].m_alive) {
|
||||
rational a2 = get_coefficient(row_dst, x);
|
||||
if (is_int(x)) {
|
||||
TRACE("opt",
|
||||
TRACE(opt,
|
||||
tout << "v" << x << ": " << a1 << " " << a2 << ":\n";
|
||||
display(tout, m_rows[row_dst]);
|
||||
display(tout, m_rows[row_src]););
|
||||
|
@ -569,7 +569,7 @@ namespace opt {
|
|||
mul(row_dst, abs(a1));
|
||||
mul_add(false, row_dst, -abs(a2), row_src);
|
||||
}
|
||||
TRACE("opt", display(tout << "result ", m_rows[row_dst]););
|
||||
TRACE(opt, display(tout << "result ", m_rows[row_dst]););
|
||||
normalize(row_dst);
|
||||
}
|
||||
else {
|
||||
|
@ -621,7 +621,7 @@ namespace opt {
|
|||
|
||||
|
||||
if (use_case1) {
|
||||
TRACE("opt", tout << "slack: " << slack << " " << src_c << " " << dst_val << " " << dst_c << " " << src_val << "\n";);
|
||||
TRACE(opt, tout << "slack: " << slack << " " << src_c << " " << dst_val << " " << dst_c << " " << src_val << "\n";);
|
||||
// dst <- abs_src_c*dst + abs_dst_c*src + slack
|
||||
mul(row_dst, abs_src_c);
|
||||
add(row_dst, slack);
|
||||
|
@ -696,7 +696,7 @@ namespace opt {
|
|||
// exists z in [0 .. |b|-2] . |b| | (z + s) && a*n_sign(b)(s + z) + |b|t <= 0
|
||||
//
|
||||
|
||||
TRACE("qe", tout << "finite disjunction " << distance << " " << src_c << " " << dst_c << "\n";);
|
||||
TRACE(qe, tout << "finite disjunction " << distance << " " << src_c << " " << dst_c << "\n";);
|
||||
vector<var> coeffs;
|
||||
if (abs_dst_c <= abs_src_c) {
|
||||
rational z = mod(dst_val, abs_dst_c);
|
||||
|
@ -1174,7 +1174,7 @@ namespace opt {
|
|||
result = def::from_row(m_rows[lub_index], x);
|
||||
else
|
||||
result = def::from_row(m_rows[glb_index], x);
|
||||
TRACE("opt1", display(tout << "resolution result:", *result) << "\n");
|
||||
TRACE(opt1, display(tout << "resolution result:", *result) << "\n");
|
||||
}
|
||||
|
||||
// The number of matching lower and upper bounds is small.
|
||||
|
@ -1271,7 +1271,7 @@ namespace opt {
|
|||
def_ref result(nullptr);
|
||||
unsigned_vector div_rows(_div_rows), mod_rows(_mod_rows);
|
||||
SASSERT(!div_rows.empty() || !mod_rows.empty());
|
||||
TRACE("opt", display(tout << "solve_div v" << x << "\n"));
|
||||
TRACE(opt, display(tout << "solve_div v" << x << "\n"));
|
||||
|
||||
rational K(1);
|
||||
for (unsigned ri : div_rows)
|
||||
|
@ -1494,11 +1494,11 @@ namespace opt {
|
|||
|
||||
result = *(*y_def * K) + *z_def;
|
||||
m_var2value[x] = eval(*result);
|
||||
TRACE("opt", tout << y << " := " << *y_def << "\n";
|
||||
TRACE(opt, tout << y << " := " << *y_def << "\n";
|
||||
tout << z << " := " << *z_def << "\n";
|
||||
tout << x << " := " << *result << "\n");
|
||||
}
|
||||
TRACE("opt", display(tout << "solve_div done v" << x << "\n"));
|
||||
TRACE(opt, display(tout << "solve_div done v" << x << "\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1527,7 +1527,7 @@ namespace opt {
|
|||
throw default_exception("modulo 0 is not defined");
|
||||
}
|
||||
if (D.is_neg()) D = abs(D);
|
||||
TRACE("opt1", display(tout << "lcm: " << D << " x: v" << x << " tableau\n"););
|
||||
TRACE(opt1, display(tout << "lcm: " << D << " x: v" << x << " tableau\n"););
|
||||
rational val_x = m_var2value[x];
|
||||
rational u = mod(val_x, D);
|
||||
SASSERT(u.is_nonneg() && u < D);
|
||||
|
@ -1536,7 +1536,7 @@ namespace opt {
|
|||
SASSERT(invariant(idx, m_rows[idx]));
|
||||
normalize(idx);
|
||||
}
|
||||
TRACE("opt1", display(tout << "tableau after replace x under mod\n"););
|
||||
TRACE(opt1, display(tout << "tableau after replace x under mod\n"););
|
||||
//
|
||||
// update inequalities such that u is added to t and
|
||||
// D is multiplied to coefficient of x.
|
||||
|
@ -1559,13 +1559,13 @@ namespace opt {
|
|||
visited.insert(row_id);
|
||||
normalize(row_id);
|
||||
}
|
||||
TRACE("opt1", display(tout << "tableau after replace v" << x << " := " << D << " * v" << y << "\n"););
|
||||
TRACE(opt1, display(tout << "tableau after replace v" << x << " := " << D << " * v" << y << "\n"););
|
||||
def_ref result = project(y, compute_def);
|
||||
if (compute_def) {
|
||||
result = *(*result * D) + u;
|
||||
m_var2value[x] = eval(*result);
|
||||
}
|
||||
TRACE("opt1", display(tout << "tableau after project v" << y << "\n"););
|
||||
TRACE(opt1, display(tout << "tableau after project v" << y << "\n"););
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1631,7 +1631,7 @@ namespace opt {
|
|||
// 3 | -t & 21 | (-ct + 3s) & a-t <= 3u
|
||||
|
||||
model_based_opt::def_ref model_based_opt::solve_for(unsigned row_id1, unsigned x, bool compute_def) {
|
||||
TRACE("opt", tout << "v" << x << " := " << eval(x) << "\n" << m_rows[row_id1] << "\n";
|
||||
TRACE(opt, tout << "v" << x << " := " << eval(x) << "\n" << m_rows[row_id1] << "\n";
|
||||
display(tout));
|
||||
rational a = get_coefficient(row_id1, x), b;
|
||||
row& r1 = m_rows[row_id1];
|
||||
|
@ -1690,10 +1690,10 @@ namespace opt {
|
|||
if (compute_def) {
|
||||
result = def::from_row(m_rows[row_id1], x);
|
||||
m_var2value[x] = eval(*result);
|
||||
TRACE("opt1", tout << "updated eval " << x << " := " << eval(x) << "\n";);
|
||||
TRACE(opt1, tout << "updated eval " << x << " := " << eval(x) << "\n";);
|
||||
}
|
||||
retire_row(row_id1);
|
||||
TRACE("opt", display(tout << "solved v" << x << "\n"));
|
||||
TRACE(opt, display(tout << "solved v" << x << "\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1709,7 +1709,7 @@ namespace opt {
|
|||
m_result.push_back(project(vars[i], compute_def));
|
||||
if (compute_def)
|
||||
eliminate(vars[i], *(m_result.back()));
|
||||
TRACE("opt", display(tout << "After projecting: v" << vars[i] << "\n"););
|
||||
TRACE(opt, display(tout << "After projecting: v" << vars[i] << "\n"););
|
||||
}
|
||||
return m_result;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace smt {
|
|||
m_graph.add_edge(e.get_target(), e.get_source(), e.get_weight(), explanation());
|
||||
}
|
||||
}
|
||||
TRACE("network_flow", {
|
||||
TRACE(network_flow, {
|
||||
tout << "Difference logic optimization:" << std::endl;
|
||||
display_dual(tout);
|
||||
tout << "Minimum cost flow:" << std::endl;
|
||||
|
@ -143,7 +143,7 @@ namespace smt {
|
|||
|
||||
template<typename Ext>
|
||||
void network_flow<Ext>::initialize() {
|
||||
TRACE("network_flow", tout << "initialize...\n";);
|
||||
TRACE(network_flow, tout << "initialize...\n";);
|
||||
// Create an artificial root node to construct initial spanning tree
|
||||
unsigned num_nodes = m_graph.get_num_nodes();
|
||||
unsigned num_edges = m_graph.get_num_edges();
|
||||
|
@ -180,7 +180,7 @@ namespace smt {
|
|||
|
||||
m_tree->initialize(tree);
|
||||
|
||||
TRACE("network_flow",
|
||||
TRACE(network_flow,
|
||||
tout << pp_vector("Potentials", m_potentials);
|
||||
tout << pp_vector("Flows", m_flows);
|
||||
tout << "Cost: " << get_cost() << "\n";
|
||||
|
@ -206,7 +206,7 @@ namespace smt {
|
|||
start = src;
|
||||
}
|
||||
SASSERT(m_tree->in_subtree_t2(start));
|
||||
TRACE("network_flow", tout << "update_potentials of T_" << start << " with change = " << change << "...\n";);
|
||||
TRACE(network_flow, tout << "update_potentials of T_" << start << " with change = " << change << "...\n";);
|
||||
svector<node> descendants;
|
||||
m_tree->get_descendants(start, descendants);
|
||||
SASSERT(descendants.size() >= 1);
|
||||
|
@ -214,7 +214,7 @@ namespace smt {
|
|||
node u = descendants[i];
|
||||
m_potentials[u] += change;
|
||||
}
|
||||
TRACE("network_flow", tout << pp_vector("Potentials", m_potentials););
|
||||
TRACE(network_flow, tout << pp_vector("Potentials", m_potentials););
|
||||
}
|
||||
|
||||
template<typename Ext>
|
||||
|
@ -230,7 +230,7 @@ namespace smt {
|
|||
edge_id e_id = path[i];
|
||||
m_flows[e_id] += against[i] ? - *m_delta : *m_delta;
|
||||
}
|
||||
TRACE("network_flow", tout << pp_vector("Flows", m_flows););
|
||||
TRACE(network_flow, tout << pp_vector("Flows", m_flows););
|
||||
}
|
||||
|
||||
template<typename Ext>
|
||||
|
@ -288,7 +288,7 @@ namespace smt {
|
|||
bool bounded = choose_leaving_edge();
|
||||
if (!bounded) return UNBOUNDED;
|
||||
vector<edge>const& es = m_graph.get_all_edges();
|
||||
TRACE("network_flow",
|
||||
TRACE(network_flow,
|
||||
{
|
||||
edge const& e_in = es[m_enter_id];
|
||||
edge const& e_out = es[m_leave_id];
|
||||
|
@ -310,7 +310,7 @@ namespace smt {
|
|||
m_states[m_leave_id] = LOWER;
|
||||
update_spanning_tree();
|
||||
update_potentials();
|
||||
TRACE("network_flow",
|
||||
TRACE(network_flow,
|
||||
tout << "Spanning tree:\n";
|
||||
display_spanning_tree(tout);
|
||||
tout << "Cost: " << get_cost() << "\n";
|
||||
|
@ -319,14 +319,14 @@ namespace smt {
|
|||
SASSERT(check_well_formed());
|
||||
}
|
||||
}
|
||||
TRACE("network_flow",
|
||||
TRACE(network_flow,
|
||||
tout << "Spanning tree:\n";
|
||||
display_spanning_tree(tout);
|
||||
tout << "Cost: " << get_cost() << "\n";
|
||||
display_primal(tout);
|
||||
);
|
||||
if (is_infeasible()) return INFEASIBLE;
|
||||
TRACE("network_flow", tout << "Found optimal solution.\n";);
|
||||
TRACE(network_flow, tout << "Found optimal solution.\n";);
|
||||
SASSERT(check_optimal());
|
||||
return OPTIMAL;
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ namespace smt {
|
|||
for (unsigned i = 0; i < m_potentials.size(); ++i) {
|
||||
total_balance += m_balances[i] * m_potentials[i];
|
||||
}
|
||||
TRACE("network_flow", tout << "Total balance: " << total_balance << ", total cost: " << total_cost << std::endl;);
|
||||
TRACE(network_flow, tout << "Total balance: " << total_balance << ", total cost: " << total_cost << std::endl;);
|
||||
return total_cost == total_balance;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace simplex {
|
|||
m.mul(coeffs[m_base_vars[i]], mul, a);
|
||||
m.set(b, m_vars[v].m_base_coeff);
|
||||
m.lcm(a, b, c);
|
||||
TRACE("simplex",
|
||||
TRACE(simplex,
|
||||
m.display(tout << " a: ", a);
|
||||
m.display(tout << " b v" << v << " : ", b);
|
||||
m.display(tout << " c: ", c);
|
||||
|
@ -69,7 +69,7 @@ namespace simplex {
|
|||
M.mul(r, b);
|
||||
m.neg(a);
|
||||
M.add(r, a, row(m_vars[v].m_base2row));
|
||||
TRACE("simplex", M.display_row(tout, r););
|
||||
TRACE(simplex, M.display_row(tout, r););
|
||||
}
|
||||
|
||||
scoped_numeral base_coeff(m);
|
||||
|
@ -87,7 +87,7 @@ namespace simplex {
|
|||
}
|
||||
}
|
||||
SASSERT(!m.is_zero(base_coeff));
|
||||
TRACE("simplex",
|
||||
TRACE(simplex,
|
||||
for (unsigned i = 0; i < num_vars; ++i) {
|
||||
m.display(tout << "v" << vars[i] << " * ", coeffs[i]); tout << " ";
|
||||
if (i + 1 < num_vars) tout << " + ";
|
||||
|
@ -132,7 +132,7 @@ namespace simplex {
|
|||
void simplex<Ext>::add_patch(var_t v) {
|
||||
SASSERT(is_base(v));
|
||||
if (outside_bounds(v)) {
|
||||
TRACE("simplex", tout << "Add patch: v" << v << "\n";);
|
||||
TRACE(simplex, tout << "Add patch: v" << v << "\n";);
|
||||
m_to_patch.insert(v);
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ namespace simplex {
|
|||
|
||||
template<typename Ext>
|
||||
void simplex<Ext>::del_row(var_t var) {
|
||||
TRACE("simplex", tout << var << "\n";);
|
||||
TRACE(simplex, tout << var << "\n";);
|
||||
row r;
|
||||
if (is_base(var)) {
|
||||
r = row(m_vars[var].m_base2row);
|
||||
|
@ -182,7 +182,7 @@ namespace simplex {
|
|||
SASSERT(!below_lower(old_base) && !above_upper(old_base));
|
||||
}
|
||||
del_row(r);
|
||||
TRACE("simplex", display(tout););
|
||||
TRACE(simplex, display(tout););
|
||||
SASSERT(well_formed());
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ namespace simplex {
|
|||
var_info& vi = m_vars[var];
|
||||
em.set(vi.m_lower, b);
|
||||
vi.m_lower_valid = true;
|
||||
TRACE("simplex", em.display(tout << "v" << var << " lower: ", b);
|
||||
TRACE(simplex, em.display(tout << "v" << var << " lower: ", b);
|
||||
em.display(tout << " value: ", vi.m_value););
|
||||
SASSERT(!vi.m_upper_valid || em.le(b, vi.m_upper));
|
||||
if (!vi.m_is_base && em.lt(vi.m_value, b)) {
|
||||
|
@ -339,7 +339,7 @@ namespace simplex {
|
|||
m_bland = false;
|
||||
SASSERT(well_formed());
|
||||
while ((v = select_var_to_fix()) != null_var) {
|
||||
TRACE("simplex", display(tout << "v" << v << "\n"););
|
||||
TRACE(simplex, display(tout << "v" << v << "\n"););
|
||||
if (!m_limit.inc() || num_iterations > m_max_iterations) {
|
||||
return l_undef;
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ namespace simplex {
|
|||
// optimal
|
||||
return l_true;
|
||||
}
|
||||
TRACE("simplex", tout << "x_i: v" << x_i << " x_j: v" << x_j << "\n";);
|
||||
TRACE(simplex, tout << "x_i: v" << x_i << " x_j: v" << x_j << "\n";);
|
||||
var_info& vj = m_vars[x_j];
|
||||
if (x_i == null_var) {
|
||||
if (inc_x_j && vj.m_upper_valid) {
|
||||
|
@ -714,10 +714,10 @@ namespace simplex {
|
|||
//
|
||||
|
||||
pivot(x_i, x_j, a_ij);
|
||||
TRACE("simplex", display(tout << "after pivot\n"););
|
||||
TRACE(simplex, display(tout << "after pivot\n"););
|
||||
move_to_bound(x_i, !inc_x_i);
|
||||
SASSERT(well_formed_row(row(m_vars[x_j].m_base2row)));
|
||||
TRACE("simplex", display(tout););
|
||||
TRACE(simplex, display(tout););
|
||||
SASSERT(is_feasible());
|
||||
}
|
||||
return l_true;
|
||||
|
@ -733,7 +733,7 @@ namespace simplex {
|
|||
else {
|
||||
em.sub(vi.m_upper, vi.m_value, delta);
|
||||
}
|
||||
TRACE("simplex", tout << "move " << (to_lower?"to_lower":"to_upper")
|
||||
TRACE(simplex, tout << "move " << (to_lower?"to_lower":"to_upper")
|
||||
<< " v" << x << " delta: " << em.to_string(delta) << "\n";);
|
||||
col_iterator it = M.col_begin(x), end = M.col_end(x);
|
||||
for (; it != end && is_pos(delta); ++it) {
|
||||
|
@ -766,7 +766,7 @@ namespace simplex {
|
|||
em.mul(delta2, base_coeff, delta2);
|
||||
em.div(delta2, coeff, delta2);
|
||||
em.abs(delta2);
|
||||
TRACE("simplex", tout << "Delta for v" << s << " " << delta2 << "\n";);
|
||||
TRACE(simplex, tout << "Delta for v" << s << " " << delta2 << "\n";);
|
||||
if (delta2 < delta) {
|
||||
delta = delta2;
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ namespace simplex {
|
|||
if (x == v) continue;
|
||||
bool inc_x = m.is_pos(it->m_coeff) == m.is_pos(m_vars[v].m_base_coeff);
|
||||
if ((inc_x && at_upper(x)) || (!inc_x && at_lower(x))) {
|
||||
TRACE("simplex", tout << "v" << x << " pos: " << inc_x
|
||||
TRACE(simplex, tout << "v" << x << " pos: " << inc_x
|
||||
<< " at upper: " << at_upper(x)
|
||||
<< " at lower: " << at_lower(x) << "\n";);
|
||||
continue; // variable cannot be used for improving bounds.
|
||||
|
@ -826,7 +826,7 @@ namespace simplex {
|
|||
((is_zero(new_gain) && is_zero(gain) && (x_i == null_var || y < x_i)));
|
||||
|
||||
if (better) {
|
||||
TRACE("simplex",
|
||||
TRACE(simplex,
|
||||
em.display(tout << "gain:", gain);
|
||||
em.display(tout << " new gain:", new_gain);
|
||||
tout << " base x_i: " << y << ", new base x_j: " << x << ", inc x_j: " << inc_x << "\n";);
|
||||
|
@ -871,7 +871,7 @@ namespace simplex {
|
|||
numeral const& a_ii = vi.m_base_coeff;
|
||||
bool sign_eq = (m.is_pos(a_ii) == m.is_pos(a_ij));
|
||||
bool inc_s = sign_eq != inc_x_j;
|
||||
TRACE("simplex", tout << "x_j: v" << x_j << ", base x_i: v" << s
|
||||
TRACE(simplex, tout << "x_j: v" << x_j << ", base x_i: v" << s
|
||||
<< ", inc_x_i: " << inc_s
|
||||
<< ", inc_x_j: " << inc_x_j
|
||||
<< ", upper valid:" << vi.m_upper_valid
|
||||
|
@ -896,7 +896,7 @@ namespace simplex {
|
|||
gain = curr_gain;
|
||||
new_a_ij = a_ij;
|
||||
inc_x_i = inc_s;
|
||||
TRACE("simplex", tout << "x_j v" << x_j << " x_i v" << x_i << " gain: ";
|
||||
TRACE(simplex, tout << "x_j v" << x_j << " x_i v" << x_i << " gain: ";
|
||||
tout << curr_gain << "\n";);
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ namespace simplex {
|
|||
if (m_left_basis.contains(v)) {
|
||||
num_repeated++;
|
||||
if (num_repeated > m_blands_rule_threshold) {
|
||||
TRACE("simplex", tout << "using blands rule, " << num_repeated << "\n";);
|
||||
TRACE(simplex, tout << "using blands rule, " << num_repeated << "\n";);
|
||||
// std::cerr << "BLANDS RULE...\n";
|
||||
m_bland = true;
|
||||
}
|
||||
|
@ -1019,7 +1019,7 @@ namespace simplex {
|
|||
}
|
||||
if (!em.is_zero(sum)) {
|
||||
IF_VERBOSE(0, M.display_row(verbose_stream(), r););
|
||||
TRACE("pb", display(tout << "non-well formed row\n"); M.display_row(tout << "row: ", r););
|
||||
TRACE(pb, display(tout << "non-well formed row\n"); M.display_row(tout << "row: ", r););
|
||||
throw default_exception("non-well formed row");
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ public:
|
|||
|
||||
this->mk_decided_bound(x, mid, false, m_left_open, left);
|
||||
this->mk_decided_bound(x, mid, true, !m_left_open, right);
|
||||
TRACE("subpaving_int_split",
|
||||
TRACE(subpaving_int_split,
|
||||
tout << "LEFT:\n"; this->ctx()->display_bounds(tout, left);
|
||||
tout << "\nRIGHT:\n"; this->ctx()->display_bounds(tout, right););
|
||||
}
|
||||
|
@ -562,9 +562,9 @@ typename context_t<C>::bound * context_t<C>::mk_bound(var x, numeral const & val
|
|||
r->m_prev = n->trail_stack();
|
||||
r->m_jst = jst;
|
||||
n->push(r);
|
||||
TRACE("subpaving_mk_bound", tout << "mk_bound: "; display(tout, r); tout << "\ntimestamp: " << r->m_timestamp << "\n";);
|
||||
TRACE(subpaving_mk_bound, tout << "mk_bound: "; display(tout, r); tout << "\ntimestamp: " << r->m_timestamp << "\n";);
|
||||
if (conflicting_bounds(x, n)) {
|
||||
TRACE("subpaving_mk_bound", tout << "conflict\n"; display_bounds(tout, n););
|
||||
TRACE(subpaving_mk_bound, tout << "conflict\n"; display_bounds(tout, n););
|
||||
set_conflict(x, n);
|
||||
}
|
||||
m_timestamp++;
|
||||
|
@ -671,7 +671,7 @@ template<typename C>
|
|||
bool context_t<C>::is_int(polynomial const * p) const {
|
||||
for (unsigned i = 0; i < p->size(); i++) {
|
||||
if (!is_int(p->x(i)) || !nm().is_int(p->a(i))) {
|
||||
TRACE("subpaving_is_int", tout << "polynomial is not integer due to monomial at i: " << i << "\n"; tout.flush();
|
||||
TRACE(subpaving_is_int, tout << "polynomial is not integer due to monomial at i: " << i << "\n"; tout.flush();
|
||||
display(tout, p->x(i)); tout << " "; nm().display(tout, p->a(i)); tout << "\n";);
|
||||
return false;
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ var context_t<C>::mk_sum(numeral const & c, unsigned sz, numeral const * as, var
|
|||
var x = p->m_xs[i];
|
||||
nm().swap(m_num_buffer[x], *curr);
|
||||
}
|
||||
TRACE("subpaving_mk_sum", tout << "new variable is integer: " << is_int(p) << "\n";);
|
||||
TRACE(subpaving_mk_sum, tout << "new variable is integer: " << is_int(p) << "\n";);
|
||||
var new_var = mk_var(is_int(p));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
var x = p->m_xs[i];
|
||||
|
@ -785,7 +785,7 @@ typename context_t<C>::ineq * context_t<C>::mk_ineq(var x, numeral const & k, bo
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::inc_ref(ineq * a) {
|
||||
TRACE("subpaving_ref_count", tout << "inc-ref: " << a << " " << a->m_ref_count << "\n";);
|
||||
TRACE(subpaving_ref_count, tout << "inc-ref: " << a << " " << a->m_ref_count << "\n";);
|
||||
if (a)
|
||||
a->m_ref_count++;
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ void context_t<C>::inc_ref(ineq * a) {
|
|||
template<typename C>
|
||||
void context_t<C>::dec_ref(ineq * a) {
|
||||
if (a) {
|
||||
TRACE("subpaving_ref_count",
|
||||
TRACE(subpaving_ref_count,
|
||||
tout << "dec-ref: " << a << " " << a->m_ref_count << "\n";
|
||||
a->display(tout, nm());
|
||||
tout << "\n";);
|
||||
|
@ -840,7 +840,7 @@ void context_t<C>::add_clause_core(unsigned sz, ineq * const * atoms, bool lemma
|
|||
else if (watch) {
|
||||
m_lemmas.push_back(c);
|
||||
}
|
||||
TRACE("subpaving_clause", tout << "new clause:\n"; display(tout, c); tout << "\n";);
|
||||
TRACE(subpaving_clause, tout << "new clause:\n"; display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
@ -865,7 +865,7 @@ void context_t<C>::del_clause(clause * c) {
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::add_unit_clause(ineq * a, bool axiom) {
|
||||
TRACE("subpaving", a->display(tout, nm(), *m_display_proc); tout << "\n";);
|
||||
TRACE(subpaving, a->display(tout, nm(), *m_display_proc); tout << "\n";);
|
||||
inc_ref(a);
|
||||
m_unit_clauses.push_back(TAG(ineq*, a, axiom));
|
||||
}
|
||||
|
@ -1171,7 +1171,7 @@ void context_t<C>::set_conflict(var x, node * n) {
|
|||
template<typename C>
|
||||
bool context_t<C>::may_propagate(bound * b, constraint * c, node * n) {
|
||||
SASSERT(b != 0 && c != 0);
|
||||
TRACE("may_propagate_bug", display(tout, b); tout << " | "; display(tout, c); tout << "\nresult: " << (b->timestamp() > c->timestamp()) << ", " << b->timestamp() << ", " << c->timestamp() << "\n";);
|
||||
TRACE(may_propagate_bug, display(tout, b); tout << " | "; display(tout, c); tout << "\nresult: " << (b->timestamp() > c->timestamp()) << ", " << b->timestamp() << ", " << c->timestamp() << "\n";);
|
||||
return b->timestamp() >= c->timestamp();
|
||||
}
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
bound * curr_upper = n->upper(x);
|
||||
SASSERT(curr_lower == 0 || curr_lower->x() == x);
|
||||
SASSERT(curr_upper == 0 || curr_upper->x() == x);
|
||||
TRACE("subpaving_relevant_bound",
|
||||
TRACE(subpaving_relevant_bound,
|
||||
display(tout, x); tout << " " << (lower ? ">" : "<") << (open ? "" : "=") << " "; nm().display(tout, k); tout << "\n";
|
||||
tout << "existing bounds:\n";
|
||||
if (curr_lower) { display(tout, curr_lower); tout << "\n"; }
|
||||
|
@ -1217,18 +1217,18 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
if (lower) {
|
||||
// If new bound triggers a conflict, then it is relevant.
|
||||
if (curr_upper && (nm().gt(k, curr_upper->value()) || ((open || curr_upper->is_open()) && nm().eq(k, curr_upper->value())))) {
|
||||
TRACE("subpaving_relevant_bound", tout << "relevant because triggers conflict.\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "relevant because triggers conflict.\n";);
|
||||
return true;
|
||||
}
|
||||
// If m_epsilon is zero, then bound is relevant only if it improves existing bound.
|
||||
if (m_zero_epsilon && curr_lower != nullptr && (nm().lt(k, curr_lower->value()) || ((curr_lower->is_open() || !open) && nm().eq(k, curr_lower->value())))) {
|
||||
// new lower bound does not improve existing bound
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound.\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "irrelevant because does not improve existing bound.\n";);
|
||||
return false;
|
||||
}
|
||||
if (curr_upper == nullptr && nm().lt(m_max_bound, k)) {
|
||||
// new lower bound exceeds the :max-bound threshold
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because exceeds :max-bound threshold.\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "irrelevant because exceeds :max-bound threshold.\n";);
|
||||
return false;
|
||||
}
|
||||
if (!m_zero_epsilon && curr_lower != nullptr) {
|
||||
|
@ -1252,13 +1252,13 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
nm().set(delta, min);
|
||||
nm().mul(delta, m_epsilon, delta);
|
||||
nm().add(curr_lower->value(), delta, delta);
|
||||
TRACE("subpaving_relevant_bound_bug",
|
||||
TRACE(subpaving_relevant_bound_bug,
|
||||
tout << "k: "; nm().display(tout, k);
|
||||
tout << ", delta: "; nm().display(tout, delta); tout << "\n";
|
||||
tout << "curr_lower: "; nm().display(tout, curr_lower->value());
|
||||
tout << ", min: "; nm().display(tout, min); tout << "\n";);
|
||||
if (nm().le(k, delta)) {
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound to at least ";
|
||||
TRACE(subpaving_relevant_bound, tout << "irrelevant because does not improve existing bound to at least ";
|
||||
nm().display(tout, delta); tout << "\n";);
|
||||
return false;
|
||||
}
|
||||
|
@ -1267,18 +1267,18 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
else {
|
||||
// If new bound triggers a conflict, then it is relevant.
|
||||
if (curr_lower && (nm().gt(curr_lower->value(), k) || ((open || curr_lower->is_open()) && nm().eq(k, curr_lower->value())))) {
|
||||
TRACE("subpaving_relevant_bound", tout << "relevant because triggers conflict.\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "relevant because triggers conflict.\n";);
|
||||
return true;
|
||||
}
|
||||
// If m_epsilon is zero, then bound is relevant only if it improves existing bound.
|
||||
if (m_zero_epsilon && curr_upper != nullptr && (nm().lt(curr_upper->value(), k) || ((curr_upper->is_open() || !open) && nm().eq(k, curr_upper->value())))) {
|
||||
// new upper bound does not improve existing bound
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound.\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "irrelevant because does not improve existing bound.\n";);
|
||||
return false;
|
||||
}
|
||||
if (curr_lower == nullptr && nm().lt(k, m_minus_max_bound)) {
|
||||
// new upper bound exceeds the -:max-bound threshold
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because exceeds -:max-bound threshold.\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "irrelevant because exceeds -:max-bound threshold.\n";);
|
||||
return false;
|
||||
}
|
||||
if (!m_zero_epsilon && curr_upper != nullptr) {
|
||||
|
@ -1303,13 +1303,13 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
nm().mul(delta, m_epsilon, delta);
|
||||
nm().sub(curr_upper->value(), delta, delta);
|
||||
if (nm().ge(k, delta)) {
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound to at least ";
|
||||
TRACE(subpaving_relevant_bound, tout << "irrelevant because does not improve existing bound to at least ";
|
||||
nm().display(tout, delta); tout << "\n";);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
TRACE("subpaving_relevant_bound", tout << "new bound is relevant\n";);
|
||||
TRACE(subpaving_relevant_bound, tout << "new bound is relevant\n";);
|
||||
return true;
|
||||
}
|
||||
catch (const typename C::exception &) {
|
||||
|
@ -1375,7 +1375,7 @@ lbool context_t<C>::value(ineq * t, node * n) {
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::propagate_clause(clause * c, node * n) {
|
||||
TRACE("propagate_clause", tout << "propagate using:\n"; display(tout, c); tout << "\n";);
|
||||
TRACE(propagate_clause, tout << "propagate using:\n"; display(tout, c); tout << "\n";);
|
||||
m_num_visited++;
|
||||
c->set_visited(m_timestamp);
|
||||
unsigned sz = c->size();
|
||||
|
@ -1399,7 +1399,7 @@ void context_t<C>::propagate_clause(clause * c, node * n) {
|
|||
j = 0;
|
||||
}
|
||||
ineq * a = (*c)[j];
|
||||
TRACE("propagate_clause", tout << "propagating inequality: "; display(tout, a); tout << "\n";);
|
||||
TRACE(propagate_clause, tout << "propagating inequality: "; display(tout, a); tout << "\n";);
|
||||
propagate_bound(a->x(), a->value(), a->is_lower(), a->is_open(), n, justification(c));
|
||||
// A clause can propagate only once.
|
||||
// So, we can safely set its timestamp again to avoid another useless visit.
|
||||
|
@ -1440,12 +1440,12 @@ void context_t<C>::propagate_polynomial(var x, node * n, var y) {
|
|||
}
|
||||
else {
|
||||
nm().set(a, p->a(i));
|
||||
TRACE("propagate_polynomial_bug", tout << "a: "; nm().display(tout, a); tout << "\n";);
|
||||
TRACE(propagate_polynomial_bug, tout << "a: "; nm().display(tout, a); tout << "\n";);
|
||||
}
|
||||
}
|
||||
TRACE("propagate_polynomial_bug", tout << "r before mul 1/a: "; im().display(tout, r); tout << "\n";);
|
||||
TRACE(propagate_polynomial_bug, tout << "r before mul 1/a: "; im().display(tout, r); tout << "\n";);
|
||||
im().div(r, a, r);
|
||||
TRACE("propagate_polynomial_bug", tout << "r after mul 1/a: "; im().display(tout, r); tout << "\n";);
|
||||
TRACE(propagate_polynomial_bug, tout << "r after mul 1/a: "; im().display(tout, r); tout << "\n";);
|
||||
// r contains the deduced bounds for y.
|
||||
}
|
||||
// r contains the deduced bounds for y.
|
||||
|
@ -1466,8 +1466,8 @@ void context_t<C>::propagate_polynomial(var x, node * n, var y) {
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::propagate_polynomial(var x, node * n) {
|
||||
TRACE("propagate_polynomial", tout << "propagate_polynomial: "; display(tout, x); tout << "\n";);
|
||||
TRACE("propagate_polynomial_detail", display_bounds(tout, n););
|
||||
TRACE(propagate_polynomial, tout << "propagate_polynomial: "; display(tout, x); tout << "\n";);
|
||||
TRACE(propagate_polynomial_detail, display_bounds(tout, n););
|
||||
SASSERT(is_polynomial(x));
|
||||
polynomial * p = get_polynomial(x);
|
||||
p->set_visited(m_timestamp);
|
||||
|
@ -1483,7 +1483,7 @@ void context_t<C>::propagate_polynomial(var x, node * n) {
|
|||
unbounded_var = y;
|
||||
}
|
||||
}
|
||||
TRACE("propagate_polynomial", tout << "unbounded_var: "; display(tout, unbounded_var); tout << "\n";);
|
||||
TRACE(propagate_polynomial, tout << "unbounded_var: "; display(tout, unbounded_var); tout << "\n";);
|
||||
|
||||
if (unbounded_var != null_var) {
|
||||
propagate_polynomial(x, n, unbounded_var);
|
||||
|
@ -1500,7 +1500,7 @@ void context_t<C>::propagate_polynomial(var x, node * n) {
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::propagate_monomial(var x, node * n) {
|
||||
TRACE("propagate_monomial", tout << "propagate_monomial: "; display(tout, x); tout << "\n";);
|
||||
TRACE(propagate_monomial, tout << "propagate_monomial: "; display(tout, x); tout << "\n";);
|
||||
SASSERT(is_monomial(x));
|
||||
SASSERT(!inconsistent(n));
|
||||
monomial * m = get_monomial(x);
|
||||
|
@ -1524,7 +1524,7 @@ void context_t<C>::propagate_monomial(var x, node * n) {
|
|||
found_unbounded = true;
|
||||
}
|
||||
}
|
||||
TRACE("propagate_monomial", tout << "found_zero: " << found_zero << ", found_unbounded: " << found_unbounded << "\n";);
|
||||
TRACE(propagate_monomial, tout << "found_zero: " << found_zero << ", found_unbounded: " << found_unbounded << "\n";);
|
||||
if (found_zero) {
|
||||
if (!is_zero(x, n)) {
|
||||
// x must be zero
|
||||
|
@ -1602,7 +1602,7 @@ void context_t<C>::propagate_monomial_upward(var x, node * n) {
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::propagate_monomial_downward(var x, node * n, unsigned j) {
|
||||
TRACE("propagate_monomial", tout << "propagate_monomial_downward: "; display(tout, x); tout << ", j: " << j << "\n";
|
||||
TRACE(propagate_monomial, tout << "propagate_monomial_downward: "; display(tout, x); tout << ", j: " << j << "\n";
|
||||
display(tout, get_monomial(x)); tout << "\n";);
|
||||
SASSERT(is_monomial(x));
|
||||
monomial * m = get_monomial(x);
|
||||
|
@ -1711,7 +1711,7 @@ void context_t<C>::propagate_def(var x, node * n) {
|
|||
template<typename C>
|
||||
void context_t<C>::propagate(node * n, bound * b) {
|
||||
var x = b->x();
|
||||
TRACE("subpaving_propagate", tout << "propagate: "; display(tout, b); tout << ", timestamp: " << b->timestamp() << "\n";);
|
||||
TRACE(subpaving_propagate, tout << "propagate: "; display(tout, b); tout << ", timestamp: " << b->timestamp() << "\n";);
|
||||
typename watch_list::const_iterator it = m_wlist[x].begin();
|
||||
typename watch_list::const_iterator end = m_wlist[x].end();
|
||||
for (; it != end; ++it) {
|
||||
|
@ -1787,14 +1787,14 @@ void context_t<C>::assert_units(node * n) {
|
|||
checkpoint();
|
||||
ineq * a = UNTAG(ineq*, *it);
|
||||
bool axiom = GET_TAG(*it) != 0;
|
||||
TRACE("subpaving_init", tout << "asserting: "; display(tout, a); tout << ", axiom: " << axiom << "\n";);
|
||||
TRACE(subpaving_init, tout << "asserting: "; display(tout, a); tout << ", axiom: " << axiom << "\n";);
|
||||
if (a->x() == null_var)
|
||||
continue;
|
||||
propagate_bound(a->x(), a->value(), a->is_lower(), a->is_open(), n, justification(axiom));
|
||||
if (inconsistent(n))
|
||||
break;
|
||||
}
|
||||
TRACE("subpaving_init", tout << "bounds after init\n"; display_bounds(tout, n););
|
||||
TRACE(subpaving_init, tout << "bounds after init\n"; display_bounds(tout, n););
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
@ -1806,11 +1806,11 @@ void context_t<C>::init() {
|
|||
m_root = mk_node();
|
||||
SASSERT(m_leaf_head == m_root);
|
||||
SASSERT(m_leaf_tail == m_root);
|
||||
TRACE("subpaving_init", display_constraints(tout););
|
||||
TRACE(subpaving_init, display_constraints(tout););
|
||||
assert_units(m_root);
|
||||
propagate_all_definitions(m_root);
|
||||
propagate(m_root);
|
||||
TRACE("subpaving_init", tout << "root bounds after propagation\n"; display_bounds(tout, m_root););
|
||||
TRACE(subpaving_init, tout << "root bounds after propagation\n"; display_bounds(tout, m_root););
|
||||
SASSERT(check_invariant());
|
||||
}
|
||||
|
||||
|
@ -1818,8 +1818,8 @@ template<typename C>
|
|||
void context_t<C>::operator()() {
|
||||
if (m_root == nullptr)
|
||||
init();
|
||||
TRACE("subpaving_stats", statistics st; collect_statistics(st); tout << "statistics:\n"; st.display_smt2(tout););
|
||||
TRACE("subpaving_main", display_params(tout););
|
||||
TRACE(subpaving_stats, statistics st; collect_statistics(st); tout << "statistics:\n"; st.display_smt2(tout););
|
||||
TRACE(subpaving_main, display_params(tout););
|
||||
while (m_leaf_head != nullptr) {
|
||||
checkpoint();
|
||||
SASSERT(m_queue.empty());
|
||||
|
@ -1828,32 +1828,32 @@ void context_t<C>::operator()() {
|
|||
node * n = (*m_node_selector)(m_leaf_head, m_leaf_tail);
|
||||
if (n == nullptr)
|
||||
break;
|
||||
TRACE("subpaving_main", tout << "selected node: #" << n->id() << ", depth: " << n->depth() << "\n";);
|
||||
TRACE(subpaving_main, tout << "selected node: #" << n->id() << ", depth: " << n->depth() << "\n";);
|
||||
remove_from_leaf_dlist(n);
|
||||
if (n != m_root) {
|
||||
add_recent_bounds(n);
|
||||
propagate(n);
|
||||
}
|
||||
TRACE("subpaving_main", tout << "node #" << n->id() << " after propagation\n";
|
||||
TRACE(subpaving_main, tout << "node #" << n->id() << " after propagation\n";
|
||||
display_bounds(tout, n););
|
||||
if (n->inconsistent()) {
|
||||
TRACE("subpaving_main", tout << "node #" << n->id() << " is inconsistent.\n";);
|
||||
TRACE(subpaving_main, tout << "node #" << n->id() << " is inconsistent.\n";);
|
||||
// TODO: conflict resolution
|
||||
continue;
|
||||
}
|
||||
if (n->depth() >= m_max_depth) {
|
||||
TRACE("subpaving_main", tout << "maximum depth reached, skipping node #" << n->id() << "\n";);
|
||||
TRACE(subpaving_main, tout << "maximum depth reached, skipping node #" << n->id() << "\n";);
|
||||
continue;
|
||||
}
|
||||
var x = (*m_var_selector)(n);
|
||||
TRACE("subpaving_main", tout << "splitting variable: "; display(tout, x); tout << "\n";);
|
||||
TRACE(subpaving_main, tout << "splitting variable: "; display(tout, x); tout << "\n";);
|
||||
if (x != null_var) {
|
||||
(*m_node_splitter)(n, x);
|
||||
m_num_splits++;
|
||||
// remove inconsistent children
|
||||
}
|
||||
}
|
||||
TRACE("subpaving_stats", statistics st; collect_statistics(st); tout << "statistics:\n"; st.display_smt2(tout););
|
||||
TRACE(subpaving_stats, statistics st; collect_statistics(st); tout << "statistics:\n"; st.display_smt2(tout););
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
|
|
@ -154,7 +154,7 @@ class subpaving_tactic : public tactic {
|
|||
m_qm.div(k, n, k);
|
||||
if (is_neg(n))
|
||||
lower = !lower;
|
||||
TRACE("subpaving_tactic", tout << x << " " << k << " " << lower << " " << open << "\n";);
|
||||
TRACE(subpaving_tactic, tout << x << " " << k << " " << lower << " " << open << "\n";);
|
||||
return m_ctx->mk_ineq(x, k, lower, open);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue