19 template <
typename Aut,
20 bool has_one = labelset_t_of<Aut>::has_one()>
26 using weight_t =
typename weightset_t::value_t;
41 :
ws_(*aut->weightset())
43 ,
d2p_(aut->all_states().
back() + 1, aut->null_state())
44 ,
p2d_(aut->all_states().
back() + 1, aut->null_state())
48 aut_dirty_ = make_shared_ptr<aut_dirty_t>(dirty_ctx);
49 aut_proper_ = make_shared_ptr<aut_proper_t>(proper_ctx);
54 pcopier([](
state_t) {
return true; },
56 return !aut->labelset()->is_one(aut->label_of(t));
60 return (!aut->in(s, aut->labelset()->one()).empty()
61 || !aut->out(s, aut->labelset()->one()).empty());
64 return aut->labelset()->is_one(aut->label_of(t));
68 const auto& dorigins = dcopier.state_map();
69 const auto& porigins = pcopier.state_map();
70 for (
const auto& dp : dorigins)
72 auto pp = porigins.find(dp.first);
73 assert(pp != porigins.end());
74 d2p_[dp.second] = pp->second;
75 p2d_[pp->second] = dp.second;
88 for (
state_t dirty_q = 0; dirty_q <
de_[dirty_p].size(); dirty_q++)
123 std::vector<std::vector<weight_t>>
de_;
126 template <
typename Aut>
std::vector< std::vector< weight_t_of< Aut > > > all_distances(const Aut &aut)
std::vector< state_t > d2p_
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
std::vector< std::vector< weight_t > > de_
weightset_t_of< automaton_t > weightset_t
fresh_automaton_t_of< Aut, proper_ctx_t > aut_proper_t
typename weightset_t::value_t weight_t
epsilon_remover_distance(const automaton_t &aut, bool)
label_t_of< aut_proper_t > label_proper_t
Container::value_type back(const Container &container)
The last member of this Container.
detail::copier< AutIn, AutOut > make_copier(const AutIn &in, AutOut &out)
Build an automaton copier.
std::string type(const automaton &a)
The implementation type of a.
typename std::remove_cv< Aut >::type automaton_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
aut_proper_t aut_proper_
The automata we work on.
mutable_automaton< dirty_ctx_t > aut_dirty_t
bool prune_
Whether to prune states that become inaccessible.
This class contains the core of the proper algorithm.
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
aut_proper_t operator()()
auto make_proper_context(const context< LabelSet, WeightSet > &ctx) -> proper_context< context< LabelSet, WeightSet >>
From a context, its non-nullable context.
std::vector< transition_t > transitions_t
AutOut copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans)
A copy of input keeping only its states that are accepted by keep_state.
epsilon_remover_distance(const automaton_t &aut, bool prune=true)
state_t_of< automaton_t > state_t
labelset_t_of< automaton_t > labelset_t
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
aut_proper_t operator()()
fresh_automaton_t_of< automaton_t > aut_proper_t
std::vector< state_t > p2d_
typename std::remove_cv< Aut >::type automaton_t
transition_t_of< automaton_t > transition_t
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
const weightset_t & ws_
Shorthand to the weightset.