28 template <Automaton Aut>
54 auto ws = *a_star_.aut_->weightset();
55 if (a_star_.res_[rhs.
state_] == a_star_.aut_->null_transition())
57 else if (a_star_.res_[state_] == a_star_.aut_->null_transition())
60 return ws.less(a_star_.heuristic_dist_[state_],
61 a_star_.heuristic_dist_[rhs.
state_]);
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);
81 template <
typename Heuristic>
85 auto ws = *aut_->weightset();
88 auto done = std::set<state_t>();
91 auto handles = std::vector<typename heap_t::handle_type>(
size);
95 dist[source] = ws.one();
96 heuristic_dist_[source] = ws.add(ws.one(), heuristic(source, dest));
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]))
118 heuristic_dist_[dst] = ws.add(nw, heuristic(dst, dest));
120 handles[dst] = todo.emplace(dst, *
this);
131 const char* sep =
"";
132 for (
auto i = todo.ordered_begin(), end = todo.ordered_end();
135 std::cout << sep << *i;
149 template <Automaton Aut>
150 std::vector<transition_t_of<Aut>>
156 [aut](state_t, state_t)
158 return aut->weightset()->zero();
predecessors_t_of< automaton_t > res_
For each state, its predecessor.
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
profile(state_t state, const self_t &a_star)
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
typename detail::transition_t_of_impl< base_t< ValueSet > >::type transition_t_of
state_t_of< automaton_t > state_t
distance_t heuristic_dist_
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
size_t states_size(const Aut &aut)
The largest state number, plus one.
std::vector< weight_t > distance_t
vcsn::min_fibonacci_heap< profile > heap_t
void show_heap_(const heap_t &todo)
predecessors_t_of< automaton_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.
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)
A Star implementation of lightest automaton.
weightset_t_of< automaton_t > weightset_t
boost::heap::fibonacci_heap< Elt, detail::comparator_t< Elt > > min_fibonacci_heap
friend std::ostream & operator<<(std::ostream &o, const profile &p)
std::vector< transition_t_of< Aut > > predecessors_t_of
A state-indexed vector of predecessor transitions from the path path.
A-Star implementation (from vcsn/algos/a-star.hh).
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
bool operator<(const profile &rhs) const
a_star_impl(const Aut &aut)
transition_t_of< automaton_t > transition_t