mirror of
https://github.com/Jaxan/hybrid-ads.git
synced 2025-04-27 15:07:45 +02:00
Fixes high memory usage (one part): global suffixes do not need to be super-global.
This commit is contained in:
parent
da393cc19f
commit
d81a4cb997
1 changed files with 23 additions and 25 deletions
|
@ -13,18 +13,14 @@ using namespace std;
|
|||
characterization_family create_seperating_family(const adaptive_distinguishing_sequence & sequence,
|
||||
const separating_matrix & sep_matrix) {
|
||||
const auto N = sequence.CI.size();
|
||||
// all words (global/local) for all states
|
||||
|
||||
vector<trie> suffixes(N);
|
||||
|
||||
// all global separating sequences, which we will add to a state in the end ...
|
||||
trie all_global_separating_words;
|
||||
|
||||
// ... to these particualr states
|
||||
vector<bool> state_needs_global_suffixes(N, false);
|
||||
characterization_family ret(N);
|
||||
|
||||
|
||||
// First we accumulate the kind-of-UIOs and the separating words we need. We will do this with a
|
||||
// breath first search.
|
||||
// breath first search. If we encouter a set of states which is not a singleton, we add
|
||||
// sequences from the matrix, locally and globally.
|
||||
stack<pair<word, reference_wrapper<const adaptive_distinguishing_sequence>>> work;
|
||||
work.push({{}, sequence});
|
||||
while (!work.empty()) {
|
||||
|
@ -40,6 +36,8 @@ characterization_family create_seperating_family(const adaptive_distinguishing_s
|
|||
suffixes[state].insert(word);
|
||||
}
|
||||
|
||||
trie all_global_separating_words;
|
||||
|
||||
for (auto && p : node.CI) {
|
||||
for (auto && q : node.CI) {
|
||||
const auto s = p.second;
|
||||
|
@ -50,10 +48,26 @@ characterization_family create_seperating_family(const adaptive_distinguishing_s
|
|||
|
||||
suffixes[s].insert(sep_word);
|
||||
all_global_separating_words.insert(sep_word);
|
||||
state_needs_global_suffixes[s] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Finalize the suffixes
|
||||
for (auto && p : node.CI) {
|
||||
const auto s = p.second;
|
||||
auto & current_suffixes = suffixes[s];
|
||||
|
||||
// local suffixes are done by now
|
||||
ret[s].local_suffixes = flatten(current_suffixes);
|
||||
|
||||
// add the global ones
|
||||
all_global_separating_words.for_each(
|
||||
[¤t_suffixes](auto w) { current_suffixes.insert(w); });
|
||||
|
||||
// and fix them
|
||||
ret[s].global_suffixes = flatten(current_suffixes);
|
||||
current_suffixes.clear();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -62,21 +76,5 @@ characterization_family create_seperating_family(const adaptive_distinguishing_s
|
|||
for (auto && c : node.children) work.push({word, c}); // and visit the children with word
|
||||
}
|
||||
|
||||
|
||||
// Then we flatten them into a characterization family.
|
||||
characterization_family ret(N);
|
||||
|
||||
for (state s = 0; s < N; ++s) {
|
||||
auto & current_suffixes = suffixes[s];
|
||||
ret[s].local_suffixes = flatten(current_suffixes);
|
||||
|
||||
if (state_needs_global_suffixes[s]) {
|
||||
all_global_separating_words.for_each(
|
||||
[¤t_suffixes](auto w) { current_suffixes.insert(w); });
|
||||
}
|
||||
|
||||
ret[s].global_suffixes = flatten(current_suffixes);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue