Commit 53a4dff4 authored by Gijs van Cuyck's avatar Gijs van Cuyck

minor bugfixes

parent b406c5d1
......@@ -52,9 +52,8 @@ void rst_to_stream(readable_splitting_tree & tree, std::ostream & output, int id
std::string indentations(ident,'\t');
std::vector<std::vector<state>> reverse_valid_map;
if(tree.children.size()>1)
{
reverse_valid_map = create_reverse_map(const_cast<std::unordered_map<state,size_t>& >(tree.valid_map),tree.children.size());
}
reverse_valid_map = create_reverse_map(tree.valid_map,tree.children.size());
output << indentations << "{" << join(tree.states.begin(),tree.states.end(),",","}") << "\n";
for(int i =0; i<tree.children.size(); i++)
......
......@@ -63,7 +63,7 @@ result create_splitting_tree(const mealy & g, options opt, uint_fast32_t random_
for (auto && b : new_blocks) {
boom.children.back()[i++].states.assign(begin(b), end(b));
}
for (auto & c : boom.children.back()) {
for (auto && c : boom.children.back()) {
work_set new_work_set = work_set(c,valid_list);
work_list.push(new_work_set);
}
......@@ -116,6 +116,8 @@ result create_splitting_tree(const mealy & g, options opt, uint_fast32_t random_
work_list.pop();
//the state for which the current tree prioritizes validity.
//if there is no preference then the first one in the list is chosen.
//used when selecting a seperator from multiple options.
//The preference is the one which is valid for valid_target, if it exists.
state valid_target =0;
if(valid_set.size()>0)
valid_target = *valid_set.begin();
......@@ -159,15 +161,17 @@ result create_splitting_tree(const mealy & g, options opt, uint_fast32_t random_
successor_states[apply(g, state, symbol).to] = true;
}
state valid_target_image = apply(g,valid_target,symbol).to;
const auto & oboom = lca(root, [&successor_states](state state) -> bool {
return successor_states[state];
},valid_target);
},valid_target_image);
// a leaf, hence not a split -> try other symbols
if (oboom.children.empty()) continue;
// possibly a succesful split, construct the children
const vector<input> word = concat(vector<input>(1, symbol), oboom.get_seperator(valid_target));
const vector<input> word = concat(vector<input>(1, symbol), oboom.get_seperator(valid_target_image));
const auto new_blocks = partition_(
begin(boom.states),
end(boom.states), [word, depth, &g, &update_succession](state state) {
......@@ -190,20 +194,23 @@ result create_splitting_tree(const mealy & g, options opt, uint_fast32_t random_
}
// We tried all we could, but did not succeed => declare incompleteness.
//has every element in work_list been checked without succes?
if (days_without_progress++ >= work_list.size()) {
if(split_on_output) {
//if we get here than we have check all possible inputs and none of them give a possible split on output.
//start checking for splits on state now instead.
//if we get here than we have checked all possible inputs and none of them give a valid split on output symbol.
//start checking for splits on output state now instead.
split_on_output = false;
days_without_progress = 0;
}
else {
// We tried all we could, but did not succeed => declare incompleteness.
//todo: code should never get here.
ret.is_complete = false;
return ret;
}
}
//no valid splits on the current work_set. put it back and try the next one.
work_list.push(work_set(boom,valid_set));
continue;
......
......@@ -42,33 +42,21 @@ static const char USAGE[] =
Options:
-h Show this screen
-v Show version
-m <arg> Operation mode: all, fixed, random
-p <arg> How to generate prefixes: minimal, lexmin, buggy, longest
-s <arg> How to generate suffixes: hsi, hads, none
-k <num> Number of extra states to check for (minus 1)
-r <num> Expected length of random infix word
-x <seed> 32 bits seeds for deterministic execution (0 is not valid)
-f <filename> Input filename ('-' or don't specify for stdin)
-o <filename> Output filename ('-' or don't specify for stdout)
-k <num> Number of extra states to check for (minus 1). currently not supported
-x <seed> 32 bits seeds for deterministic execution (0 is not valid). currently not supported
-f <filename> Input filename ('-' or don't specify for default example)
-o <filename> Output filename ('-' or don't specify for default output file)
)";
static const string output_directory = "../outputs/";
enum Mode { ALL, FIXED, RANDOM, WSET };
enum PrefixMode { MIN, LEXMIN, BUGGY, DFS };
enum SuffixMode { HSI, HADS, NOSUFFIX };
struct main_options {
bool help = false;
bool version = false;
Mode mode = ALL;
PrefixMode prefix_mode = MIN;
SuffixMode suffix_mode = HADS;
unsigned long k_max = 1; // 3 means 2 extra states
unsigned long rnd_length = 8; // in addition to k_max
unsigned long seed = 0; // 0 for unset/noise
unsigned long k_max = 1; // 3 means 2 extra states. currently not supported
unsigned long seed = 0; // 0 for unset/noise. currently not supported
string input_filename = "../examples/lee_yannakakis_distinguishable.dot";
string output_filename = "";
......@@ -77,16 +65,10 @@ struct main_options {
main_options parse_options(int argc, char ** argv) {
main_options opts;
static const map<string, Mode> mode_names = {
{"all", ALL}, {"fixed", FIXED}, {"random", RANDOM}, {"wset", WSET}};
static const map<string, PrefixMode> prefix_names = {
{"minimal", MIN}, {"lexmin", LEXMIN}, {"buggy", BUGGY}, {"longest", DFS}};
static const map<string, SuffixMode> suffix_names = {
{"hsi", HSI}, {"hads", HADS}, {"none", NOSUFFIX}};
try {
int c;
while ((c = getopt(argc, argv, "hvm:p:s:k:r:x:f:o:")) != -1) {
while ((c = getopt(argc, argv, "hvk:x:f:o:")) != -1) {
switch (c) {
case 'h': // show help message
opts.help = true;
......@@ -94,21 +76,9 @@ main_options parse_options(int argc, char ** argv) {
case 'v': // show version
opts.version = true;
break;
case 'm': // select operation mode
opts.mode = mode_names.at(optarg);
break;
case 'p': // select prefix mode
opts.prefix_mode = prefix_names.at(optarg);
break;
case 's': // select suffix mode
opts.suffix_mode = suffix_names.at(optarg);
break;
case 'k': // select extra states / k-value
opts.k_max = stoul(optarg);
break;
case 'r': // expected random length
opts.rnd_length = stoul(optarg);
break;
case 'x': // seed
opts.seed = stoul(optarg);
break;
......@@ -137,7 +107,7 @@ main_options parse_options(int argc, char ** argv) {
if(start == std::string::npos)
start = opts.input_filename.find_last_of('\\');
size_t end = opts.input_filename.find_last_of('.');
if(start >end-start || end == std::string::npos)
if(start >=end || end == std::string::npos)
opts.output_filename = output_directory + "default_output.txt";
else
opts.output_filename = output_directory + opts.input_filename.substr(start,end-start) + "_output.txt";
......@@ -161,15 +131,10 @@ int main(int argc, char * argv[]){
}
if (args.version) {
cout << "Version 2 (July 2017)" << endl;
cout << "Version 1 (October 2018)" << endl;
exit(0);
}
const bool no_suffix = args.suffix_mode == NOSUFFIX;
const bool use_distinguishing_sequence = args.suffix_mode == HADS;
const bool randomize_hopcroft = false;
const bool randomize_lee_yannakakis = false;
/*
* Then all the setup is done. Parsing the automaton,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment