* 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.
{
tgba_succ_iterator* i = aut_->succ_iter(from);
todo.push_back(pair_state_iter(from, i));
}
while (!todo.empty())
{ {
std::map<const state*, state_proposition, const state* src = todo.front().first;
state_ptr_less_than> complete_map; tgba_succ_iterator* i = todo.front().second;
std::deque<pair_state_iter> todo_complete; todo.pop_front();
tgba_succ_iterator* ite = aut_->succ_iter(from_state); for (i->first(); !i->done(); i->next())
todo_complete.push_back(pair_state_iter(from_state, ite));
cycle_path tmp_comp;
while(!todo_complete.empty())
{ {
pair_state_iter started_ = todo_complete.front(); const state* dest = h_filt(i->current_state());
todo_complete.pop_front();
tgba_succ_iterator* iter_s = started_.second; // Do not escape this SCC.
iter_s->first(); if (!scc.has_state(dest))
for (iter_s->first(); !iter_s->done(); iter_s->next()) continue;
bdd cond = i->current_condition();
// If we have reached our destination, unwind the path
// and populate PERIOD.
if (dest == to)
{ {
const state* curr_state = started_.second->current_state(); cycle_path p;
if (comp_path.has_state(curr_state)) p.push_front(state_proposition(dest, cond));
while (src != from)
{ {
if (curr_state->compare(to_state) == 0) const state_proposition& psi = father[src];
{ p.push_front(state_proposition(src, psi.second));
const state* curr_father = started_.first; src = psi.first;
bdd curr_condition = iter_s->current_condition();
tmp_comp.push_front(state_proposition(curr_state, curr_condition));
while (curr_father->compare(from_state) != 0)
{
tmp_comp.push_front(state_proposition(curr_father,
complete_map[curr_father].second));
curr_father = complete_map[curr_father].first;
}
period.splice(period.end(), tmp_comp);
todo_complete.clear();
break;
}
else
{
todo_complete.push_back(pair_state_iter(curr_state,
aut_->succ_iter(curr_state)));
complete_map[curr_state] =
state_proposition(started_.first,
iter_s->current_condition());
}
} }
period.splice(period.end(), p);
// Exit the BFS, but release all iterators first.
while (!todo.empty())
{
delete todo.front().second;
todo.pop_front();
}
break;
} }
// Common case: record backlinks and continue BFS.
todo.push_back(pair_state_iter(dest, aut_->succ_iter(dest)));
father[dest] = state_proposition(src, cond);
} }
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