powerset: rewrite using the tgba_digraph interface

Fixes #48.

* src/tgbaalgos/powerset.cc, src/tgbaalgos/powerset.hh: Here.
* src/tgbaalgos/minimize.cc: Adjust usage.
This commit is contained in:
Alexandre Duret-Lutz 2015-01-09 17:10:28 +01:00
parent d6ba00ffe1
commit eadcf95363
3 changed files with 14 additions and 26 deletions

View file

@ -254,12 +254,11 @@ namespace spot
// Iterate on each original state corresponding to start. // Iterate on each original state corresponding to start.
const power_map::power_state& ps = const power_map::power_state& ps =
pm.states_of(det_a->state_number(start)); pm.states_of(det_a->state_number(start));
for (auto& it: ps) for (auto& s: ps)
{ {
// Construct a product between LOOP_A and ORIG_A starting in // Construct a product between LOOP_A and ORIG_A starting in
// *IT. FIXME: This could be sped up a lot! // S. FIXME: This could be sped up a lot!
if (!product(loop_a, orig_a, 0U, if (!product(loop_a, orig_a, 0U, s)->is_empty())
orig_a->state_number(it))->is_empty())
{ {
accepting = true; accepting = true;
break; break;

View file

@ -41,7 +41,6 @@
namespace spot namespace spot
{ {
// FIXME: Redo this algorithm using the tgba_digraph interface.
tgba_digraph_ptr tgba_digraph_ptr
tgba_powerset(const const_tgba_digraph_ptr& aut, power_map& pm, bool merge) tgba_powerset(const const_tgba_digraph_ptr& aut, power_map& pm, bool merge)
{ {
@ -55,9 +54,7 @@ namespace spot
res->copy_ap_of(aut); res->copy_ap_of(aut);
{ {
power_state ps; power_state ps{aut->get_init_state_number()};
const state* s = pm.canonicalize(aut->get_init_state());
ps.insert(s);
todo.push_back(ps); todo.push_back(ps);
unsigned num = res->new_state(); unsigned num = res->new_state();
seen[ps] = num; seen[ps] = num;
@ -71,8 +68,8 @@ namespace spot
// Compute all variables occurring on outgoing arcs. // Compute all variables occurring on outgoing arcs.
bdd all_vars = bddtrue; bdd all_vars = bddtrue;
for (auto s: src) for (auto s: src)
for (auto i: aut->succ(s)) for (auto i: aut->out(s))
all_vars &= bdd_support(i->current_condition()); all_vars &= bdd_support(i.cond);
bdd all_conds = bddtrue; bdd all_conds = bddtrue;
// Iterate over all possible conditions // Iterate over all possible conditions
@ -84,13 +81,13 @@ namespace spot
// Construct the set of all states reachable via COND. // Construct the set of all states reachable via COND.
power_state dest; power_state dest;
for (auto s: src) for (auto s: src)
for (auto si: aut->succ(s)) for (auto si: aut->out(s))
if ((cond >> si->current_condition()) == bddtrue) if ((cond >> si.cond) == bddtrue)
dest.insert(pm.canonicalize(si->current_state())); dest.insert(si.dst);
if (dest.empty()) if (dest.empty())
continue; continue;
// Add that transition. // Add that transition.
power_set::const_iterator i = seen.find(dest); auto i = seen.find(dest);
int dest_num; int dest_num;
if (i != seen.end()) if (i != seen.end())
{ {
@ -204,8 +201,7 @@ namespace spot
{ {
// Check the product between LOOP_A, and ORIG_A starting // Check the product between LOOP_A, and ORIG_A starting
// in S. // in S.
if (!product(loop_a, ref_, if (!product(loop_a, ref_, loop_a_init, s)->is_empty())
loop_a_init, ref_->state_number(s))->is_empty())
{ {
accepting = true; accepting = true;
break; break;
@ -296,7 +292,7 @@ namespace spot
auto det = tgba_powerset(aut, pm, false); auto det = tgba_powerset(aut, pm, false);
if ((threshold_states > 0) if ((threshold_states > 0)
&& (pm.map_.size() > pm.states_.size() * threshold_states)) && (pm.map_.size() > aut->num_states() * threshold_states))
return nullptr; return nullptr;
if (fix_dba_acceptance(det, aut, pm, threshold_cycles)) if (fix_dba_acceptance(det, aut, pm, threshold_cycles))
return nullptr; return nullptr;

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2011, 2013, 2014 Laboratoire de Recherche et // Copyright (C) 2011, 2013, 2014, 2015 Laboratoire de Recherche et
// Développement de l'Epita. // Développement de l'Epita.
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6), // Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre // département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -32,7 +32,7 @@ namespace spot
struct SPOT_API power_map struct SPOT_API power_map
{ {
typedef std::set<const state*, state_ptr_less_than> power_state; typedef std::set<unsigned> power_state;
typedef std::map<unsigned, power_state> power_map_data; typedef std::map<unsigned, power_state> power_map_data;
const power_state& const power_state&
@ -41,14 +41,7 @@ namespace spot
return map_.at(s); return map_.at(s);
} }
const state*
canonicalize(const state* s)
{
return states_(s);
}
power_map_data map_; power_map_data map_;
state_unicity_table states_;
}; };