diff --git a/lib/characterization_family.cpp b/lib/characterization_family.cpp index 747733a..0b39f36 100644 --- a/lib/characterization_family.cpp +++ b/lib/characterization_family.cpp @@ -11,13 +11,12 @@ using namespace std; characterization_family create_seperating_family(const adaptive_distinguishing_sequence & sequence, - const separating_matrix & sep_matrix) { + const splitting_tree & separating_sequences) { const auto N = sequence.CI.size(); vector suffixes(N); 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. If we encouter a set of states which is not a singleton, we add // sequences from the matrix, locally and globally. @@ -36,18 +35,24 @@ characterization_family create_seperating_family(const adaptive_distinguishing_s suffixes[state].insert(word); } - trie all_global_separating_words; - + // for each distinct pair, look up the lca in the splitting tree and add that word. + // This gives a very bad complexity! (cubic I guess) + // I believe this can be fixed to quadratic for (auto && p : node.CI) { for (auto && q : node.CI) { const auto s = p.second; const auto t = q.second; - if (s == t) continue; + if (s <= t) continue; - const auto & sep_word = sep_matrix[s][t]; + vector states(N, false); + states[s] = states[t] = true; + + const auto root = lca(separating_sequences, + [&states](auto z) -> bool { return states[z]; }); + const auto & sep_word = root.seperator; suffixes[s].insert(sep_word); - all_global_separating_words.insert(sep_word); + suffixes[t].insert(sep_word); } } @@ -56,14 +61,8 @@ characterization_family create_seperating_family(const adaptive_distinguishing_s const auto s = p.second; auto & current_suffixes = suffixes[s]; - // local suffixes are done by now + // they are the same (FIXME) 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(); } diff --git a/lib/characterization_family.hpp b/lib/characterization_family.hpp index 0eeb326..e15efbe 100644 --- a/lib/characterization_family.hpp +++ b/lib/characterization_family.hpp @@ -26,4 +26,4 @@ using characterization_family = std::vector; /// \brief Creates the characterization family from the results of the LY algorithm /// If the sequence is complete, we do not need the separating_matrix characterization_family create_seperating_family(const adaptive_distinguishing_sequence & sequence, - const separating_matrix & sep_matrix); + const splitting_tree & separating_sequences); diff --git a/src/main.cpp b/src/main.cpp index ecc3370..6124860 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,12 +64,8 @@ int main(int argc, char *argv[]) try { return create_splitting_tree(machine, randomize_hopcroft ? randomized_hopcroft_style : hopcroft_style); }(); - const auto all_pair_seperating_sequences_ = [&]{ - time_logger t("gathering all seperating sequences"); - return create_all_pair_seperating_sequences(splitting_tree_hopcroft.root); - }(); - return all_pair_seperating_sequences_; + return splitting_tree_hopcroft.root; }(); auto sequence = [&]{ diff --git a/src/methods.cpp b/src/methods.cpp index 667eac8..251e763 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -44,7 +44,7 @@ int main(int argc, char * argv[]) { auto pairs_fut = async([&] { const auto tree = create_splitting_tree(machine, randomized_min_hopcroft_style); - return create_all_pair_seperating_sequences(tree.root); + return tree.root; }); auto prefixes_fut = async([&] {