mirror of
https://github.com/Jaxan/hybrid-ads.git
synced 2025-04-28 07:27:45 +02:00
Removes assert in favor of exceptions. Removes code I do not use. Bug fix.
This commit is contained in:
parent
77695e8f22
commit
9d83501d69
2 changed files with 20 additions and 50 deletions
|
@ -1,13 +1,11 @@
|
||||||
#include "read_mealy_from_dot.hpp"
|
#include "read_mealy_from_dot.hpp"
|
||||||
#include "mealy.hpp"
|
#include "mealy.hpp"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -66,10 +64,10 @@ mealy read_mealy_from_dot(std::istream & in, translation & t){
|
||||||
m.input_size = t.max_input.base();
|
m.input_size = t.max_input.base();
|
||||||
m.output_size = t.max_output.base();
|
m.output_size = t.max_output.base();
|
||||||
|
|
||||||
assert(m.graph_size > 0);
|
if(m.graph_size == 0) throw runtime_error("Empty state set");
|
||||||
assert(m.input_size > 0);
|
if(m.input_size == 0) throw runtime_error("Empty input set");
|
||||||
assert(m.output_size > 0);
|
if(m.output_size == 0) throw runtime_error("Empty output set");
|
||||||
assert(is_complete(m));
|
if(!is_complete(m)) throw runtime_error("Partial machine");
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
56
src/main.cpp
56
src/main.cpp
|
@ -6,20 +6,17 @@
|
||||||
#include <seperating_matrix.hpp>
|
#include <seperating_matrix.hpp>
|
||||||
#include <splitting_tree.hpp>
|
#include <splitting_tree.hpp>
|
||||||
#include <transfer_sequences.hpp>
|
#include <transfer_sequences.hpp>
|
||||||
#include <partition.hpp>
|
|
||||||
|
|
||||||
#include <io.hpp>
|
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <numeric>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <numeric>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
using time_logger = silent_timer;
|
using time_logger = silent_timer;
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]) try {
|
||||||
if(argc != 4) return 1;
|
if(argc != 4) return 1;
|
||||||
const string filename = argv[1];
|
const string filename = argv[1];
|
||||||
const bool use_stdio = filename == "--";
|
const bool use_stdio = filename == "--";
|
||||||
|
@ -31,9 +28,9 @@ int main(int argc, char *argv[]){
|
||||||
const bool streaming = mode == "stream";
|
const bool streaming = mode == "stream";
|
||||||
const bool random_part = streaming;
|
const bool random_part = streaming;
|
||||||
const bool statistics = mode == "stats";
|
const bool statistics = mode == "stats";
|
||||||
const bool compress_suite = mode == "compr";
|
|
||||||
|
|
||||||
const bool use_relevances = true;
|
const bool use_distinguishing_sequence = true;
|
||||||
|
const bool use_relevances = false;
|
||||||
const bool randomize_prefixes = true;
|
const bool randomize_prefixes = true;
|
||||||
const bool randomize_hopcroft = true;
|
const bool randomize_hopcroft = true;
|
||||||
const bool randomize_lee_yannakakis = true;
|
const bool randomize_lee_yannakakis = true;
|
||||||
|
@ -65,14 +62,17 @@ int main(int argc, char *argv[]){
|
||||||
});
|
});
|
||||||
|
|
||||||
auto sequence_fut = async([&]{
|
auto sequence_fut = async([&]{
|
||||||
const auto splitting_tree = [&]{
|
const auto tree = [&]{
|
||||||
time_logger t("Lee & Yannakakis I");
|
time_logger t("Lee & Yannakakis I");
|
||||||
|
if(use_distinguishing_sequence)
|
||||||
return create_splitting_tree(machine, randomize_lee_yannakakis ? randomized_lee_yannakakis_style : lee_yannakakis_style);
|
return create_splitting_tree(machine, randomize_lee_yannakakis ? randomized_lee_yannakakis_style : lee_yannakakis_style);
|
||||||
|
else
|
||||||
|
return result(machine.graph_size);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto sequence = [&]{
|
const auto sequence = [&]{
|
||||||
time_logger t("Lee & Yannakakis II");
|
time_logger t("Lee & Yannakakis II");
|
||||||
return create_adaptive_distinguishing_sequence(splitting_tree);
|
return create_adaptive_distinguishing_sequence(tree);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
return sequence;
|
return sequence;
|
||||||
|
@ -199,13 +199,11 @@ int main(int argc, char *argv[]){
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 generator(rd());
|
std::mt19937 generator(rd());
|
||||||
|
|
||||||
uniform_int_distribution<size_t> prefix_selection(0, transfer_sequences.size());
|
uniform_int_distribution<size_t> prefix_selection(0, transfer_sequences.size()-1);
|
||||||
uniform_int_distribution<> unfair_coin(0, 2); // expected flips is p / (p-1)^2, where p is succes probability
|
uniform_int_distribution<> unfair_coin(0, 2); // expected flips is p / (p-1)^2, where p is succes probability
|
||||||
uniform_int_distribution<size_t> suffix_selection;
|
uniform_int_distribution<size_t> suffix_selection;
|
||||||
auto relevant_inputs = relevant_inputs_fut.get();
|
auto relevant_inputs = relevant_inputs_fut.get();
|
||||||
|
|
||||||
using params = uniform_int_distribution<size_t>::param_type;
|
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
state current_state = 0;
|
state current_state = 0;
|
||||||
|
|
||||||
|
@ -222,6 +220,7 @@ int main(int argc, char *argv[]){
|
||||||
if(minimal_size) minimal_size--;
|
if(minimal_size) minimal_size--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using params = uniform_int_distribution<size_t>::param_type;
|
||||||
const auto & suffixes = seperating_family[current_state.base()];
|
const auto & suffixes = seperating_family[current_state.base()];
|
||||||
const auto & s = suffixes[suffix_selection(generator, params{0, suffixes.size()-1})];
|
const auto & s = suffixes[suffix_selection(generator, params{0, suffixes.size()-1})];
|
||||||
|
|
||||||
|
@ -231,34 +230,7 @@ int main(int argc, char *argv[]){
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (exception const & e) {
|
||||||
if(compress_suite){
|
cerr << "Exception thrown: " << e.what() << endl;
|
||||||
time_logger t("making test suite");
|
return 1;
|
||||||
vector<word> suite;
|
|
||||||
|
|
||||||
for(state s = 0; s < machine.graph_size; ++s){
|
|
||||||
const auto prefix = transfer_sequences[s.base()];
|
|
||||||
|
|
||||||
for(auto && suffix : seperating_family[s.base()]){
|
|
||||||
suite.push_back(concat(prefix, suffix));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<vector<string>> real_suite(suite.size());
|
|
||||||
transform(suite.begin(), suite.end(), real_suite.begin(), [&inputs](auto const & seq){
|
|
||||||
vector<string> seq2(seq.size());
|
|
||||||
transform(seq.begin(), seq.end(), seq2.begin(), [&inputs](auto const & i){
|
|
||||||
return inputs[i.base()];
|
|
||||||
});
|
|
||||||
return seq2;
|
|
||||||
});
|
|
||||||
|
|
||||||
boost::iostreams::filtering_ostream compressed_stream;
|
|
||||||
compressed_stream.push(boost::iostreams::gzip_compressor());
|
|
||||||
compressed_stream.push(boost::iostreams::file_descriptor_sink(filename + "test_suite"));
|
|
||||||
|
|
||||||
boost::archive::text_oarchive archive(compressed_stream);
|
|
||||||
archive << real_suite;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue