autfilt: some cleanup around --are-isomorphic

* src/bin/autfilt.cc: Do not use -I for --are-isomorphic.
Fix --help.
* src/tgbatest/isomorph.test: Adjust to use --are-isomorphic, and speed
it up 5-fold.
This commit is contained in:
Alexandre Duret-Lutz 2014-12-10 17:02:50 +01:00
parent d033633be0
commit ff4dca48a5
2 changed files with 28 additions and 48 deletions

View file

@ -48,7 +48,7 @@
static const char argp_program_doc[] ="\ static const char argp_program_doc[] ="\
Convert, transform, and filter Büchi automata.\n\ Convert, transform, and filter Büchi automata.\v\
Exit status:\n\ Exit status:\n\
0 if some automata were output\n\ 0 if some automata were output\n\
1 if no automata were output (no match)\n\ 1 if no automata were output (no match)\n\
@ -118,8 +118,7 @@ static const argp_option options[] =
{ "%p", 0, 0, OPTION_DOC | OPTION_NO_USAGE, { "%p", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"1 if the output is complete, 0 otherwise", 0 }, "1 if the output is complete, 0 otherwise", 0 },
{ "%r", 0, 0, OPTION_DOC | OPTION_NO_USAGE, { "%r", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"conversion time (including post-processings, but not parsing)" "processing time (excluding parsing) in seconds", 0 },
" in seconds", 0 },
{ "%%", 0, 0, OPTION_DOC | OPTION_NO_USAGE, { "%%", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"a single %", 0 }, "a single %", 0 },
/**************************************************/ /**************************************************/
@ -132,10 +131,9 @@ static const argp_option options[] =
"randomize states and transitions (specify 's' or 't' to" "randomize states and transitions (specify 's' or 't' to"
"randomize only states or transitions)", 0 }, "randomize only states or transitions)", 0 },
/**************************************************/ /**************************************************/
{ 0, 0, 0, 0, "Filter:", -1 }, { 0, 0, 0, 0, "Filters:", 6 },
{ "are-isomorphic", 'I', "FILENAME", 0, { "are-isomorphic", OPT_ARE_ISOMORPHIC, "FILENAME", 0,
"print only the automata that are isomorph to the automaton "\ "keep automata that are isomorphic the automaton in FILENAME", 0 },
"described in FILENAME", 0 },
{ "isomorphic", 0, 0, OPTION_ALIAS | OPTION_HIDDEN, 0, 0 }, { "isomorphic", 0, 0, OPTION_ALIAS | OPTION_HIDDEN, 0, 0 },
/**************************************************/ /**************************************************/
{ 0, 0, 0, 0, "Miscellaneous options:", -1 }, { 0, 0, 0, 0, "Miscellaneous options:", -1 },
@ -177,24 +175,6 @@ to_int(const char* s)
return res; return res;
} }
// spot::tgba_digraph_ptr
// hoa_parse(const char* filename)
// {
// spot::hoa_parse_error_list pel;
// auto b = spot::make_bdd_dict();
// auto hp = spot::hoa_stream_parser(filename);
//
// pel.clear();
// auto haut = hp.parse(pel, b);
// if (!haut && pel.empty())
// error(2, 0, "no automaton to parse from %s", filename);
// if (spot::format_hoa_parse_errors(std::cerr, filename, pel))
// error(2, 0, "failed to parse automaton from %s", filename);;
// if (!haut)
// error(2, 0, "failed to read automaton from %s", filename);
// return haut->aut;
// }
static int static int
parse_opt(int key, char* arg, struct argp_state*) parse_opt(int key, char* arg, struct argp_state*)
{ {
@ -214,15 +194,6 @@ parse_opt(int key, char* arg, struct argp_state*)
format = Hoa; format = Hoa;
hoa_opt = arg; hoa_opt = arg;
break; break;
case 'I':
{
spot::hoa_parse_error_list pel;
auto p = hoa_parse(arg, pel, dict);
if (spot::format_hoa_parse_errors(std::cerr, arg, pel)
|| !p || p->aborted)
error(2, 0, "failed to read automaton from %s", arg);
opt_are_isomorphic = std::move(p->aut);
}
case 'M': case 'M':
type = spot::postprocessor::Monitor; type = spot::postprocessor::Monitor;
break; break;
@ -241,6 +212,16 @@ parse_opt(int key, char* arg, struct argp_state*)
case OPT_DOT: case OPT_DOT:
format = Dot; format = Dot;
break; break;
case OPT_ARE_ISOMORPHIC:
{
spot::hoa_parse_error_list pel;
auto p = hoa_parse(arg, pel, dict);
if (spot::format_hoa_parse_errors(std::cerr, arg, pel)
|| !p || p->aborted)
error(2, 0, "failed to read automaton from %s", arg);
opt_are_isomorphic = std::move(p->aut);
break;
}
case OPT_LBTT: case OPT_LBTT:
if (arg) if (arg)
{ {
@ -420,11 +401,7 @@ namespace
// Preprocessing. // Preprocessing.
if (opt_merge) if (opt_merge)
{
aut->merge_transitions(); aut->merge_transitions();
if (opt_are_isomorphic)
opt_are_isomorphic->merge_transitions();
}
// Filters. // Filters.
@ -533,6 +510,9 @@ main(int argc, char** argv)
if (jobs.empty()) if (jobs.empty())
jobs.emplace_back("-", true); jobs.emplace_back("-", true);
if (opt_are_isomorphic && opt_merge)
opt_are_isomorphic->merge_transitions();
spot::srand(opt_seed); spot::srand(opt_seed);
spot::postprocessor post(&extra_options); spot::postprocessor post(&extra_options);

View file

@ -18,17 +18,17 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. ./defs . ./defs
for i in `seq 0 4`; do set -e
for i in 0 1 2 3 4; do
../../bin/randaut a --seed=$i -S4 --hoa >iso$i ../../bin/randaut a --seed=$i -S4 --hoa >iso$i
../../bin/autfilt -F iso$i --randomize --hoa >aut$i ../../bin/autfilt iso$i --randomize --hoa >aut$i
done done
for i in `seq 0 4`; do cat aut0 aut1 aut2 aut3 aut4 > all
for j in `seq 0 4`; do (for i in 0 1 2 3 4; do
exp=$(test $i -eq $j; echo $?) run 0 ../../bin/autfilt all --are-isomorphic iso$i --hoa
run $exp ../../bin/autfilt -F aut$i -I iso$j done) > output
done diff all output
done