* src/tgbaalgos/emptinesscheck.cc (emptiness_check::complete_cycle):

Simplify, comment, and free memory.
This commit is contained in:
Alexandre Duret-Lutz 2003-10-28 16:05:56 +00:00
parent 89fddaaa81
commit 66f05a2621
3 changed files with 64 additions and 47 deletions

View file

@ -1,8 +1,11 @@
2003-10-28 Alexandre Duret-Lutz <adl@src.lip6.fr> 2003-10-28 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbaalgos/emptinesscheck.cc (emptiness_check::complete_cycle):
Simplify, comment, and free memory.
* src/tgbaalgos/emptinesscheck.cc (triplet): New class. * src/tgbaalgos/emptinesscheck.cc (triplet): New class.
(emptiness_check::accepting_path): (emptiness_check::accepting_path): Simplify, comment,
Simplify, comment, derecursive, and free memory... derecursive, and free memory...
2003-10-27 Alexandre Duret-Lutz <adl@src.lip6.fr> 2003-10-27 Alexandre Duret-Lutz <adl@src.lip6.fr>

View file

@ -398,55 +398,69 @@ namespace spot
} }
void void
emptiness_check::complete_cycle(const connected_component_set& comp_path, emptiness_check::complete_cycle(const connected_component_set& scc,
const state* from_state, const state* from,
const state* to_state) const state* to)
{ {
if (h[from_state] != h[to_state]) if (from == to)
return;
// Records backlinks to parent state during the BFS.
// (This also stores the propositions of this link.)
std::map<const state*, state_proposition, state_ptr_less_than> father;
// BFS queue.
std::deque<pair_state_iter> todo;
// Initial state.
{ {
std::map<const state*, state_proposition, tgba_succ_iterator* i = aut_->succ_iter(from);
state_ptr_less_than> complete_map; todo.push_back(pair_state_iter(from, i));
std::deque<pair_state_iter> todo_complete; }
tgba_succ_iterator* ite = aut_->succ_iter(from_state);
todo_complete.push_back(pair_state_iter(from_state, ite)); while (!todo.empty())
cycle_path tmp_comp; {
while(!todo_complete.empty()) const state* src = todo.front().first;
{ tgba_succ_iterator* i = todo.front().second;
pair_state_iter started_ = todo_complete.front(); todo.pop_front();
todo_complete.pop_front(); for (i->first(); !i->done(); i->next())
tgba_succ_iterator* iter_s = started_.second; {
iter_s->first(); const state* dest = h_filt(i->current_state());
for (iter_s->first(); !iter_s->done(); iter_s->next())
{ // Do not escape this SCC.
const state* curr_state = started_.second->current_state(); if (!scc.has_state(dest))
if (comp_path.has_state(curr_state)) continue;
{
if (curr_state->compare(to_state) == 0) bdd cond = i->current_condition();
{
const state* curr_father = started_.first; // If we have reached our destination, unwind the path
bdd curr_condition = iter_s->current_condition(); // and populate PERIOD.
tmp_comp.push_front(state_proposition(curr_state, curr_condition)); if (dest == to)
while (curr_father->compare(from_state) != 0) {
{ cycle_path p;
tmp_comp.push_front(state_proposition(curr_father, p.push_front(state_proposition(dest, cond));
complete_map[curr_father].second)); while (src != from)
curr_father = complete_map[curr_father].first; {
const state_proposition& psi = father[src];
p.push_front(state_proposition(src, psi.second));
src = psi.first;
}
period.splice(period.end(), p);
// Exit the BFS, but release all iterators first.
while (!todo.empty())
{
delete todo.front().second;
todo.pop_front();
} }
period.splice(period.end(), tmp_comp);
todo_complete.clear();
break; break;
} }
else
{ // Common case: record backlinks and continue BFS.
todo_complete.push_back(pair_state_iter(curr_state, todo.push_back(pair_state_iter(dest, aut_->succ_iter(dest)));
aut_->succ_iter(curr_state))); father[dest] = state_proposition(src, cond);
complete_map[curr_state] =
state_proposition(started_.first,
iter_s->current_condition());
}
}
}
} }
delete i;
} }
} }

View file

@ -101,13 +101,13 @@ namespace spot
/// Called by counter_example to find a path which traverses all /// Called by counter_example to find a path which traverses all
/// accepting conditions in the accepted SCC. /// accepting conditions in the accepted SCC.
void accepting_path (const connected_component_set& comp_path, void accepting_path (const connected_component_set& scc,
const state* start_path, bdd acc_to_traverse); const state* start, bdd acc_to_traverse);
/// Complete a cycle that caraterise the period of the counter /// Complete a cycle that caraterise the period of the counter
/// example. Append a sequence to the path given by accepting_path. /// example. Append a sequence to the path given by accepting_path.
void complete_cycle(const connected_component_set& comp_path, void complete_cycle(const connected_component_set& scc,
const state* from_state, const state* to_state); const state* from, const state* to);
}; };
} }
#endif // SPOT_EMPTINESS_CHECK_HH #endif // SPOT_EMPTINESS_CHECK_HH