mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 06:03:23 +00:00
cal modifications
This commit is contained in:
parent
dc5e532095
commit
3a68affb1b
2 changed files with 73 additions and 28 deletions
|
@ -211,30 +211,17 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class hilbert_basis::index {
|
class hilbert_basis::value_index {
|
||||||
// for each index, a heap of weights.
|
|
||||||
// for each weight a list of offsets
|
|
||||||
|
|
||||||
struct stats {
|
|
||||||
unsigned m_num_comparisons;
|
|
||||||
unsigned m_num_find;
|
|
||||||
unsigned m_num_insert;
|
|
||||||
stats() { reset(); }
|
|
||||||
void reset() { memset(this, 0, sizeof(*this)); }
|
|
||||||
};
|
|
||||||
|
|
||||||
hilbert_basis& hb;
|
hilbert_basis& hb;
|
||||||
|
ptr_vector<weight_map> m_values;
|
||||||
offset_refs_t m_refs;
|
offset_refs_t m_refs;
|
||||||
svector<offset_t> m_found;
|
svector<offset_t> m_found;
|
||||||
ptr_vector<weight_map> m_values;
|
|
||||||
weight_map m_weight;
|
weight_map m_weight;
|
||||||
stats m_stats;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
value_index(hilbert_basis& hb): hb(hb) {}
|
||||||
|
|
||||||
index(hilbert_basis& hb): hb(hb), m_weight(m_found, m_refs) {}
|
~value_index() {
|
||||||
|
|
||||||
~index() {
|
|
||||||
for (unsigned i = 0; i < m_values.size(); ++i) {
|
for (unsigned i = 0; i < m_values.size(); ++i) {
|
||||||
dealloc(m_values[i]);
|
dealloc(m_values[i]);
|
||||||
}
|
}
|
||||||
|
@ -250,22 +237,79 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(offset_t idx, values const& vs) {
|
void insert(offset_t idx, values const& vs) {
|
||||||
++m_stats.m_num_insert;
|
|
||||||
#if 0
|
|
||||||
for (unsigned i = 0; i < m_values.size(); ++i) {
|
for (unsigned i = 0; i < m_values.size(); ++i) {
|
||||||
m_values[i]->insert(idx, vs[i]);
|
m_values[i]->insert(idx, vs[i]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
m_weight.insert(idx, vs.value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(offset_t idx, values const& vs) {
|
void remove(offset_t idx, values const& vs) {
|
||||||
#if 0
|
|
||||||
for (unsigned i = 0; i < m_values.size(); ++i) {
|
for (unsigned i = 0; i < m_values.size(); ++i) {
|
||||||
m_values[i]->remove(idx, vs[i]);
|
m_values[i]->remove(idx, vs[i]);
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class hilbert_basis::index {
|
||||||
|
// for each index, a heap of weights.
|
||||||
|
// for each weight a list of offsets
|
||||||
|
|
||||||
|
struct stats {
|
||||||
|
unsigned m_num_comparisons;
|
||||||
|
unsigned m_num_find;
|
||||||
|
unsigned m_num_insert;
|
||||||
|
stats() { reset(); }
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
hilbert_basis& hb;
|
||||||
|
value_index m_values;
|
||||||
|
rational_map<value_index*> m_negative;
|
||||||
|
stats m_stats;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
index(hilbert_basis& hb):
|
||||||
|
hb(hb),
|
||||||
|
m_weight(m_found, m_refs),
|
||||||
|
m_values(hb) {}
|
||||||
|
|
||||||
|
~index() {
|
||||||
|
rational_map<weight_map*>::iterator it = m_negative.begin(), end = m_negative.end();
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
dealloc(it->m_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(unsigned num_vars) {
|
||||||
|
m_values.init(num_vars);
|
||||||
|
m_num_vars = num_vars;
|
||||||
|
SASSERT(m_negative.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert(offset_t idx, values const& vs) {
|
||||||
|
++m_stats.m_num_insert;
|
||||||
|
if (vs.value().is_neg()) {
|
||||||
|
weight_map* w = 0;
|
||||||
|
if (!m_negative.find(vs.value(), w)) {
|
||||||
|
w = alloc(weight_map, m_found, m_refs);
|
||||||
|
}
|
||||||
|
w->insert(idx, vs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_weight.insert(idx, vs.value());
|
||||||
|
m_values.insert(idx, vs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove(offset_t idx, values const& vs) {
|
||||||
|
if (vs.value().is_neg()) {
|
||||||
|
weight_map* w = m_negative.find(vs.value());
|
||||||
|
w->remove(idx, vs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
m_weight.remove(idx, vs.value());
|
m_weight.remove(idx, vs.value());
|
||||||
|
m_values.remove(idx, vs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool find(values const& vs, offset_t idx, offset_t& found_idx) {
|
bool find(values const& vs, offset_t idx, offset_t& found_idx) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
typedef vector<numeral> num_vector;
|
typedef vector<numeral> num_vector;
|
||||||
private:
|
private:
|
||||||
class rational_heap;
|
class rational_heap;
|
||||||
|
class value_index;
|
||||||
class index;
|
class index;
|
||||||
class passive;
|
class passive;
|
||||||
class weight_map;
|
class weight_map;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue