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 ...@@ -73,10 +73,7 @@ namespace spot
class dupexp_iter_save: public dupexp_iter<T> class dupexp_iter_save: public dupexp_iter<T>
{ {
public: public:
dupexp_iter_save(const tgba* a, dupexp_iter_save(const tgba* a, std::vector<const state*>& relation)
std::map<const state*,
const state*,
state_ptr_less_than>& relation)
: dupexp_iter<T>(a), relation_(relation) : dupexp_iter<T>(a), relation_(relation)
{ {
} }
...@@ -84,12 +81,12 @@ namespace spot ...@@ -84,12 +81,12 @@ namespace spot
virtual void virtual void
end() end()
{ {
relation_.resize(this->seen.size());
for (auto s: this->seen) for (auto s: this->seen)
relation_[this->out_->state_from_number(s.second - 1)] relation_[s.second - 1] = const_cast<state*>(s.first);
= const_cast<state*>(s.first);
} }
std::map<const state*, const state*, state_ptr_less_than>& relation_; std::vector<const state*>& relation_;
}; };
} // anonymous } // anonymous
...@@ -111,23 +108,17 @@ namespace spot ...@@ -111,23 +108,17 @@ namespace spot
} }
tgba_digraph* tgba_digraph*
tgba_dupexp_bfs(const tgba* aut, tgba_dupexp_bfs(const tgba* aut, std::vector<const state*>& rel)
std::map<const state*,
const state*, state_ptr_less_than>& rel)
{ {
dupexp_iter_save<tgba_reachable_iterator_breadth_first> di(aut, dupexp_iter_save<tgba_reachable_iterator_breadth_first> di(aut, rel);
rel);
di.run(); di.run();
return di.result(); return di.result();
} }
tgba_digraph* tgba_digraph*
tgba_dupexp_dfs(const tgba* aut, tgba_dupexp_dfs(const tgba* aut, std::vector<const state*>& rel)
std::map<const state*,
const state*, state_ptr_less_than>& rel)
{ {
dupexp_iter_save<tgba_reachable_iterator_depth_first> di(aut, dupexp_iter_save<tgba_reachable_iterator_depth_first> di(aut, rel);
rel);
di.run(); di.run();
return di.result(); return di.result();
} }
......
...@@ -41,17 +41,20 @@ namespace spot ...@@ -41,17 +41,20 @@ namespace spot
/// \ingroup tgba_misc /// \ingroup tgba_misc
/// \brief Build an explicit automaton from all states of \a aut, /// \brief Build an explicit automaton from all states of \a aut,
/// numbering states in bread first order as they are processed. /// 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* SPOT_API tgba_digraph*
tgba_dupexp_bfs(const tgba* aut, tgba_dupexp_bfs(const tgba* aut, std::vector<const state*>& relation);
std::map<const state*, const state*,
state_ptr_less_than>& relation);
/// \ingroup tgba_misc /// \ingroup tgba_misc
/// \brief Build an explicit automata from all states of \a aut, /// \brief Build an explicit automata from all states of \a aut,
/// numbering states in depth first order as they are processed. /// 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* SPOT_API tgba_digraph*
tgba_dupexp_dfs(const tgba* aut, tgba_dupexp_dfs(const tgba* aut, std::vector<const state*>& relation);
std::map<const state*, const state*,
state_ptr_less_than>& relation);
} }
#endif // SPOT_TGBAALGOS_DUPEXP_HH #endif // SPOT_TGBAALGOS_DUPEXP_HH
...@@ -98,9 +98,6 @@ namespace spot ...@@ -98,9 +98,6 @@ namespace spot
state_ptr_equal> map_state_bdd; state_ptr_equal> map_state_bdd;
typedef std::vector<bdd> vector_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; typedef std::vector<const state*> vector_state_state;
...@@ -393,15 +390,12 @@ namespace spot ...@@ -393,15 +390,12 @@ namespace spot
bdd acc = bddtrue; bdd acc = bddtrue;
map_constraint::const_iterator it; map_constraint::const_iterator it;
// We are using // Check if we have a constraint about this edge in the
// new_original_[old_a_->state_from_number(...)] because // original automaton.
// we have the constraints in the original automaton which
// has been duplicated twice to get the current automaton.
if (map_cst_ if (map_cst_
&& ((it = map_cst_ && ((it = map_cst_
->find(std::make_pair ->find(std::make_pair(new_original_[src],
(new_original_[old_a_->state_from_number(src)], new_original_[t.dst])))
new_original_[old_a_->state_from_number(t.dst)])))
!= map_cst_->end())) != map_cst_->end()))
{ {
acc = it->second; acc = it->second;
...@@ -798,11 +792,7 @@ namespace spot ...@@ -798,11 +792,7 @@ namespace spot
automaton_size stat; automaton_size stat;
scc_map* scc_map_; scc_map* scc_map_;
map_state_state new_original_; std::vector<const 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_;
const map_constraint* map_cst_; const map_constraint* map_cst_;
...@@ -1019,10 +1009,9 @@ namespace spot ...@@ -1019,10 +1009,9 @@ namespace spot
{ {
assert(src_right != dst_right); assert(src_right != dst_right);
constraint.emplace_back constraint.emplace_back(new_original_[src_right_n],
(new_original_[old_a_->state_from_number(src_right_n)], new_original_[dst_right_n],
new_original_[old_a_->state_from_number(dst_right_n)], add);
add);
} }
} }
else if (out_scc_left && !out_scc_right) else if (out_scc_left && !out_scc_right)
...@@ -1035,10 +1024,9 @@ namespace spot ...@@ -1035,10 +1024,9 @@ namespace spot
{ {
assert(src_left != dst_left); assert(src_left != dst_left);
constraint.emplace_back constraint.emplace_back(new_original_[src_left_n],
(new_original_[old_a_->state_from_number(src_left_n)], new_original_[dst_left_n],
new_original_[old_a_->state_from_number(dst_left_n)], add);
add);
} }
} }
else if (out_scc_left && out_scc_right) else if (out_scc_left && out_scc_right)
...@@ -1051,14 +1039,12 @@ namespace spot ...@@ -1051,14 +1039,12 @@ namespace spot
{ {
assert(src_left != dst_left && src_right != dst_right); assert(src_left != dst_left && src_right != dst_right);
// FIXME: cas pas compris. // FIXME: cas pas compris.
constraint.emplace_back constraint.emplace_back(new_original_[src_left_n],
(new_original_[old_a_->state_from_number(src_left_n)], new_original_[dst_left_n],
new_original_[old_a_->state_from_number(dst_left_n)], add);
add); constraint.emplace_back(new_original_[src_right_n],
constraint.emplace_back new_original_[dst_right_n],
(new_original_[old_a_->state_from_number(src_right_n)], add);
new_original_[old_a_->state_from_number(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