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();
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;
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();
state_t_of< automaton_t > state_t
profile(state_t state, const self_t &a_star)
friend std::ostream & operator<<(std::ostream &o, const profile &p)
a_star_impl(const Aut &aut)
A Star implementation of lightest automaton.
size_t states_size(const Aut &aut)
The largest state number, plus one.
std::vector< weight_t > distance_t
bool operator<(const profile &rhs) const
std::vector< transition_t > res_
For each state, its predecessor.
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
distance_t heuristic_dist_
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
transition_t_of< automaton_t > transition_t
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
boost::heap::fibonacci_heap< profile > heap_t
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
weightset_t_of< automaton_t > weightset_t
weight_t_of< automaton_t > weight_t
std::vector< transition_t_of< Aut > > lightest_path(const Aut &aut, state_t_of< Aut > source, state_t_of< Aut > dest, a_star_tag)
std::vector< transition_t > operator()(state_t source, state_t dest, Heuristic heuristic)
A-Star implementation (from vcsn/algos/a-star.hh).
void show_heap_(const heap_t &todo)