Use the count_state() function instead of stats_reachable().

* src/tgbaalgos/postproc.cc: Move the count_state() function...
* src/priv/countstates.cc, src/priv/countstates.hh: ... in these
new files.
* src/priv/Makefile.am: Add them.
* src/saba/sabacomplementtgba.cc, src/tgba/tgbakvcomplement.cc,
src/tgbaalgos/minimize.cc: Use count_states() instead of
stats_reachable().
This commit is contained in:
Alexandre Duret-Lutz 2013-07-10 07:57:24 +02:00
parent 43b3df0ef0
commit f00d97b4ba
7 changed files with 87 additions and 33 deletions

View file

@ -24,6 +24,7 @@ noinst_HEADERS = \
acccompl.hh \ acccompl.hh \
accconv.hh \ accconv.hh \
bddalloc.hh \ bddalloc.hh \
countstates.hh \
freelist.hh freelist.hh
noinst_LTLIBRARIES = libpriv.la noinst_LTLIBRARIES = libpriv.la
@ -31,6 +32,7 @@ libpriv_la_SOURCES = \
acccompl.cc \ acccompl.cc \
accconv.cc \ accconv.cc \
bddalloc.cc \ bddalloc.cc \
countstates.cc \
freelist.cc freelist.cc

41
src/priv/countstates.cc Normal file
View file

@ -0,0 +1,41 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// 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 "countstates.hh"
#include "tgba/tgbaexplicit.hh"
#include "tgbaalgos/stats.hh"
namespace spot
{
unsigned count_states(const tgba* a)
{
const sba_explicit_number* se =
dynamic_cast<const sba_explicit_number*>(a);
if (se)
return se->num_states();
const tgba_explicit_number* te =
dynamic_cast<const tgba_explicit_number*>(a);
if (te)
return te->num_states();
tgba_statistics st = stats_reachable(a);
return st.states;
}
}

29
src/priv/countstates.hh Normal file
View file

@ -0,0 +1,29 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SPOT_PRIV_COUNTSTATES_HH
# define SPOT_PRIV_COUNTSTATES_HH
namespace spot
{
class tgba;
unsigned count_states(const tgba* a);
}
#endif // SPOT_PRIV_COUNTSTATES_HH

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et // Copyright (C) 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche
// Développement de l'Epita (LRDE). // et Développement de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
// //
@ -28,7 +28,7 @@
#include "misc/hashfunc.hh" #include "misc/hashfunc.hh"
#include "ltlast/formula.hh" #include "ltlast/formula.hh"
#include "ltlast/constant.hh" #include "ltlast/constant.hh"
#include "tgbaalgos/stats.hh" #include "priv/countstates.hh"
#include "sabacomplementtgba.hh" #include "sabacomplementtgba.hh"
#include "explicitstateconjunction.hh" #include "explicitstateconjunction.hh"
@ -376,10 +376,7 @@ namespace spot
int v = get_dict() int v = get_dict()
->register_acceptance_variable(ltl::constant::true_instance(), this); ->register_acceptance_variable(ltl::constant::true_instance(), this);
the_acceptance_cond_ = bdd_ithvar(v); the_acceptance_cond_ = bdd_ithvar(v);
{ nb_states_ = count_states(automaton_);
spot::tgba_statistics a_size = spot::stats_reachable(automaton_);
nb_states_ = a_size.states;
}
} }
saba_complement_tgba::~saba_complement_tgba() saba_complement_tgba::~saba_complement_tgba()

View file

@ -29,7 +29,7 @@
#include "misc/hashfunc.hh" #include "misc/hashfunc.hh"
#include "ltlast/formula.hh" #include "ltlast/formula.hh"
#include "ltlast/constant.hh" #include "ltlast/constant.hh"
#include "tgbaalgos/stats.hh" #include "priv/countstates.hh"
namespace spot namespace spot
{ {
@ -601,10 +601,7 @@ namespace spot
int v = get_dict() int v = get_dict()
->register_acceptance_variable(ltl::constant::true_instance(), this); ->register_acceptance_variable(ltl::constant::true_instance(), this);
the_acceptance_cond_ = bdd_ithvar(v); the_acceptance_cond_ = bdd_ithvar(v);
{ nb_states_ = count_states(automaton_);
spot::tgba_statistics a_size = spot::stats_reachable(automaton_);
nb_states_ = a_size.states;
}
get_acc_list(); get_acc_list();
} }

View file

@ -1,5 +1,6 @@
// Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et Développement // -*- coding: utf-8 -*-
// de l'Epita (LRDE). // Copyright (C) 2010, 2011, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
// //
@ -45,7 +46,7 @@
#include "tgbaalgos/scc.hh" #include "tgbaalgos/scc.hh"
#include "tgbaalgos/ltl2tgba_fm.hh" #include "tgbaalgos/ltl2tgba_fm.hh"
#include "tgbaalgos/bfssteps.hh" #include "tgbaalgos/bfssteps.hh"
#include "tgbaalgos/stats.hh" #include "priv/countstates.hh"
namespace spot namespace spot
{ {
@ -535,7 +536,7 @@ namespace spot
// This corresponds to the algorithm in Fig. 1 of "Efficient // This corresponds to the algorithm in Fig. 1 of "Efficient
// minimization of deterministic weak omega-automata" written by // minimization of deterministic weak omega-automata" written by
// Christof Löding and published in Information Processing // Christof Löding and published in Information Processing
// Letters 79 (2001) pp 105--109. // Letters 79 (2001) pp 105--109.
// We also keep track of whether an SCC is useless // We also keep track of whether an SCC is useless
@ -554,7 +555,7 @@ namespace spot
unsigned k = (scc_count | 1) + 1; unsigned k = (scc_count | 1) + 1;
// SCC are numbered in topological order // SCC are numbered in topological order
// (but in the reverse order as Löding's) // (but in the reverse order as Löding's)
for (unsigned m = 0; m < scc_count; ++m) for (unsigned m = 0; m < scc_count; ++m)
{ {
bool is_useless = true; bool is_useless = true;
@ -628,8 +629,8 @@ namespace spot
if (reject_bigger) if (reject_bigger)
{ {
// Abort if min_aut_f has more states than aut_f. // Abort if min_aut_f has more states than aut_f.
tgba_statistics orig_size = stats_reachable(aut_f); unsigned orig_states = count_states(aut_f);
if (orig_size.states < min_aut_f->num_states()) if (orig_states < min_aut_f->num_states())
{ {
delete min_aut_f; delete min_aut_f;
return const_cast<tgba*>(aut_f); return const_cast<tgba*>(aut_f);

View file

@ -22,26 +22,13 @@
#include "simulation.hh" #include "simulation.hh"
#include "sccfilter.hh" #include "sccfilter.hh"
#include "degen.hh" #include "degen.hh"
#include "stats.hh"
#include "stripacc.hh" #include "stripacc.hh"
#include <cstdlib> #include <cstdlib>
#include "misc/optionmap.hh" #include "misc/optionmap.hh"
#include "priv/countstates.hh"
namespace spot namespace spot
{ {
unsigned count_states(const tgba* a)
{
const sba_explicit_number* se =
dynamic_cast<const sba_explicit_number*>(a);
if (se)
return se->num_states();
const tgba_explicit_number* te =
dynamic_cast<const tgba_explicit_number*>(a);
if (te)
return te->num_states();
tgba_statistics st = stats_reachable(a);
return st.states;
}
postprocessor::postprocessor(const option_map* opt) postprocessor::postprocessor(const option_map* opt)
: type_(TGBA), pref_(Small), level_(High), : type_(TGBA), pref_(Small), level_(High),