20 bool has_one = labelset_t_of<Aut>::has_one()>
26 using weight_t =
typename weightset_t::value_t;
46 :
ws_(*aut->weightset())
55 aut_dirty_ = make_shared_ptr<aut_dirty_t>(dirty_ctx);
56 aut_proper_ = make_shared_ptr<aut_proper_t>(proper_ctx);
61 pcopier([](
state_t) {
return true; },
63 return !aut->labelset()->is_one(aut->label_of(t));
67 return (!
in(aut, s, aut->labelset()->one()).empty()
68 || !
out(aut, s, aut->labelset()->one()).empty());
71 return aut->labelset()->is_one(aut->label_of(t));
75 const auto& dorigins = dcopier.state_map();
76 const auto& porigins = pcopier.state_map();
77 for (
const auto& dp : dorigins)
79 auto pp = porigins.find(dp.first);
80 assert(pp != porigins.end());
81 d2p_[dp.second] = pp->second;
82 p2d_[pp->second] = dp.second;
96 if (!
ws_.is_zero(dist_pq))
98 auto proper_q =
d2p_[dirty_q];
101 auto proper_p =
d2p_[dirty_p];
106 ws_.mul(dist_pq, w));
129 std::vector<state_proper_t>
d2p_;
131 std::vector<state_dirty_t>
p2d_;
133 std::vector<std::vector<weight_t>>
de_;
136 template <Automaton Aut>
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
Container::value_type back(const Container &container)
The last member of this Container.
This class contains the core of the proper algorithm.
state_t_of< aut_dirty_t > state_dirty_t
auto make_proper_context(const context< LabelSet, WeightSet > &ctx) -> proper_context< context< LabelSet, WeightSet >>
From a context, its non-nullable context.
epsilon_remover_distance(const automaton_t &aut, bool prune=true)
typename weightset_t::value_t weight_t
std::remove_cv_t< Aut > automaton_t
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
aut_proper_t aut_proper_
The automata we work on.
std::vector< std::vector< weight_t_of< Aut > > > all_distances(const Aut &aut)
state_t_of< aut_proper_t > state_proper_t
const weightset_t & ws_
Shorthand to the weightset.
aut_proper_t operator()()
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
mutable_automaton< dirty_ctx_t > aut_dirty_t
Spontaneous automaton.
fresh_automaton_t_of< automaton_t > aut_proper_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
bool prune_
Whether to prune states that become inaccessible.
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
transition_t_of< automaton_t > transition_t
epsilon_remover_distance(const automaton_t &aut, bool)
aut_proper_t operator()()
std::vector< state_dirty_t > p2d_
proper states -> dirty states.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
std::vector< std::vector< weight_t > > de_
label_t_of< aut_proper_t > label_proper_t
std::vector< state_proper_t > d2p_
dirty states -> proper states.
detail::copier< AutIn, AutOut > make_copier(const AutIn &in, AutOut &out, bool safe=true)
Build an automaton copier.
std::remove_cv_t< Aut > automaton_t
auto in(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions arriving to state s.
state_t_of< automaton_t > state_t
labelset_t_of< automaton_t > labelset_t
weightset_t_of< automaton_t > weightset_t
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
fresh_automaton_t_of< Aut, proper_ctx_t > aut_proper_t
Proper automaton.