stats: speed up the computation of transitions
Juraj Major reported a case with 32 APs where ltlcross would take forever to gather statistics. It turns out that for each edge, twa_sub_statistics was enumerating all compatible assignments of 32 APs. This uses bdd_satcountset() instead, and also store the result in a long long to avoid overflows. * spot/twaalgos/stats.cc (twa_sub_statistics): Improve the code for counting transitions. * bin/common_aoutput.hh, bin/ltlcross.cc, spot/twaalgos/stats.hh: Store transition counts are long long. * tests/core/readsave.test: Add test case. * NEWS: Mention the bug.
This commit is contained in:
parent
4608d9a5b1
commit
d25fcb23eb
6 changed files with 45 additions and 21 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2008, 2011-2018 Laboratoire de Recherche et
|
||||
// Copyright (C) 2008, 2011-2018, 2020 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
|
||||
|
|
@ -64,7 +64,7 @@ namespace spot
|
|||
{
|
||||
public:
|
||||
sub_stats_bfs(const const_twa_ptr& a, twa_sub_statistics& s)
|
||||
: stats_bfs(a, s), s_(s), seen_(a->ap_vars())
|
||||
: stats_bfs(a, s), s_(s), apvars_(a->ap_vars())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -73,17 +73,12 @@ namespace spot
|
|||
const twa_succ_iterator* it) override
|
||||
{
|
||||
++s_.edges;
|
||||
bdd cond = it->cond();
|
||||
while (cond != bddfalse)
|
||||
{
|
||||
cond -= bdd_satoneset(cond, seen_, bddtrue);
|
||||
++s_.transitions;
|
||||
}
|
||||
s_.transitions += bdd_satcountset(it->cond(), apvars_);
|
||||
}
|
||||
|
||||
private:
|
||||
twa_sub_statistics& s_;
|
||||
bdd seen_;
|
||||
bdd apvars_;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -180,11 +175,7 @@ namespace spot
|
|||
[&s, &ge](bdd cond)
|
||||
{
|
||||
++s.edges;
|
||||
while (cond != bddfalse)
|
||||
{
|
||||
cond -= bdd_satoneset(cond, ge->ap_vars(), bddtrue);
|
||||
++s.transitions;
|
||||
}
|
||||
s.transitions += bdd_satcountset(cond, ge->ap_vars());
|
||||
});
|
||||
}
|
||||
return s;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2008, 2011-2017 Laboratoire de Recherche et
|
||||
// Copyright (C) 2008, 2011-2017, 2020 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
|
||||
|
|
@ -44,7 +44,7 @@ namespace spot
|
|||
|
||||
struct SPOT_API twa_sub_statistics: public twa_statistics
|
||||
{
|
||||
unsigned transitions;
|
||||
unsigned long long transitions;
|
||||
|
||||
twa_sub_statistics() { transitions = 0; }
|
||||
std::ostream& dump(std::ostream& out) const;
|
||||
|
|
@ -125,7 +125,7 @@ namespace spot
|
|||
printable_formula form_;
|
||||
printable_value<unsigned> states_;
|
||||
printable_value<unsigned> edges_;
|
||||
printable_value<unsigned> trans_;
|
||||
printable_value<unsigned long long> trans_;
|
||||
printable_value<unsigned> acc_;
|
||||
printable_scc_info scc_;
|
||||
printable_value<unsigned> nondetstates_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue