mirror of
https://github.com/Z3Prover/z3
synced 2025-08-29 22:40:08 +00:00
move some functionality from nla_solver to rooted_mons
Signed-off-by: Lev <levnach@hotmail.com>
This commit is contained in:
parent
b43a0e184c
commit
64a7231079
3 changed files with 69 additions and 55 deletions
|
@ -19,6 +19,7 @@
|
|||
--*/
|
||||
|
||||
#pragma once
|
||||
#include "util/lp/lp_utils.h"
|
||||
namespace nla {
|
||||
struct rooted_mon {
|
||||
svector<lpvar> m_vars;
|
||||
|
@ -84,5 +85,56 @@ struct rooted_mon_table {
|
|||
return m_rooted_monomials_containing_var;
|
||||
}
|
||||
|
||||
std::unordered_map<unsigned, std::unordered_set<unsigned>>& factor_to_product() {
|
||||
return m_rooted_factor_to_product;
|
||||
}
|
||||
|
||||
const std::unordered_map<unsigned, std::unordered_set<unsigned>>& factor_to_product() const {
|
||||
return m_rooted_factor_to_product;
|
||||
}
|
||||
|
||||
void reduce_set_by_checking_proper_containment(std::unordered_set<unsigned>& p,
|
||||
const rooted_mon & rm ) {
|
||||
for (auto it = p.begin(); it != p.end();) {
|
||||
if (lp::is_proper_factor(rm.m_vars, vec()[*it].m_vars)) {
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
auto iit = it;
|
||||
iit ++;
|
||||
p.erase(it);
|
||||
it = iit;
|
||||
}
|
||||
}
|
||||
|
||||
// here i is the index of a monomial in m_vector_of_rooted_monomials
|
||||
void find_rooted_monomials_containing_rm(unsigned i_rm) {
|
||||
const auto & rm = vec()[i_rm];
|
||||
|
||||
std::unordered_set<unsigned> p = var_map()[rm[0]];
|
||||
// TRACE("nla_solver",
|
||||
// tout << "i_rm = " << i_rm << ", rm = ";
|
||||
// print_rooted_monomial(rm, tout);
|
||||
// tout << "\n rm[0] =" << rm[0] << " var = ";
|
||||
// print_var(rm[0], tout);
|
||||
// tout << "\n";
|
||||
// trace_print_rms(p, tout);
|
||||
// );
|
||||
|
||||
|
||||
for (unsigned k = 1; k < rm.size(); k++) {
|
||||
intersect_set(p, var_map()[rm[k]]);
|
||||
}
|
||||
// TRACE("nla_solver", trace_print_rms(p, tout););
|
||||
reduce_set_by_checking_proper_containment(p, rm);
|
||||
// TRACE("nla_solver", trace_print_rms(p, tout););
|
||||
factor_to_product()[i_rm] = p;
|
||||
}
|
||||
|
||||
void fill_rooted_factor_to_product() {
|
||||
for (unsigned i = 0; i < vec().size(); i++) {
|
||||
find_rooted_monomials_containing_rm(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue