safra: Iterate on APs to compute successors

* spot/twaalgos/safra.cc, spot/twaalgos/safra.hh: Here.
This commit is contained in:
Alexandre Lewkowicz 2016-02-04 16:03:47 +01:00 committed by Alexandre Duret-Lutz
parent 8068cfad93
commit dbd7740874
2 changed files with 32 additions and 34 deletions

View file

@ -184,28 +184,28 @@ safra_state::find_scc_brace_id(unsigned scc_id, const scc_info& scc)
void void
safra_state::compute_succs(const const_twa_graph_ptr& aut, safra_state::compute_succs(const const_twa_graph_ptr& aut,
const std::vector<bdd_id_t>& bddnums,
std::unordered_map<bdd,
std::pair<unsigned, unsigned>,
bdd_hash>& deltas,
succs_t& res, succs_t& res,
const scc_info& scc, const scc_info& scc,
const std::map<int, bdd>& implications, const std::map<int, bdd>& implications,
const std::vector<bool>& is_connected, const std::vector<bool>& is_connected,
std::unordered_map<bdd, unsigned, bdd_hash>& bdd2num,
std::vector<bdd>& all_bdds,
bool scc_opt, bool scc_opt,
bool use_bisimulation) const bool use_bisimulation) const
{ {
// Given a bdd returns index of associated safra_state in res // Given a bdd returns index of associated safra_state in res
std::map<unsigned, unsigned> bdd2num; std::map<unsigned, unsigned> bdd_idx2node_idx;
for (auto& ap: all_bdds)
{
for (auto& node: nodes_) for (auto& node: nodes_)
{ {
for (auto& t: aut->out(node.first)) for (auto& t: aut->out(node.first))
{ {
// deltas precalculate all transitions in edge t if (!bdd_implies(ap, t.cond))
auto p = deltas[t.cond]; continue;
for (unsigned j = p.first; j < p.second; ++j) unsigned bdd_idx = bdd2num[ap];
{ auto i = bdd_idx2node_idx.insert(std::make_pair(bdd_idx,
auto i = bdd2num.insert(std::make_pair(bddnums[j], res.size())); res.size()));
unsigned idx; unsigned idx;
if (!i.second) if (!i.second)
// No new state added, so get pre-existing state whichi is an // No new state added, so get pre-existing state whichi is an
@ -215,8 +215,7 @@ safra_state::compute_succs(const const_twa_graph_ptr& aut,
{ {
// Each new node starts out with same number of nodes as src // Each new node starts out with same number of nodes as src
idx = res.size(); idx = res.size();
res.emplace_back(safra_state(nb_braces_.size()), res.emplace_back(safra_state(nb_braces_.size()), bdd_idx);
bddnums[j]);
} }
safra_state& ss = res[idx].first; safra_state& ss = res[idx].first;
// Check if we are leaving the SCC, if so we delete all the // Check if we are leaving the SCC, if so we delete all the
@ -254,7 +253,7 @@ safra_state::compute_succs(const const_twa_graph_ptr& aut,
tmp.ungreenify_last_brace(); tmp.ungreenify_last_brace();
s.first.color_ = tmp.finalize_construction(); s.first.color_ = tmp.finalize_construction();
} }
} }
void void
safra_state::merge_redundant_states(const std::map<int, bdd>& implications, safra_state::merge_redundant_states(const std::map<int, bdd>& implications,
@ -572,8 +571,8 @@ safra_state::compute_succs(const const_twa_graph_ptr& aut,
safra_state curr = todo.front(); safra_state curr = todo.front();
unsigned src_num = seen.find(curr)->second; unsigned src_num = seen.find(curr)->second;
todo.pop_front(); todo.pop_front();
curr.compute_succs(aut, bddnums, deltas, succs, scc, implications, curr.compute_succs(aut, succs, scc, implications, is_connected,
is_connected, scc_opt, use_bisimulation); bdd2num, num2bdd, scc_opt, use_bisimulation);
for (auto s: succs) for (auto s: succs)
{ {
auto i = seen.find(s.first); auto i = seen.find(s.first);

View file

@ -54,17 +54,16 @@ namespace spot
bool acceptance_scc = false); bool acceptance_scc = false);
// Given a certain transition_label, compute all the successors of that // Given a certain transition_label, compute all the successors of that
// label, and return that new node. // label, and return that new node.
void compute_succs(const const_twa_graph_ptr& aut, void
const std::vector<bdd_id_t>& bddnums, compute_succs(const const_twa_graph_ptr& aut,
std::unordered_map<bdd,
std::pair<unsigned, unsigned>,
bdd_hash>& deltas,
succs_t& res, succs_t& res,
const scc_info& scc, const scc_info& scc,
const std::map<int, bdd>& implications, const std::map<int, bdd>& implications,
const std::vector<bool>& is_connected, const std::vector<bool>& is_connected,
bool scc_opt = false, std::unordered_map<bdd, unsigned, bdd_hash>& bdd2num,
bool use_bisimulation = false) const; std::vector<bdd>& all_bdds,
bool scc_opt,
bool use_bisimulation) const;
// scc_id has to be an accepting SCC. This function tries to find a node // scc_id has to be an accepting SCC. This function tries to find a node
// who lives in that SCC and if it does, we return the brace_id of that SCC. // who lives in that SCC and if it does, we return the brace_id of that SCC.
unsigned find_scc_brace_id(unsigned scc_id, const scc_info& scc); unsigned find_scc_brace_id(unsigned scc_id, const scc_info& scc);