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