9 #ifndef __DIADES__AUTOMATA__EXPERIMENTAL__ABSTRACT__HH 10 #define __DIADES__AUTOMATA__EXPERIMENTAL__ABSTRACT__HH 12 #include<unordered_map> 13 #include<unordered_set> 20 namespace Experimental {
43 template<
typename Fsm,
typename BeliefStateIterator,
typename StateCreation>
45 abstract(
const Fsm & machine,
46 Fsm & abstractedMachine,
48 std::vector<typename Fsm::State> & abstractedStates,
52 if (machine == abstractedMachine) {
55 std::unordered_map<State, std::unordered_set < size_t>> bsOfState;
56 std::vector<BeliefStateIterator> iterators;
58 for (
auto it = bfBegin; it != bfEnd; ++it) {
61 std::tie(newState,result) = creator.newState(*it);
62 iterators.push_back(it);
63 abstractedStates.push_back(newState);
64 std::for_each(it->begin(), it->end(), [&](
State s) {
65 bsOfState[s].insert(iterators.size() - 1);
66 if (machine.isInitial(s)) {
67 abstractedMachine.setInitial(abstractedStates.back());
71 abstractedMachine.copyEventPropertyIds(machine);
72 std::for_each(bsOfState.begin(), bsOfState.end(),
73 [&](
const std::pair<State, std::unordered_set < size_t> > & bsState) {
74 std::for_each(machine.outputTransitionBegin(bsState.first),
75 machine.outputTransitionEnd(bsState.first),
77 auto itTarget = bsOfState.find(t.target());
78 if (itTarget != bsOfState.end()) {
79 std::for_each(bsState.second.begin(),
81 [&](
size_t sourceId) {
82 std::for_each(itTarget->second.begin(),
83 itTarget->second.end(),
84 [&](
size_t targetId) {
85 abstractedMachine.newTransition(abstractedStates[sourceId],
86 abstractedStates[targetId],
188 template<
typename Fsm,
typename BeliefStateIterator,
typename StateCreation>
190 abstract(
const Fsm & machine,
191 Fsm & abstractedMachine,
194 std::vector<typename Fsm::State> abstractedStates;
195 return abstract(machine, abstractedMachine, bfBegin, bfEnd, abstractedStates,creator);
Diades::Graph::Edge Transition
FaultyEventStateMachine< CandidateId, EventInfoId > Fsm
Diades::Graph::GraphNodeSet::Iterator BeliefStateIterator
AutFsm::Transition Transition
Namespace of the Diades project.
Diades::Graph::Node State