bin: factor output options of autfilt and randaut
* src/bin/autfilt.cc: Move output options handling... * src/bin/common_aoutput.cc, src/bin/common_aoutput.hh:... here. * src/bin/randaut.cc: Use them. * src/tgbatest/randaut.test: Test --name and --stats for randaut.
This commit is contained in:
parent
3f4b19142d
commit
72737dfefc
5 changed files with 329 additions and 265 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
// Copyright (C) 2013, 2014, 2015 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -39,7 +39,6 @@
|
|||
#include "tgbaalgos/isdet.hh"
|
||||
#include "tgbaalgos/stutterize.hh"
|
||||
#include "tgbaalgos/closure.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
#include "misc/optionmap.hh"
|
||||
#include "misc/timer.hh"
|
||||
#include "misc/random.hh"
|
||||
|
|
@ -58,25 +57,20 @@ Exit status:\n\
|
|||
|
||||
|
||||
#define OPT_TGBA 1
|
||||
#define OPT_DOT 2
|
||||
#define OPT_LBTT 3
|
||||
#define OPT_SPOT 4
|
||||
#define OPT_STATS 5
|
||||
#define OPT_RANDOMIZE 6
|
||||
#define OPT_SEED 7
|
||||
#define OPT_PRODUCT 8
|
||||
#define OPT_MERGE 9
|
||||
#define OPT_ARE_ISOMORPHIC 10
|
||||
#define OPT_IS_COMPLETE 11
|
||||
#define OPT_IS_DETERMINISTIC 12
|
||||
#define OPT_STATES 17
|
||||
#define OPT_COUNT 18
|
||||
#define OPT_NAME 19
|
||||
#define OPT_EDGES 20
|
||||
#define OPT_ACC_SETS 21
|
||||
#define OPT_DESTUT 22
|
||||
#define OPT_INSTUT 23
|
||||
#define OPT_IS_EMPTY 24
|
||||
#define OPT_RANDOMIZE 2
|
||||
#define OPT_SEED 3
|
||||
#define OPT_PRODUCT 4
|
||||
#define OPT_MERGE 5
|
||||
#define OPT_ARE_ISOMORPHIC 6
|
||||
#define OPT_IS_COMPLETE 7
|
||||
#define OPT_IS_DETERMINISTIC 8
|
||||
#define OPT_STATES 9
|
||||
#define OPT_COUNT 10
|
||||
#define OPT_EDGES 11
|
||||
#define OPT_ACC_SETS 12
|
||||
#define OPT_DESTUT 13
|
||||
#define OPT_INSTUT 14
|
||||
#define OPT_IS_EMPTY 15
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
|
|
@ -92,62 +86,8 @@ static const argp_option options[] =
|
|||
{ "monitor", 'M', 0, 0, "Monitor (accepts all finite prefixes "
|
||||
"of the given property)", 0 },
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "Output format:", 3 },
|
||||
{ "count", 'c', 0, 0, "print only a count of matched automata", 0 },
|
||||
{ "dot", OPT_DOT, "c|h|n|N|t|v", OPTION_ARG_OPTIONAL,
|
||||
"GraphViz's format (default). Add letters to chose (c) circular nodes, "
|
||||
"(h) horizontal layout, (v) vertical layout, (n) with name, "
|
||||
"(N) without name, (t) always transition-based acceptance.", 0 },
|
||||
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
||||
"Output the automaton in HOA format. Add letters to select "
|
||||
"(s) state-based acceptance, (t) transition-based acceptance, "
|
||||
"(m) mixed acceptance, (l) single-line output", 0 },
|
||||
{ "lbtt", OPT_LBTT, "t", OPTION_ARG_OPTIONAL,
|
||||
"LBTT's format (add =t to force transition-based acceptance even"
|
||||
" on Büchi automata)", 0 },
|
||||
{ "max-count", 'n', "NUM", 0,
|
||||
"output at most NUM automata", 0 },
|
||||
{ "name", OPT_NAME, "FORMAT", OPTION_ARG_OPTIONAL,
|
||||
"set the name of the output automaton (default: %M)", 0 },
|
||||
{ "quiet", 'q', 0, 0, "suppress all normal output", 0 },
|
||||
{ "spin", 's', 0, 0, "Spin neverclaim (implies --ba)", 0 },
|
||||
{ "spot", OPT_SPOT, 0, 0, "SPOT's format", 0 },
|
||||
{ "utf8", '8', 0, 0, "enable UTF-8 characters in output "
|
||||
"(ignored with --lbtt or --spin)", 0 },
|
||||
{ "stats", OPT_STATS, "FORMAT", 0,
|
||||
"output statistics about the automaton", 0 },
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "The FORMAT string passed to --stats may use "\
|
||||
"the following interpreted sequences (capitals for input,"
|
||||
" minuscules for output):", 4 },
|
||||
{ "%F", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"name of the input file", 0 },
|
||||
{ "%L", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"location in the input file", 0 },
|
||||
{ "%M, %m", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"name of the automaton (as specified in the HOA format)", 0 },
|
||||
{ "%S, %s", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of states", 0 },
|
||||
{ "%E, %e", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of edges", 0 },
|
||||
{ "%T, %t", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of transitions", 0 },
|
||||
{ "%A, %a", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of acceptance pairs or sets", 0 },
|
||||
{ "%C, %c", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of SCCs", 0 },
|
||||
{ "%n", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of nondeterministic states in output", 0 },
|
||||
{ "%d", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is deterministic, 0 otherwise", 0 },
|
||||
{ "%p", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is complete, 0 otherwise", 0 },
|
||||
{ "%r", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"processing time (excluding parsing) in seconds", 0 },
|
||||
{ "%w", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"one word accepted by the output automaton", 0 },
|
||||
{ "%%", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
{ "count", 'c', 0, 0, "print only a count of matched automata", 3 },
|
||||
{ "max-count", 'n', "NUM", 0, "output at most NUM automata", 3 },
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "Transformations:", 5 },
|
||||
{ "merge-transitions", OPT_MERGE, 0, 0,
|
||||
|
|
@ -192,6 +132,8 @@ static const argp_option options[] =
|
|||
|
||||
static const struct argp_child children[] =
|
||||
{
|
||||
{ &aoutput_argp, 0, 0, 0 },
|
||||
{ &aoutput_io_format_argp, 0, 0, 4 },
|
||||
{ &post_argp_disabled, 0, 0, 20 },
|
||||
{ &misc_argp, 0, 0, -1 },
|
||||
{ 0, 0, 0, 0 }
|
||||
|
|
@ -200,7 +142,6 @@ static const struct argp_child children[] =
|
|||
typedef spot::tgba_digraph::graph_t::trans_storage_t tr_t;
|
||||
typedef std::set<std::vector<tr_t>> unique_aut_t;
|
||||
static long int match_count = 0;
|
||||
static const char* stats = "";
|
||||
static spot::option_map extra_options;
|
||||
static bool randomize_st = false;
|
||||
static bool randomize_tr = false;
|
||||
|
|
@ -248,9 +189,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
// This switch is alphabetically-ordered.
|
||||
switch (key)
|
||||
{
|
||||
case '8':
|
||||
spot::enable_utf8();
|
||||
break;
|
||||
case 'B':
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
|
|
@ -260,24 +198,12 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
case 'F':
|
||||
jobs.emplace_back(arg, true);
|
||||
break;
|
||||
case 'H':
|
||||
automaton_format = Hoa;
|
||||
hoa_opt = arg;
|
||||
break;
|
||||
case 'M':
|
||||
type = spot::postprocessor::Monitor;
|
||||
break;
|
||||
case 'n':
|
||||
opt_max_count = to_pos_int(arg);
|
||||
break;
|
||||
case 'q':
|
||||
automaton_format = Quiet;
|
||||
break;
|
||||
case 's':
|
||||
automaton_format = Spin;
|
||||
if (type != spot::postprocessor::Monitor)
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
case 'u':
|
||||
opt_uniq =
|
||||
std::unique_ptr<unique_aut_t>(new std::set<std::vector<tr_t>>());
|
||||
|
|
@ -305,10 +231,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
opt_are_isomorphic = std::move(p->aut);
|
||||
break;
|
||||
}
|
||||
case OPT_DOT:
|
||||
automaton_format = Dot;
|
||||
opt_dot = arg;
|
||||
break;
|
||||
case OPT_EDGES:
|
||||
opt_edges = parse_range(arg, 0, std::numeric_limits<int>::max());
|
||||
break;
|
||||
|
|
@ -327,24 +249,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
case OPT_IS_EMPTY:
|
||||
opt_is_empty = true;
|
||||
break;
|
||||
case OPT_LBTT:
|
||||
if (arg)
|
||||
{
|
||||
if (arg[0] == 't' && arg[1] == 0)
|
||||
automaton_format = Lbtt_t;
|
||||
else
|
||||
error(2, 0, "unknown argument for --lbtt: '%s'", arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
automaton_format = Lbtt;
|
||||
}
|
||||
break;
|
||||
case OPT_NAME:
|
||||
if (arg)
|
||||
opt_name = arg;
|
||||
else
|
||||
opt_name = "%M";
|
||||
case OPT_MERGE:
|
||||
opt_merge = true;
|
||||
break;
|
||||
|
|
@ -387,18 +291,9 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
case OPT_SEED:
|
||||
opt_seed = to_int(arg);
|
||||
break;
|
||||
case OPT_SPOT:
|
||||
automaton_format = Spot;
|
||||
break;
|
||||
case OPT_STATES:
|
||||
opt_states = parse_range(arg, 0, std::numeric_limits<int>::max());
|
||||
break;
|
||||
case OPT_STATS:
|
||||
if (!*arg)
|
||||
error(2, 0, "empty format string for --stats");
|
||||
stats = arg;
|
||||
automaton_format = Stats;
|
||||
break;
|
||||
case OPT_TGBA:
|
||||
if (automaton_format == Spin)
|
||||
error(2, 0, "--spin and --tgba are incompatible");
|
||||
|
|
@ -425,7 +320,7 @@ namespace
|
|||
public:
|
||||
|
||||
hoa_processor(spot::postprocessor& post)
|
||||
: post(post), printer(stats)
|
||||
: post(post), printer(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -503,7 +398,7 @@ namespace
|
|||
return 0;
|
||||
}
|
||||
|
||||
printer.print(aut, filename, conversion_time, haut);
|
||||
printer.print(aut, filename, -1, conversion_time, haut);
|
||||
|
||||
if (opt_max_count >= 0 && match_count >= opt_max_count)
|
||||
abort_run = true;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
|
||||
// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -17,11 +17,15 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "common_sys.hh"
|
||||
#include "error.h"
|
||||
|
||||
#include "common_aoutput.hh"
|
||||
#include "common_post.hh"
|
||||
#include "common_cout.hh"
|
||||
|
||||
#include "tgba/bddprint.hh"
|
||||
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgbaalgos/lbtt.hh"
|
||||
#include "tgbaalgos/hoa.hh"
|
||||
|
|
@ -29,14 +33,191 @@
|
|||
#include "tgbaalgos/save.hh"
|
||||
|
||||
automaton_format_t automaton_format = Dot;
|
||||
const char* opt_dot = nullptr;
|
||||
const char* hoa_opt = nullptr;
|
||||
static const char* opt_dot = nullptr;
|
||||
static const char* hoa_opt = nullptr;
|
||||
const char* opt_name = nullptr;
|
||||
static const char* stats = "";
|
||||
|
||||
#define OPT_DOT 1
|
||||
#define OPT_LBTT 2
|
||||
#define OPT_SPOT 3
|
||||
#define OPT_STATS 4
|
||||
#define OPT_NAME 5
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "Output format:", 3 },
|
||||
{ "dot", OPT_DOT, "c|h|n|N|t|v", OPTION_ARG_OPTIONAL,
|
||||
"GraphViz's format (default). Add letters to chose (c) circular nodes, "
|
||||
"(h) horizontal layout, (v) vertical layout, (n) with name, "
|
||||
"(N) without name, (t) always transition-based acceptance.", 0 },
|
||||
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
||||
"Output the automaton in HOA format. Add letters to select "
|
||||
"(s) state-based acceptance, (t) transition-based acceptance, "
|
||||
"(m) mixed acceptance, (l) single-line output", 0 },
|
||||
{ "lbtt", OPT_LBTT, "t", OPTION_ARG_OPTIONAL,
|
||||
"LBTT's format (add =t to force transition-based acceptance even"
|
||||
" on Büchi automata)", 0 },
|
||||
{ "name", OPT_NAME, "FORMAT", OPTION_ARG_OPTIONAL,
|
||||
"set the name of the output automaton (default: %M)", 0 },
|
||||
{ "quiet", 'q', 0, 0, "suppress all normal output", 0 },
|
||||
{ "spin", 's', 0, 0, "Spin neverclaim (implies --ba)", 0 },
|
||||
{ "spot", OPT_SPOT, 0, 0, "SPOT's format", 0 },
|
||||
{ "utf8", '8', 0, 0, "enable UTF-8 characters in output "
|
||||
"(ignored with --lbtt or --spin)", 0 },
|
||||
{ "stats", OPT_STATS, "FORMAT", 0,
|
||||
"output statistics about the automaton", 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
const struct argp aoutput_argp = { options, parse_opt_aoutput, 0, 0, 0, 0, 0 };
|
||||
|
||||
// Those can be overridden by individual tools. E.g. randaut has no
|
||||
// notion of input file, so %F and %L represent something else.
|
||||
char F_doc[32] = "name of the input file";
|
||||
char L_doc[32] = "location in the input file";
|
||||
|
||||
static const argp_option io_options[] =
|
||||
{
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "The FORMAT string passed to --stats may use "\
|
||||
"the following interpreted sequences (capitals for input,"
|
||||
" minuscules for output):", 4 },
|
||||
{ "%F", 0, 0, OPTION_DOC | OPTION_NO_USAGE, F_doc, 0 },
|
||||
{ "%L", 0, 0, OPTION_DOC | OPTION_NO_USAGE, L_doc, 0 },
|
||||
{ "%M, %m", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"name of the automaton (as specified in the HOA format)", 0 },
|
||||
{ "%S, %s", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of states", 0 },
|
||||
{ "%E, %e", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of edges", 0 },
|
||||
{ "%T, %t", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of transitions", 0 },
|
||||
{ "%A, %a", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of acceptance pairs or sets", 0 },
|
||||
{ "%C, %c", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of SCCs", 0 },
|
||||
{ "%n", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of nondeterministic states in output", 0 },
|
||||
{ "%d", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is deterministic, 0 otherwise", 0 },
|
||||
{ "%p", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is complete, 0 otherwise", 0 },
|
||||
{ "%r", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"processing time (excluding any parsing) in seconds", 0 },
|
||||
{ "%w", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"one word accepted by the output automaton", 0 },
|
||||
{ "%%", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
const struct argp aoutput_io_format_argp = { io_options, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
static const argp_option o_options[] =
|
||||
{
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "The FORMAT string passed to --stats may use "\
|
||||
"the following interpreted sequences:", 4 },
|
||||
{ "%F", 0, 0, OPTION_DOC | OPTION_NO_USAGE, F_doc, 0 },
|
||||
{ "%L", 0, 0, OPTION_DOC | OPTION_NO_USAGE, L_doc, 0 },
|
||||
{ "%m", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "name of the automaton", 0 },
|
||||
{ "%s", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "number of states", 0 },
|
||||
{ "%e", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "number of edges", 0 },
|
||||
{ "%t", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "number of transitions", 0 },
|
||||
{ "%a", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of acceptance pairs or sets", 0 },
|
||||
{ "%c", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of SCCs", 0 },
|
||||
{ "%n", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of nondeterministic states in output", 0 },
|
||||
{ "%d", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is deterministic, 0 otherwise", 0 },
|
||||
{ "%p", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is complete, 0 otherwise", 0 },
|
||||
{ "%r", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"processing time (excluding any parsing) in seconds", 0 },
|
||||
{ "%w", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"one word accepted by the output automaton", 0 },
|
||||
{ "%%", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
const struct argp aoutput_o_format_argp = { o_options, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
int parse_opt_aoutput(int key, char* arg, struct argp_state*)
|
||||
{
|
||||
// This switch is alphabetically-ordered.
|
||||
switch (key)
|
||||
{
|
||||
case '8':
|
||||
spot::enable_utf8();
|
||||
break;
|
||||
case 'H':
|
||||
automaton_format = Hoa;
|
||||
hoa_opt = arg;
|
||||
break;
|
||||
case 'q':
|
||||
automaton_format = Quiet;
|
||||
break;
|
||||
case 's':
|
||||
automaton_format = Spin;
|
||||
if (type != spot::postprocessor::Monitor)
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
case OPT_DOT:
|
||||
automaton_format = Dot;
|
||||
opt_dot = arg;
|
||||
break;
|
||||
case OPT_LBTT:
|
||||
if (arg)
|
||||
{
|
||||
if (arg[0] == 't' && arg[1] == 0)
|
||||
automaton_format = Lbtt_t;
|
||||
else
|
||||
error(2, 0, "unknown argument for --lbtt: '%s'", arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
automaton_format = Lbtt;
|
||||
}
|
||||
break;
|
||||
case OPT_NAME:
|
||||
if (arg)
|
||||
opt_name = arg;
|
||||
else
|
||||
opt_name = "%M";
|
||||
break;
|
||||
case OPT_SPOT:
|
||||
automaton_format = Spot;
|
||||
break;
|
||||
case OPT_STATS:
|
||||
if (!*arg)
|
||||
error(2, 0, "empty format string for --stats");
|
||||
stats = arg;
|
||||
automaton_format = Stats;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
automaton_printer::automaton_printer(bool has_input)
|
||||
: statistics(std::cout, stats, has_input),
|
||||
namer(name, opt_name, has_input)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
automaton_printer::print(const spot::tgba_digraph_ptr& aut,
|
||||
// Input location for errors and statistics.
|
||||
const char* filename,
|
||||
int loc,
|
||||
// Time and input automaton for statistics
|
||||
double time,
|
||||
const spot::const_hoa_aut_ptr& haut)
|
||||
|
|
@ -45,7 +226,7 @@ automaton_printer::print(const spot::tgba_digraph_ptr& aut,
|
|||
if (opt_name)
|
||||
{
|
||||
name.str("");
|
||||
namer.print(haut, aut, filename, time);
|
||||
namer.print(haut, aut, filename, loc, time);
|
||||
aut->set_named_prop("automaton-name", new std::string(name.str()));
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +259,7 @@ automaton_printer::print(const spot::tgba_digraph_ptr& aut,
|
|||
spot::never_claim_reachable(std::cout, aut);
|
||||
break;
|
||||
case Stats:
|
||||
statistics.print(haut, aut, filename, time) << '\n';
|
||||
statistics.print(haut, aut, filename, loc, time) << '\n';
|
||||
break;
|
||||
}
|
||||
flush_cout();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -49,12 +49,21 @@ enum automaton_format_t {
|
|||
|
||||
// The format to use in output_automaton()
|
||||
extern automaton_format_t automaton_format;
|
||||
// Any option to pass to Dot
|
||||
extern const char* opt_dot;
|
||||
// Options to pass to the HOA printer
|
||||
extern const char* hoa_opt;
|
||||
// How to name the automaton
|
||||
// Set to the argument of --name, else nullptr.
|
||||
extern const char* opt_name;
|
||||
// Output options
|
||||
extern const struct argp aoutput_argp;
|
||||
|
||||
// help text for %F and %L
|
||||
extern char F_doc[32];
|
||||
extern char L_doc[32];
|
||||
|
||||
// FORMAT help text
|
||||
extern const struct argp aoutput_io_format_argp;
|
||||
extern const struct argp aoutput_o_format_argp;
|
||||
|
||||
// Parse output options
|
||||
int parse_opt_aoutput(int key, char* arg, struct argp_state* state);
|
||||
|
||||
/// \brief prints various statistics about a TGBA
|
||||
///
|
||||
|
|
@ -64,19 +73,23 @@ extern const char* opt_name;
|
|||
class hoa_stat_printer: protected spot::stat_printer
|
||||
{
|
||||
public:
|
||||
hoa_stat_printer(std::ostream& os, const char* format)
|
||||
hoa_stat_printer(std::ostream& os, const char* format,
|
||||
bool has_input = false)
|
||||
: spot::stat_printer(os, format)
|
||||
{
|
||||
declare('A', &haut_acc_);
|
||||
declare('C', &haut_scc_);
|
||||
declare('E', &haut_edges_);
|
||||
if (has_input)
|
||||
{
|
||||
declare('A', &haut_acc_);
|
||||
declare('C', &haut_scc_);
|
||||
declare('E', &haut_edges_);
|
||||
declare('M', &haut_name_);
|
||||
declare('S', &haut_states_);
|
||||
declare('T', &haut_trans_);
|
||||
}
|
||||
declare('F', &filename_);
|
||||
declare('L', &location_);
|
||||
declare('f', &filename_); // Override the formula printer.
|
||||
declare('L', &haut_loc_);
|
||||
declare('M', &haut_name_);
|
||||
declare('m', &aut_name_);
|
||||
declare('S', &haut_states_);
|
||||
declare('T', &haut_trans_);
|
||||
declare('w', &aut_word_);
|
||||
}
|
||||
|
||||
|
|
@ -87,32 +100,55 @@ public:
|
|||
std::ostream&
|
||||
print(const spot::const_hoa_aut_ptr& haut,
|
||||
const spot::const_tgba_digraph_ptr& aut,
|
||||
const char* filename, double run_time)
|
||||
const char* filename, int loc, double run_time)
|
||||
{
|
||||
filename_ = filename;
|
||||
haut_loc_ = haut->loc;
|
||||
if (loc >= 0 && has('L'))
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << loc;
|
||||
location_ = os.str();
|
||||
}
|
||||
if (haut)
|
||||
{
|
||||
if (loc < 0 && has('L'))
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << haut->loc;
|
||||
location_ = os.str();
|
||||
}
|
||||
|
||||
if (has('T'))
|
||||
{
|
||||
spot::tgba_sub_statistics s = sub_stats_reachable(haut->aut);
|
||||
haut_states_ = s.states;
|
||||
haut_edges_ = s.transitions;
|
||||
haut_trans_ = s.sub_transitions;
|
||||
}
|
||||
else if (has('E'))
|
||||
{
|
||||
spot::tgba_sub_statistics s = sub_stats_reachable(haut->aut);
|
||||
haut_states_ = s.states;
|
||||
haut_edges_ = s.transitions;
|
||||
}
|
||||
if (has('M'))
|
||||
{
|
||||
auto n = haut->aut->get_named_prop<std::string>("automaton-name");
|
||||
if (n)
|
||||
haut_name_ = *n;
|
||||
else
|
||||
haut_name_.val().clear();
|
||||
}
|
||||
if (has('S'))
|
||||
haut_states_ = haut->aut->num_states();
|
||||
|
||||
if (has('A'))
|
||||
haut_acc_ = haut->aut->acc().num_sets();
|
||||
|
||||
if (has('C'))
|
||||
haut_scc_ = spot::scc_info(haut->aut).scc_count();
|
||||
}
|
||||
|
||||
if (has('T'))
|
||||
{
|
||||
spot::tgba_sub_statistics s = sub_stats_reachable(haut->aut);
|
||||
haut_states_ = s.states;
|
||||
haut_edges_ = s.transitions;
|
||||
haut_trans_ = s.sub_transitions;
|
||||
}
|
||||
else if (has('E'))
|
||||
{
|
||||
spot::tgba_sub_statistics s = sub_stats_reachable(haut->aut);
|
||||
haut_states_ = s.states;
|
||||
haut_edges_ = s.transitions;
|
||||
}
|
||||
if (has('M'))
|
||||
{
|
||||
auto n = haut->aut->get_named_prop<std::string>("automaton-name");
|
||||
if (n)
|
||||
haut_name_ = *n;
|
||||
else
|
||||
haut_name_.val().clear();
|
||||
}
|
||||
if (has('m'))
|
||||
{
|
||||
auto n = aut->get_named_prop<std::string>("automaton-name");
|
||||
|
|
@ -121,17 +157,6 @@ public:
|
|||
else
|
||||
aut_name_.val().clear();
|
||||
}
|
||||
if (has('S'))
|
||||
{
|
||||
haut_states_ = haut->aut->num_states();
|
||||
}
|
||||
|
||||
if (has('A'))
|
||||
haut_acc_ = haut->aut->acc().num_sets();
|
||||
|
||||
if (has('C'))
|
||||
haut_scc_ = spot::scc_info(haut->aut).scc_count();
|
||||
|
||||
if (has('w'))
|
||||
{
|
||||
auto res = spot::couvreur99(aut)->check();
|
||||
|
|
@ -157,6 +182,7 @@ public:
|
|||
|
||||
private:
|
||||
spot::printable_value<const char*> filename_;
|
||||
spot::printable_value<std::string> location_;
|
||||
spot::printable_value<std::string> haut_name_;
|
||||
spot::printable_value<std::string> aut_name_;
|
||||
spot::printable_value<std::string> aut_word_;
|
||||
|
|
@ -165,7 +191,6 @@ private:
|
|||
spot::printable_value<unsigned> haut_trans_;
|
||||
spot::printable_value<unsigned> haut_acc_;
|
||||
spot::printable_value<unsigned> haut_scc_;
|
||||
spot::printable_value<spot::location> haut_loc_;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -177,15 +202,13 @@ class automaton_printer
|
|||
|
||||
public:
|
||||
|
||||
automaton_printer(const char* stats)
|
||||
: statistics(std::cout, stats), namer(name, opt_name)
|
||||
{
|
||||
}
|
||||
automaton_printer(bool has_input = false);
|
||||
|
||||
void
|
||||
print(const spot::tgba_digraph_ptr& aut,
|
||||
// Input location for errors and statistics.
|
||||
const char* filename = nullptr,
|
||||
int loc = -1,
|
||||
// Time and input automaton for statistics
|
||||
double time = 0.0,
|
||||
const spot::const_hoa_aut_ptr& haut = nullptr);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
|
||||
// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -30,15 +30,13 @@
|
|||
#include "common_setup.hh"
|
||||
#include "common_range.hh"
|
||||
#include "common_cout.hh"
|
||||
#include "common_aoutput.hh"
|
||||
|
||||
#include "ltlenv/defaultenv.hh"
|
||||
#include "misc/timer.hh"
|
||||
#include "misc/random.hh"
|
||||
|
||||
#include "tgba/bddprint.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgbaalgos/lbtt.hh"
|
||||
#include "tgbaalgos/hoa.hh"
|
||||
#include "tgbaalgos/neverclaim.hh"
|
||||
#include "tgbaalgos/randomgraph.hh"
|
||||
#include "tgbaalgos/canonicalize.hh"
|
||||
|
||||
|
|
@ -62,11 +60,8 @@ states, 1 to 3 acceptance sets, and three atomic propositions:\n\
|
|||
% randaut -n 3 --hoa -S5..10 -A1..3 3\n\
|
||||
";
|
||||
|
||||
#define OPT_TGBA 1
|
||||
#define OPT_DOT 2
|
||||
#define OPT_LBTT 3
|
||||
#define OPT_SEED 4
|
||||
#define OPT_STATE_ACC 5
|
||||
#define OPT_SEED 1
|
||||
#define OPT_STATE_ACC 2
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
|
|
@ -91,39 +86,25 @@ static const argp_option options[] =
|
|||
{ "state-acc", OPT_STATE_ACC, 0, 0, "use state-based acceptance", 0 },
|
||||
RANGE_DOC,
|
||||
/**************************************************/
|
||||
{ 0, 0, 0, 0, "Output format:", 3 },
|
||||
{ "dot", OPT_DOT, "c|h|n|N|t|v", OPTION_ARG_OPTIONAL,
|
||||
"GraphViz's format (default). Add letters to chose (c) circular nodes, "
|
||||
"(h) horizontal layout, (v) vertical layout, (n) with name, "
|
||||
"(N) without name, (t) always transition-based acceptance.", 0 },
|
||||
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
||||
"Output the automaton in HOA format. Add letters to select "
|
||||
"(s) state-based acceptance, (t) transition-based acceptance, "
|
||||
"(m) mixed acceptance, (l) single-line output", 0 },
|
||||
{ "lbtt", OPT_LBTT, "t", OPTION_ARG_OPTIONAL,
|
||||
"LBTT's format (add =t to force transition-based acceptance even"
|
||||
" on Büchi automata)", 0 },
|
||||
{ "spin", 's', 0, 0, "Spin neverclaim (implies --ba)", 0 },
|
||||
{ "utf8", '8', 0, 0, "enable UTF-8 characters in output "
|
||||
"(ignored with --lbtt or --spin)", 0 },
|
||||
{ 0, 0, 0, 0, "Miscellaneous options:", -1 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
static const struct argp_child children[] =
|
||||
{
|
||||
{ &aoutput_argp, 0, 0, 3 },
|
||||
{ &aoutput_o_format_argp, 0, 0, 4 },
|
||||
{ &misc_argp, 0, 0, -1 },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
typedef spot::tgba_digraph::graph_t::trans_storage_t tr_t;
|
||||
typedef std::set<std::vector<tr_t>> unique_aut_t;
|
||||
static enum output_format { Dot, Lbtt, Lbtt_t, Spin, Hoa } format = Dot;
|
||||
const char* opt_dot = nullptr;
|
||||
static const char* hoa_opt = 0;
|
||||
static spot::ltl::atomic_prop_set aprops;
|
||||
static bool ap_count_given = false;
|
||||
static int opt_seed = 0;
|
||||
static const char* opt_seed_str = "0";
|
||||
static int opt_automata = 1;
|
||||
static range opt_states = { 10, 10 };
|
||||
static float opt_density = 0.2;
|
||||
|
|
@ -195,17 +176,9 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
|||
case 'D':
|
||||
opt_deterministic = true;
|
||||
break;
|
||||
case 'H':
|
||||
format = Hoa;
|
||||
hoa_opt = arg;
|
||||
break;
|
||||
case 'n':
|
||||
opt_automata = to_int(arg);
|
||||
break;
|
||||
case 's':
|
||||
format = Spin;
|
||||
ba_options();
|
||||
break;
|
||||
case 'S':
|
||||
opt_states = parse_range(arg);
|
||||
if (opt_states.min > opt_states.max)
|
||||
|
|
@ -215,25 +188,9 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
|||
opt_uniq =
|
||||
std::unique_ptr<unique_aut_t>(new std::set<std::vector<tr_t>>());
|
||||
break;
|
||||
case OPT_DOT:
|
||||
format = Dot;
|
||||
opt_dot = arg;
|
||||
break;
|
||||
case OPT_LBTT:
|
||||
if (arg)
|
||||
{
|
||||
if (arg[0] == 't' && arg[1] == 0)
|
||||
format = Lbtt_t;
|
||||
else
|
||||
error(2, 0, "unknown argument for --lbtt: '%s'", arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
format = Lbtt;
|
||||
}
|
||||
break;
|
||||
case OPT_SEED:
|
||||
opt_seed = to_int(arg);
|
||||
opt_seed_str = arg;
|
||||
break;
|
||||
case OPT_STATE_ACC:
|
||||
opt_state_acc = true;
|
||||
|
|
@ -270,6 +227,8 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
|||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
strcpy(F_doc, "seed number");
|
||||
strcpy(L_doc, "automaton number");
|
||||
setup(argv);
|
||||
|
||||
const argp ap = { options, parse_opt, "N|PROP...", argp_program_doc,
|
||||
|
|
@ -284,7 +243,7 @@ main(int argc, char** argv)
|
|||
error(2, 0, "No atomic proposition supplied? Run '%s --help' for usage.",
|
||||
program_name);
|
||||
|
||||
if (format == Spin && opt_acc_sets.max > 1)
|
||||
if (automaton_format == Spin && opt_acc_sets.max > 1)
|
||||
error(2, 0, "--spin is incompatible with --acc-sets=%d..%d",
|
||||
opt_acc_sets.min, opt_acc_sets.max);
|
||||
if (ba_wanted && opt_acc_sets.min != 1 && opt_acc_sets.max != 1)
|
||||
|
|
@ -294,11 +253,18 @@ main(int argc, char** argv)
|
|||
spot::srand(opt_seed);
|
||||
auto d = spot::make_bdd_dict();
|
||||
|
||||
automaton_printer printer;
|
||||
|
||||
constexpr unsigned max_trials = 10000;
|
||||
unsigned trials = max_trials;
|
||||
|
||||
while (opt_automata)
|
||||
int automaton_num = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
spot::stopwatch sw;
|
||||
sw.start();
|
||||
|
||||
int size = opt_states.min;
|
||||
if (size != opt_states.max)
|
||||
size = spot::rrand(size, opt_states.max);
|
||||
|
|
@ -330,30 +296,13 @@ main(int argc, char** argv)
|
|||
trials = max_trials;
|
||||
}
|
||||
|
||||
if (opt_automata > 0)
|
||||
--opt_automata;
|
||||
auto runtime = sw.stop();
|
||||
|
||||
bool is_ba = accs == 0 || (accs == 1 && opt_state_acc);
|
||||
printer.print(aut, opt_seed_str, automaton_num, runtime, nullptr);
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case Dot:
|
||||
spot::dotty_reachable(std::cout, aut, is_ba, opt_dot);
|
||||
break;
|
||||
case Lbtt:
|
||||
spot::lbtt_reachable(std::cout, aut, is_ba);
|
||||
break;
|
||||
case Lbtt_t:
|
||||
spot::lbtt_reachable(std::cout, aut, false);
|
||||
break;
|
||||
case Hoa:
|
||||
spot::hoa_reachable(std::cout, aut, hoa_opt) << '\n';
|
||||
break;
|
||||
case Spin:
|
||||
spot::never_claim_reachable(std::cout, aut);
|
||||
break;
|
||||
}
|
||||
flush_cout();
|
||||
}
|
||||
++automaton_num;
|
||||
if (opt_automata > 0 && automaton_num >= opt_automata)
|
||||
break;
|
||||
}
|
||||
spot::ltl::destroy_atomic_prop_set(aprops);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2014 Laboratoire de Recherche et Développement de
|
||||
# l'Epita (LRDE).
|
||||
# Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement
|
||||
# de l'Epita (LRDE).
|
||||
#
|
||||
# This file is part of Spot, a model checking library.
|
||||
#
|
||||
|
|
@ -52,3 +52,19 @@ $randaut --states 10..20 2 -n 100 -H > aut.hoa
|
|||
a=`$autfilt --states=..14 -c <aut.hoa`
|
||||
b=`$autfilt aut.hoa --states=15.. -c`
|
||||
test `expr $a + $b` = 100
|
||||
|
||||
# The count of SCCs and edges might change if the
|
||||
# algorithm or its default values are changed. Do
|
||||
# not hesitate to adjust the expected values below.
|
||||
$randaut -n 5 --name='%F-%L-%s-%c-%e' -H a | grep '^name' >out
|
||||
cat >expected<<EOF
|
||||
name: "0-0-10-1-29"
|
||||
name: "0-1-10-1-30"
|
||||
name: "0-2-10-1-29"
|
||||
name: "0-3-10-3-24"
|
||||
name: "0-4-10-1-29"
|
||||
EOF
|
||||
diff out expected
|
||||
|
||||
$randaut -n 5 --stats='name: "%F-%L-%s-%c-%e"' a >out2
|
||||
diff out2 expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue