Add a way to count the number of sub-transitions.
* src/tgbaalgos/stats.hh (tgba_sub_statistics): New class. (sub_stats_reachable): New function. * src/tgbaalgos/stats.cc (sub_stats_bfs): New class. (tgba_sub_statistics::dump, sub_stats_reachable): New function. * src/tgbatest/ltl2tgba.cc (-kt): New option. * src/tgbatest/ltl2tgba.test: Use -kt.
This commit is contained in:
parent
91e51c4c3f
commit
30727074fd
5 changed files with 99 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2008 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2008, 2011 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -54,6 +54,49 @@ namespace spot
|
|||
private:
|
||||
tgba_statistics& s_;
|
||||
};
|
||||
|
||||
class sub_stats_bfs: public stats_bfs
|
||||
{
|
||||
public:
|
||||
sub_stats_bfs(const tgba* a, tgba_sub_statistics& s)
|
||||
: stats_bfs(a, s), s_(s), seen_(bddtrue)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
process_link(const state*, int, const state*, int,
|
||||
const tgba_succ_iterator* it)
|
||||
{
|
||||
++s_.transitions;
|
||||
|
||||
bdd cond = it->current_condition();
|
||||
bdd newvars = bdd_exist(bdd_support(cond), seen_);
|
||||
if (newvars != bddtrue)
|
||||
{
|
||||
seen_ &= newvars;
|
||||
int count = 0;
|
||||
while (newvars != bddtrue)
|
||||
{
|
||||
++count;
|
||||
newvars = bdd_high(newvars);
|
||||
}
|
||||
// If we discover one new variable, that means that all
|
||||
// transitions we counted so far are actually double
|
||||
// subtransitions. If we have two new variables, they where
|
||||
// quadruple transitions, etc.
|
||||
s_.sub_transitions <<= count;
|
||||
}
|
||||
while (cond != bddfalse)
|
||||
{
|
||||
cond -= bdd_satoneset(cond, seen_, bddtrue);
|
||||
++s_.sub_transitions;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
tgba_sub_statistics& s_;
|
||||
bdd seen_;
|
||||
};
|
||||
} // anonymous
|
||||
|
||||
|
||||
|
|
@ -64,12 +107,28 @@ namespace spot
|
|||
return out;
|
||||
}
|
||||
|
||||
std::ostream& tgba_sub_statistics::dump(std::ostream& out) const
|
||||
{
|
||||
out << "sub trans.: " << sub_transitions << std::endl;
|
||||
this->tgba_statistics::dump(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
tgba_statistics
|
||||
stats_reachable(const tgba* g)
|
||||
{
|
||||
tgba_statistics s = {0, 0};
|
||||
tgba_statistics s;
|
||||
stats_bfs d(g, s);
|
||||
d.run();
|
||||
return s;
|
||||
}
|
||||
|
||||
tgba_sub_statistics
|
||||
sub_stats_reachable(const tgba* g)
|
||||
{
|
||||
tgba_sub_statistics s;
|
||||
sub_stats_bfs d(g, s);
|
||||
d.run();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2008 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2008, 2011 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -38,11 +38,22 @@ namespace spot
|
|||
unsigned transitions;
|
||||
unsigned states;
|
||||
|
||||
tgba_statistics() { transitions = 0; states = 0; }
|
||||
std::ostream& dump(std::ostream& out) const;
|
||||
};
|
||||
|
||||
struct tgba_sub_statistics: public tgba_statistics
|
||||
{
|
||||
unsigned sub_transitions;
|
||||
|
||||
tgba_sub_statistics() { sub_transitions = 0; }
|
||||
std::ostream& dump(std::ostream& out) const;
|
||||
};
|
||||
|
||||
/// \brief Compute statistics for an automaton.
|
||||
tgba_statistics stats_reachable(const tgba* g);
|
||||
/// \brief Compute subended statistics for an automaton.
|
||||
tgba_sub_statistics sub_stats_reachable(const tgba* g);
|
||||
|
||||
/// @}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue