23 template <
typename Ctx>
24 mutable_automaton<Ctx>
27 require(0 < num_states,
"num_states must be > 0");
31 automaton_t res = make_shared_ptr<automaton_t>(
ctx);
33 std::vector<state_t> states;
34 states.reserve(num_states);
36 for (
unsigned i = 0; i < num_states; ++i)
37 states.push_back(res->new_state());
39 for (
unsigned i = 0; i < num_states; ++i)
42 for (
auto l : ctx.labelset()->genset())
44 auto dest = (la || i == num_states - 1) ? (i + 1) % num_states : i;
45 res->add_transition(states[i], states[dest], l,
46 ctx.weightset()->one());
51 res->set_initial(states[0]);
52 res->set_final(states[0]);
62 template <
typename Ctx,
typename>
66 const auto& c = ctx->as<Ctx>();
std::shared_ptr< const detail::context_base > context
A dyn::context.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
automaton cerny(const context &ctx, unsigned num_states)
Bridge.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
static dyn::context ctx(const driver &d)
Get the context of the driver.
std::shared_ptr< detail::automaton_base > automaton
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
mutable_automaton< Ctx > cerny(const Ctx &ctx, unsigned num_states)
Cerny automata are automata whose synchronizing word length is always (n - 1)^2, the upper bound of t...
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton