introduce count_univbranch_states() and count_univbranch_edges()
Fixes #368, suggested by František Blahoudek. * spot/twaalgos/isdet.cc, spot/twaalgos/isdet.hh (count_univbranch_states(), count_univbranch_edges()): New functions. * bin/common_aoutput.cc, bin/common_aoutput.hh: Add %u and variants. * NEWS: Mention these. * tests/core/alternating.test: Test them.
This commit is contained in:
parent
60296317c7
commit
29e08a1afb
6 changed files with 125 additions and 4 deletions
|
|
@ -218,6 +218,10 @@ static const argp_option io_options[] =
|
|||
"1 if the automaton is complete, 0 otherwise", 0 },
|
||||
{ "%r", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"wall-clock time elapsed in seconds (excluding parsing)", 0 },
|
||||
{ "%U, %u, %[LETTER]U, %[LETTER]u", 0, nullptr,
|
||||
OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the automaton contains some universal branching "
|
||||
"(or a number of [s]tates or [e]dges with universal branching)", 0 },
|
||||
{ "%W, %w", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"one word accepted by the automaton", 0 },
|
||||
{ "%X, %x, %[LETTERS]X, %[LETTERS]x", 0, nullptr,
|
||||
|
|
@ -272,6 +276,11 @@ static const argp_option o_options[] =
|
|||
"or (c) children processes.", 0 },
|
||||
{ "%n", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of nondeterministic states in output", 0 },
|
||||
{ "%u, %[LETTER]u", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the automaton contains some universal branching "
|
||||
"(or a number of [s]tates or [e]dges with universal branching)", 0 },
|
||||
{ "%u, %[e]u", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"number of states (or [e]dges) with universal branching", 0 },
|
||||
{ "%d", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"1 if the output is deterministic, 0 otherwise", 0 },
|
||||
{ "%p", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
|
|
@ -393,6 +402,7 @@ hoa_stat_printer::hoa_stat_printer(std::ostream& os, const char* format,
|
|||
declare('P', &haut_complete_);
|
||||
declare('S', &haut_states_);
|
||||
declare('T', &haut_trans_);
|
||||
declare('U', &haut_univbranch_);
|
||||
declare('W', &haut_word_);
|
||||
declare('X', &haut_ap_);
|
||||
}
|
||||
|
|
@ -406,6 +416,7 @@ hoa_stat_printer::hoa_stat_printer(std::ostream& os, const char* format,
|
|||
declare('f', &filename_); // Override the formula printer.
|
||||
declare('h', &output_aut_);
|
||||
declare('m', &aut_name_);
|
||||
declare('u', &aut_univbranch_);
|
||||
declare('w', &aut_word_);
|
||||
declare('x', &aut_ap_);
|
||||
}
|
||||
|
|
@ -478,6 +489,8 @@ hoa_stat_printer::print(const spot::const_parsed_aut_ptr& haut,
|
|||
// This is more efficient than calling count_nondet_state().
|
||||
haut_deterministic_ = is_deterministic(haut->aut);
|
||||
}
|
||||
if (has('U'))
|
||||
haut_univbranch_ = haut->aut;
|
||||
|
||||
if (has('P'))
|
||||
haut_complete_ = is_complete(haut->aut);
|
||||
|
|
@ -509,6 +522,8 @@ hoa_stat_printer::print(const spot::const_parsed_aut_ptr& haut,
|
|||
else
|
||||
aut_name_.val().clear();
|
||||
}
|
||||
if (has('u'))
|
||||
aut_univbranch_ = aut;
|
||||
if (has('w'))
|
||||
{
|
||||
if (auto word = aut->accepting_word())
|
||||
|
|
@ -532,6 +547,8 @@ hoa_stat_printer::print(const spot::const_parsed_aut_ptr& haut,
|
|||
output_aut_ = nullptr;
|
||||
input_aut_ = nullptr;
|
||||
haut_scc_.reset();
|
||||
aut_univbranch_ = nullptr;
|
||||
haut_univbranch_ = nullptr;
|
||||
aut_ap_.clear();
|
||||
haut_ap_.clear();
|
||||
return res;
|
||||
|
|
@ -661,6 +678,26 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
void printable_univbranch::print(std::ostream& os, const char* pos) const
|
||||
{
|
||||
std::string options = "l";
|
||||
if (pos[0] == '[' && pos[1] != ']')
|
||||
{
|
||||
if (pos[1] == 'e' && pos[2] == ']')
|
||||
{
|
||||
os << spot::count_univbranch_edges(val_);
|
||||
return;
|
||||
}
|
||||
else if (pos[1] == 's' && pos[2] == ']')
|
||||
{
|
||||
os << spot::count_univbranch_states(val_);
|
||||
return;
|
||||
}
|
||||
percent_error(pos, pos + 1);
|
||||
}
|
||||
os << (spot::count_univbranch_edges(val_) ? 1 : 0);
|
||||
}
|
||||
|
||||
void printable_timer::print(std::ostream& os, const char* pos) const
|
||||
{
|
||||
double res = 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014-2017 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2014-2018 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -74,6 +74,14 @@ struct printable_automaton final:
|
|||
void print(std::ostream& os, const char* pos) const override;
|
||||
};
|
||||
|
||||
struct printable_univbranch final:
|
||||
public spot::printable_value<spot::const_twa_graph_ptr>
|
||||
{
|
||||
using spot::printable_value<spot::const_twa_graph_ptr>::operator=;
|
||||
void print(std::ostream& os, const char* pos) const override;
|
||||
};
|
||||
|
||||
|
||||
struct printable_timer final: public spot::printable
|
||||
{
|
||||
protected:
|
||||
|
|
@ -169,6 +177,8 @@ private:
|
|||
spot::printable_value<unsigned> haut_complete_;
|
||||
spot::printable_value<const char*> csv_prefix_;
|
||||
spot::printable_value<const char*> csv_suffix_;
|
||||
printable_univbranch haut_univbranch_;
|
||||
printable_univbranch aut_univbranch_;
|
||||
printable_timer timer_;
|
||||
printable_automaton input_aut_;
|
||||
printable_automaton output_aut_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue