3 #include <boost/heap/fibonacci_heap.hpp>
28 template <Automaton Aut>
67 auto ws = *a.
aut_->weightset();
68 a.aut_->print_state_name(p.
state_, o) <<
':';
69 if (a.res_[p.
state_] != a.aut_->null_transition())
70 return ws.print(a.heuristic_dist_[p.
state_], o);
79 using heap_t = boost::heap::fibonacci_heap<profile>;
81 template <
typename Heuristic>
82 std::vector<transition_t>
85 auto ws = *
aut_->weightset();
86 auto size =
aut_->all_states().back() + 1;
88 auto done = std::set<state_t>();
91 std::vector<typename heap_t::handle_type> handles(
size);
95 dist[source] = ws.one();
97 handles[source] = todo.emplace(source, *
this);
104 return std::move(
res_);
109 auto dst =
aut_->dst_of(t);
112 auto nw = ws.mul(dist[s],
aut_->weight_of(t));
113 if (
res_[dst] ==
aut_->null_transition()
114 || ws.less(nw, dist[dst]))
120 handles[dst] = todo.emplace(dst, *
this);
125 return std::vector<transition_t>(
size,
aut_->null_transition());
131 const char* sep =
"";
132 for (
auto i = todo.ordered_begin(), end = todo.ordered_end();
135 std::cout << sep << *i;
138 std::cout << std::endl;
144 std::vector<transition_t>
res_;
149 template <Automaton Aut>
150 std::vector<transition_t_of<Aut>>
156 [aut](state_t, state_t)
158 return aut->weightset()->zero();
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
Container::value_type back(const Container &container)
The last member of this Container.
state_t_of< automaton_t > state_t
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
a_star_impl(const Aut &aut)
A Star implementation of lightest automaton.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
std::vector< weight_t > distance_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::vector< transition_t > res_
For each state, its predecessor.
distance_t heuristic_dist_
friend std::ostream & operator<<(std::ostream &o, const profile &p)
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
transition_t_of< automaton_t > transition_t
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
boost::heap::fibonacci_heap< profile > heap_t
profile(state_t state, const self_t &a_star)
weightset_t_of< automaton_t > weightset_t
weight_t_of< automaton_t > weight_t
std::vector< transition_t > operator()(state_t source, state_t dest, Heuristic heuristic)
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
A-Star implementation (from vcsn/algos/a-star.hh).
bool operator<(const profile &rhs) const
void show_heap_(const heap_t &todo)
std::vector< transition_t_of< Aut > > lightest_path(const Aut &aut, state_t_of< Aut > source, state_t_of< Aut > dest, a_star_tag)