Commit 32a0db6a authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

dupexp, simulation: more simplifications.

* src/tgbaalgos/dupexp.cc, src/tgbaalgos/dupexp.hh: Return the
association between new states and old states in a vector instead of a
map.
* src/tgbaalgos/simulation.cc: Adjust.
parent bb2ce45b
......@@ -73,10 +73,7 @@ namespace spot
class dupexp_iter_save: public dupexp_iter<T>
{
public:
dupexp_iter_save(const tgba* a,
std::map<const state*,
const state*,
state_ptr_less_than>& relation)
dupexp_iter_save(const tgba* a, std::vector<const state*>& relation)
: dupexp_iter<T>(a), relation_(relation)
{
}
......@@ -84,12 +81,12 @@ namespace spot
virtual void
end()
{
relation_.resize(this->seen.size());
for (auto s: this->seen)
relation_[this->out_->state_from_number(s.second - 1)]
= const_cast<state*>(s.first);
relation_[s.second - 1] = const_cast<state*>(s.first);
}
std::map<const state*, const state*, state_ptr_less_than>& relation_;
std::vector<const state*>& relation_;
};
} // anonymous
......@@ -111,23 +108,17 @@ namespace spot
}
tgba_digraph*
tgba_dupexp_bfs(const tgba* aut,
std::map<const state*,
const state*, state_ptr_less_than>& rel)
tgba_dupexp_bfs(const tgba* aut, std::vector<const state*>& rel)
{
dupexp_iter_save<tgba_reachable_iterator_breadth_first> di(aut,
rel);
dupexp_iter_save<tgba_reachable_iterator_breadth_first> di(aut, rel);
di.run();
return di.result();
}
tgba_digraph*
tgba_dupexp_dfs(const tgba* aut,
std::map<const state*,
const state*, state_ptr_less_than>& rel)
tgba_dupexp_dfs(const tgba* aut, std::vector<const state*>& rel)
{
dupexp_iter_save<tgba_reachable_iterator_depth_first> di(aut,
rel);
dupexp_iter_save<tgba_reachable_iterator_depth_first> di(aut, rel);
di.run();
return di.result();
}
......
......@@ -41,17 +41,20 @@ namespace spot
/// \ingroup tgba_misc
/// \brief Build an explicit automaton from all states of \a aut,
/// numbering states in bread first order as they are processed.
/// \a aut the automaton to duplicate
/// \a relation a map of all the new states (represented by
/// their number) to the old states.
SPOT_API tgba_digraph*
tgba_dupexp_bfs(const tgba* aut,
std::map<const state*, const state*,
state_ptr_less_than>& relation);
tgba_dupexp_bfs(const tgba* aut, std::vector<const state*>& relation);
/// \ingroup tgba_misc
/// \brief Build an explicit automata from all states of \a aut,
/// numbering states in depth first order as they are processed.
/// \a aut the automaton to duplicate
/// \a relation a map of all the new states (represented by
/// their number) to the old states.
SPOT_API tgba_digraph*
tgba_dupexp_dfs(const tgba* aut,
std::map<const state*, const state*,
state_ptr_less_than>& relation);
tgba_dupexp_dfs(const tgba* aut, std::vector<const state*>& relation);
}
#endif // SPOT_TGBAALGOS_DUPEXP_HH
......@@ -98,9 +98,6 @@ namespace spot
state_ptr_equal> map_state_bdd;
typedef std::vector<bdd> vector_state_bdd;
typedef std::map<const state*, const state*,
state_ptr_less_than> map_state_state;
typedef std::vector<const state*> vector_state_state;
......@@ -393,15 +390,12 @@ namespace spot
bdd acc = bddtrue;
map_constraint::const_iterator it;
// We are using
// new_original_[old_a_->state_from_number(...)] because
// we have the constraints in the original automaton which
// has been duplicated twice to get the current automaton.
// Check if we have a constraint about this edge in the
// original automaton.
if (map_cst_
&& ((it = map_cst_
->find(std::make_pair
(new_original_[old_a_->state_from_number(src)],
new_original_[old_a_->state_from_number(t.dst)])))
->find(std::make_pair(new_original_[src],
new_original_[t.dst])))
!= map_cst_->end()))
{
acc = it->second;
......@@ -798,11 +792,7 @@ namespace spot
automaton_size stat;
scc_map* scc_map_;
map_state_state new_original_;
// This table link a state in the current automaton with a state
// in the original one.
map_state_state old_old_name_;
std::vector<const state*> new_original_;
const map_constraint* map_cst_;
......@@ -1019,10 +1009,9 @@ namespace spot
{
assert(src_right != dst_right);
constraint.emplace_back
(new_original_[old_a_->state_from_number(src_right_n)],
new_original_[old_a_->state_from_number(dst_right_n)],
add);
constraint.emplace_back(new_original_[src_right_n],
new_original_[dst_right_n],
add);
}
}
else if (out_scc_left && !out_scc_right)
......@@ -1035,10 +1024,9 @@ namespace spot
{
assert(src_left != dst_left);
constraint.emplace_back
(new_original_[old_a_->state_from_number(src_left_n)],
new_original_[old_a_->state_from_number(dst_left_n)],
add);
constraint.emplace_back(new_original_[src_left_n],
new_original_[dst_left_n],
add);
}
}
else if (out_scc_left && out_scc_right)
......@@ -1051,14 +1039,12 @@ namespace spot
{
assert(src_left != dst_left && src_right != dst_right);
// FIXME: cas pas compris.
constraint.emplace_back
(new_original_[old_a_->state_from_number(src_left_n)],
new_original_[old_a_->state_from_number(dst_left_n)],
add);
constraint.emplace_back
(new_original_[old_a_->state_from_number(src_right_n)],
new_original_[old_a_->state_from_number(dst_right_n)],
add);
constraint.emplace_back(new_original_[src_left_n],
new_original_[dst_left_n],
add);
constraint.emplace_back(new_original_[src_right_n],
new_original_[dst_right_n],
add);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment