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()->generators())
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>();
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...
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::shared_ptr< const detail::context_base > context
A dyn::context.
std::shared_ptr< detail::automaton_base > automaton
automaton cerny(const context &ctx, unsigned num_states)
Bridge.
static dyn::context ctx(const driver &d)
Get the context of the driver.