mirror of
https://github.com/Jaxan/hybrid-ads.git
synced 2025-04-27 15:07:45 +02:00
Adds more (useless?) statistics for analysing machines in stats.cpp
This commit is contained in:
parent
6863872218
commit
5faac3fef7
1 changed files with 91 additions and 7 deletions
|
@ -1,12 +1,17 @@
|
||||||
|
#include <adaptive_distinguishing_sequence.hpp>
|
||||||
#include <mealy.hpp>
|
#include <mealy.hpp>
|
||||||
#include <read_mealy.hpp>
|
|
||||||
#include <reachability.hpp>
|
#include <reachability.hpp>
|
||||||
|
#include <read_mealy.hpp>
|
||||||
|
#include <separating_family.hpp>
|
||||||
|
#include <splitting_tree.hpp>
|
||||||
#include <transfer_sequences.hpp>
|
#include <transfer_sequences.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <future>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -43,8 +48,8 @@ void print_quantiles(C const & container, S && selector, ostream & out) {
|
||||||
|
|
||||||
static auto count_self_loops(mealy const & m) {
|
static auto count_self_loops(mealy const & m) {
|
||||||
vector<long> ret(m.graph_size);
|
vector<long> ret(m.graph_size);
|
||||||
for(state s = 0; s < m.graph_size; ++s){
|
for (state s = 0; s < m.graph_size; ++s) {
|
||||||
ret[s] = count_if(m.graph[s].begin(), m.graph[s].end(), [=](auto e){ return e.to == s; });
|
ret[s] = count_if(m.graph[s].begin(), m.graph[s].end(), [=](auto e) { return e.to == s; });
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -69,14 +74,93 @@ static void print_stats_for_machine(string filename) {
|
||||||
const auto reachable_machine = reachable_submachine(machine, 0);
|
const auto reachable_machine = reachable_submachine(machine, 0);
|
||||||
cout << '\t' << reachable_machine.graph_size << " reachable states" << endl;
|
cout << '\t' << reachable_machine.graph_size << " reachable states" << endl;
|
||||||
|
|
||||||
auto prefixes = create_transfer_sequences(reachable_machine, 0);
|
const auto prefixes = create_transfer_sequences(reachable_machine, 0);
|
||||||
cout << "prefixes ";
|
cout << "prefixes ";
|
||||||
print_quantiles(prefixes, [](auto const & l){ return l.size(); }, cout);
|
print_quantiles(prefixes, [](auto const & l) { return l.size(); }, cout);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
auto self_loop_counts = count_self_loops(reachable_machine);
|
const auto self_loop_counts = count_self_loops(reachable_machine);
|
||||||
cout << "self loops ";
|
cout << "self loops ";
|
||||||
print_quantiles(self_loop_counts, [](auto const & l){ return l; }, cout);
|
print_quantiles(self_loop_counts, [](auto const & l) { return l; }, cout);
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
const auto counted_outputs = [&] {
|
||||||
|
vector<unsigned> counts(reachable_machine.input_size, 0);
|
||||||
|
for (auto && r : reachable_machine.graph)
|
||||||
|
for (auto && e : r) counts[e.out]++;
|
||||||
|
return counts;
|
||||||
|
}();
|
||||||
|
cout << "output usage ";
|
||||||
|
print_quantiles(counted_outputs, [](auto const & l) { return l; }, cout);
|
||||||
|
cout << endl;
|
||||||
|
{
|
||||||
|
ofstream extended_log("extended_log.txt");
|
||||||
|
for(auto && x : counted_outputs) extended_log << x << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto counted_states = [&] {
|
||||||
|
vector<unsigned> counts(reachable_machine.graph_size, 0);
|
||||||
|
for (auto && r : reachable_machine.graph)
|
||||||
|
for (auto && e : r) counts[e.to]++;
|
||||||
|
return counts;
|
||||||
|
}();
|
||||||
|
cout << "state usage ";
|
||||||
|
print_quantiles(counted_states, [](auto const & l) { return l; }, cout);
|
||||||
|
cout << endl;
|
||||||
|
{
|
||||||
|
ofstream extended_log("extended_log2.txt");
|
||||||
|
for(auto && x : counted_states) extended_log << x << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto unique_transitions = [&] {
|
||||||
|
vector<unsigned> ret(reachable_machine.input_size+1, 0);
|
||||||
|
for (state s = 0; s < reachable_machine.graph_size; ++s) {
|
||||||
|
unsigned count = 0;
|
||||||
|
vector<bool> c(reachable_machine.graph_size, false);
|
||||||
|
for (auto && x : reachable_machine.graph[s]) {
|
||||||
|
if(!c[x.to]) {
|
||||||
|
c[x.to] = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret[count]++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}();
|
||||||
|
cout << "transition usage ";
|
||||||
|
print_quantiles(unique_transitions, [](auto const & l) { return l; }, cout);
|
||||||
|
cout << endl;
|
||||||
|
{
|
||||||
|
ofstream extended_log("extended_log3.txt");
|
||||||
|
for (auto && x : unique_transitions) extended_log << x << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
random_device rd;
|
||||||
|
uint_fast32_t seeds[] = {rd(), rd()};
|
||||||
|
auto sequence_fut = async([&] {
|
||||||
|
const auto tree = create_splitting_tree(machine, randomized_lee_yannakakis_style, seeds[0]);
|
||||||
|
return create_adaptive_distinguishing_sequence(tree);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto pairs_fut = async([&] {
|
||||||
|
const auto tree = create_splitting_tree(machine, randomized_min_hopcroft_style, seeds[1]);
|
||||||
|
return tree.root;
|
||||||
|
});
|
||||||
|
|
||||||
|
const auto suffixes = create_separating_family(sequence_fut.get(), pairs_fut.get());
|
||||||
|
|
||||||
|
cout << "number of suffixes (randomized) ";
|
||||||
|
print_quantiles(suffixes, [](auto const & l) { return l.local_suffixes.size(); }, cout);
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
vector<word> all_suffixes;
|
||||||
|
for (auto const & s : suffixes)
|
||||||
|
for (auto const & t : s.local_suffixes) all_suffixes.push_back(t);
|
||||||
|
|
||||||
|
cout << "length of all suffixes (randomized) ";
|
||||||
|
print_quantiles(all_suffixes, [](auto const & l) { return l.size(); }, cout);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue