1 #ifndef VCSN_ALGOS_ENUMERATE_HH
2 # define VCSN_ALGOS_ENUMERATE_HH
25 template <
typename Aut>
31 static_assert(context_t::labelset_t::is_free(),
32 "enumerate: requires free labelset");
42 using word_t =
typename labelset_t::word_t;
46 using queue_t = std::queue<std::pair<state_t, monomial_t>>;
63 for (
size_t i = 0; i < max && !queue.empty(); ++i)
81 while (
past_[
aut_->post()].size() < num && !queue.empty())
106 tie(s, m) = std::move(q1.front());
108 for (
const auto t:
aut_->all_out(s))
112 ws_.mul(m.second,
aut_->weight_of(t)));
114 q2.emplace(
aut_->dst_of(t), n);
125 std::map<state_t, polynomial_t>
past_;
129 template <
typename Automaton>
138 template <
typename Automaton>
140 typename detail::enumerater<Automaton>::polynomial_t
157 template <
typename Aut,
typename Un
signed>
161 const auto& a = aut->as<Aut>();
175 template <
typename Aut,
typename Un
signed>
179 const auto& a = aut->as<Aut>();
190 #endif // !VCSN_ALGOS_ENUMERATE_HH
Linear combination of labels: map labels to weights.
polynomial enumerate(const automaton &aut, unsigned max)
value_t & add_here(value_t &v, const value_t &p) const
v += p.
std::pair< word_t, weight_t > monomial_t
Same as polynomial_t::value_type.
const polynomialset_t ps_
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &polynomial)
detail::enumerater< Automaton >::polynomial_t shortest(const Automaton &aut, unsigned num)
state_t_of< automaton_t > state_t
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
const labelset_t_of< polynomialset_t > & ls_
polynomial_t enumerate(unsigned max)
The weighted accepted word with length at most max.
detail::enumerater< Automaton >::polynomial_t enumerate(const Automaton &aut, unsigned max)
typename labelset_t::word_t word_t
context_t_of< Aut > context_t
label_t_of< automaton_t > label_t
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
std::queue< std::pair< state_t, monomial_t >> queue_t
std::map< state_t, polynomial_t > past_
For each state, the first orders of its past.
auto make_word_polynomialset(const Ctx &ctx) -> word_polynomialset_t< Ctx >
The polynomialset of words of a labelset (not necessarily on words itself).
polynomial shortest(const automaton &aut, unsigned num)
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
typename polynomialset_t::value_t polynomial_t
const labelset_ptr & labelset() const
std::map< label_t, weight_t, vcsn::less< labelset_t >> value_t
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
void propagate_(queue_t &q1)
Process once all the states of q1.
polynomial_t shortest(unsigned num)
The shortest accepted weighted words, or throw an exception.
const monomial_t & monomial_one() const
weight_t_of< automaton_t > weight_t
labelset_t_of< automaton_t > labelset_t
enumerater(const automaton_t &aut)
weightset_t_of< automaton_t > weightset_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
const value_t & one() const
std::shared_ptr< const detail::polynomial_base > polynomial