mirror of
https://github.com/Jaxan/hybrid-ads.git
synced 2025-04-27 15:07:45 +02:00
Adds plain txt support to the important executables
This commit is contained in:
parent
52da35f494
commit
da393cc19f
3 changed files with 46 additions and 55 deletions
67
src/main.cpp
67
src/main.cpp
|
@ -3,6 +3,7 @@
|
|||
#include <mealy.hpp>
|
||||
#include <reachability.hpp>
|
||||
#include <read_mealy_from_dot.hpp>
|
||||
#include <read_mealy_from_txt.hpp>
|
||||
#include <characterization_family.hpp>
|
||||
#include <separating_matrix.hpp>
|
||||
#include <splitting_tree.hpp>
|
||||
|
@ -18,7 +19,10 @@ using namespace std;
|
|||
using time_logger = silent_timer;
|
||||
|
||||
int main(int argc, char *argv[]) try {
|
||||
if(argc != 4) return 1;
|
||||
if(argc != 4) {
|
||||
cerr << "usage: main <filename> <max k> <stream|stop>" << endl;
|
||||
return 1;
|
||||
}
|
||||
const string filename = argv[1];
|
||||
const bool use_stdio = filename == "--";
|
||||
|
||||
|
@ -39,9 +43,17 @@ int main(int argc, char *argv[]) try {
|
|||
time_logger t("reading file " + filename);
|
||||
if(use_stdio){
|
||||
return read_mealy_from_dot(cin);
|
||||
} else {
|
||||
}
|
||||
if(filename.find(".txt") != string::npos) {
|
||||
const auto m = read_mealy_from_txt(filename);
|
||||
const auto t = create_translation_for_mealy(m);
|
||||
return make_pair(move(m), move(t));
|
||||
} else if (filename.find(".dot") != string::npos) {
|
||||
return read_mealy_from_dot(filename);
|
||||
}
|
||||
|
||||
clog << "warning: unrecognized file format, assuming .dot\n";
|
||||
return read_mealy_from_dot(filename);
|
||||
}();
|
||||
|
||||
const auto & machine = reachable_submachine(move(machine_and_translation.first), 0);
|
||||
|
@ -127,59 +139,12 @@ int main(int argc, char *argv[]) try {
|
|||
for(auto && x : w) cout << inputs[x] << ' ';
|
||||
};
|
||||
|
||||
// This part is commented out, as the polymorphic lambdas are kinda important
|
||||
#if 0
|
||||
if(statistics){
|
||||
const auto adder = [](auto const & x){
|
||||
return [&x](auto const & l, auto const & r) { return l + x(r); };
|
||||
};
|
||||
|
||||
const auto size = adder([](auto const & r) { return r.size(); });
|
||||
|
||||
const auto p_size = transfer_sequences.size();
|
||||
const auto p_total = accumulate(begin(transfer_sequences), end(transfer_sequences), 0, size);
|
||||
const auto p_avg = p_total / double(p_size);
|
||||
|
||||
cout << "Prefixes:\n";
|
||||
cout << "\tsize\t" << p_size << '\n';
|
||||
cout << "\ttotal\t" << p_total << '\n';
|
||||
cout << "\tavg\t" << p_avg << '\n';
|
||||
|
||||
const auto w_fam_size = seperating_family.size();
|
||||
const auto w_fam_total = accumulate(begin(seperating_family), end(seperating_family), 0, size);
|
||||
const auto w_fam_avg = w_fam_total / double(w_fam_size);
|
||||
|
||||
const auto w_total = accumulate(begin(seperating_family), end(seperating_family), 0, adder([&size](auto const & r){
|
||||
return accumulate(begin(r), end(r), 0, size);
|
||||
}));
|
||||
const auto w_avg = w_total / double(w_fam_total);
|
||||
|
||||
cout << "Suffixes:\n";
|
||||
cout << "\tsize\t" << w_fam_total << '\n';
|
||||
cout << "\tavg\t" << w_fam_avg << '\n';
|
||||
cout << "\ttotal\t" << w_total << '\n';
|
||||
cout << "\tavg\t" << w_avg << '\n';
|
||||
|
||||
cout << "Total tests (approximately):\n";
|
||||
double total = machine.graph_size * 1 * w_fam_avg;
|
||||
double length = p_avg + 0 + w_avg;
|
||||
for(size_t k = 0; k <= k_max; ++k){
|
||||
cout << "\tk = " << k << "\t"
|
||||
<< setw(16) << size_t(total) << " * "
|
||||
<< setw(3) << size_t(length) << " = "
|
||||
<< setw(20) << size_t(total * length) << endl;
|
||||
total *= machine.input_size;
|
||||
length += 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(streaming){
|
||||
time_logger t("outputting all preset tests");
|
||||
|
||||
vector<word> all_sequences(1);
|
||||
for(size_t k = 0; k <= k_max; ++k){
|
||||
cerr << "*** K = " << k << endl;
|
||||
clog << "*** K = " << k << endl;
|
||||
for(state s = 0; s < machine.graph_size; ++s){
|
||||
const auto prefix = transfer_sequences[s];
|
||||
|
||||
|
@ -199,7 +164,7 @@ int main(int argc, char *argv[]) try {
|
|||
|
||||
if(random_part){
|
||||
time_logger t("outputting all random tests");
|
||||
cerr << "*** K > " << k_max << endl;
|
||||
clog << "*** K > " << k_max << endl;
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 generator(rd());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <adaptive_distinguishing_sequence.hpp>
|
||||
#include <read_mealy_from_dot.hpp>
|
||||
#include <read_mealy_from_txt.hpp>
|
||||
#include <characterization_family.hpp>
|
||||
#include <separating_matrix.hpp>
|
||||
#include <trie.hpp>
|
||||
|
@ -13,14 +14,26 @@
|
|||
using namespace std;
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
if (argc != 4) return 1;
|
||||
if (argc != 4) {
|
||||
cerr << "usage: methods <file> <mode> <k_max>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const string filename = argv[1];
|
||||
const string mode = argv[2];
|
||||
const bool use_no_LY = mode == "--W-method";
|
||||
const size_t k_max = std::stoul(argv[3]);
|
||||
|
||||
const auto machine = read_mealy_from_dot(filename).first;
|
||||
const auto machine = [&]{
|
||||
if (filename.find(".txt") != string::npos) {
|
||||
return read_mealy_from_txt(filename);
|
||||
} else if (filename.find(".dot") != string::npos) {
|
||||
return read_mealy_from_dot(filename).first;
|
||||
}
|
||||
|
||||
clog << "warning: unrecognized file format, assuming dot";
|
||||
return read_mealy_from_dot(filename).first;
|
||||
}();
|
||||
|
||||
auto sequence_fut = async([&] {
|
||||
if (use_no_LY) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <mealy.hpp>
|
||||
#include <read_mealy_from_dot.hpp>
|
||||
#include <read_mealy_from_txt.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
@ -9,7 +10,16 @@
|
|||
using namespace std;
|
||||
|
||||
static void print_stats_for_machine(string filename){
|
||||
const auto machine = read_mealy_from_dot(filename).first;
|
||||
const auto machine = [&]{
|
||||
if (filename.find(".txt") != string::npos) {
|
||||
return read_mealy_from_txt(filename);
|
||||
} else if (filename.find(".dot") != string::npos) {
|
||||
return read_mealy_from_dot(filename).first;
|
||||
}
|
||||
|
||||
clog << "warning: unrecognized file format, assuming dot";
|
||||
return read_mealy_from_dot(filename).first;
|
||||
}();
|
||||
|
||||
cout << "machine " << filename << " has\n";
|
||||
cout << '\t' << machine.graph_size << " states\n";
|
||||
|
@ -18,7 +28,10 @@ static void print_stats_for_machine(string filename){
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
if(argc != 2) return 37;
|
||||
if(argc != 2) {
|
||||
cerr << "usages: stats <filename>" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const string filename = argv[1];
|
||||
print_stats_for_machine(filename);
|
||||
|
|
Loading…
Add table
Reference in a new issue