|
|
||||||
|
op_observercomputation.cpp
Go to the documentation of this file.
8 output control consistency (OCC) and local control consistency (LCC) are provided. See for example
46 void calculateDynamicSystemClosedObs(const Generator& rGen, EventSet& rHighAlph, Generator& rGenDyn)
48 OP_DF("calculateDynamicSystemClosedObs(" << rGen.Name() << "," << rHighAlph.Name() << "," << rGenDyn.Name() << ")");
55 rGenDyn.InjectAlphabet(rHighAlph); // all high-level events are contained in the alphabet of rGenDyn
81 OP_DF("calculateDynamicSystemClosedObs: loop over all states; current state: " << rGen.StateName(*stateSetIt)
95 // insert the exit state and the high-level event with the reachable entry state into the exitStates set
104 // compute locally reachable states for current entry state and insert it into entryStateToLocalReach
111 // after this loop we have the set of exit states in exitStates and a map from entry states to their
121 // We compute the local backward reach of each exit state and find the corresponding entry states in
135 // loop over all pairs (Ev,X2) of current exit state and insert transitions from all states in the
161 OP_DF("calculateDynamicSystemObs(" << rGen.Name() << "," << rHighAlph.Name() << "," << rGenDyn.Name() << ")");
175 OP_DF("calculateDynamicSystemObs: loop over all states; current state: " << rGen.StateName(*stateSetIt)
197 OP_DF("calculateDynamicSystemMSA(" << rGen.Name() << "," << rHighAlph.Name() << "," << rGenDyn.Name() << ")");
221 OP_DF("calculateDynamicSystemMSA: loop over all states; current state: " << rGen.StateName(*stateSetIt)
225 // if all forward transitions lead to marked states, all states that have been reached are states where msa holds
232 // if all backward transitions lead to marked states, all states that have been reached are states where msa holds
237 // otherwise, msa is violated for the current state. Then, msa-transitions are introduced to all states
252 bool recursiveCheckMSAForward(const Generator& rGen, const EventSet& rHighAlph, Idx currentState, StateSet& rDoneStates){
278 bool recursiveCheckMSABackward(const Generator& rGen, const TransSetX2EvX1& rRevTransSet, const EventSet& rHighAlph, Idx currentState, StateSet& rDoneStates){
303 void calculateDynamicSystemLCC(const Generator& rGen, const EventSet& rControllableEvents, const EventSet& rHighAlph, Generator& rGenDyn){
304 OP_DF("calculateDynamicSystemLCC(" << rGen.Name() << "," << rControllableEvents.Name() << "," << rHighAlph.Name() << "," << rGenDyn.Name() << ")");
312 // labels for transitions for states with uncontrollable successor strings in the dynamic system
320 std::string eventname = ( rGenDyn.EventSymbolTablep())->UniqueSymbol(SymbolTable::GlobalEventSymbolTablep()->Symbol(*eIt) + "LCCLabel");
333 OP_DF("calculateDynamicSystemLCC: loop over all states; current state: " << rGen.StateName(*sIt)
342 // if the event is an uncontrollable high-level event, it is inserted for the current exit state
354 // after this loop, we have the set of exit states with their outgoing uncontrollable high-level events.
355 // Now we compute the backwards reachable state via uncontrollable strings to determine all states where lcc holds
365 // transitions are introduced to all states that are reachable via strings including one high-level event
377 // loop over all states reachable via strings with one high-level event (these states are already encoded
387 void recursiveCheckLCC(const TransSetX2EvX1& rRevTransSet, const EventSet& rControllableEvents, const EventSet& rHighAlph, Idx currentState, StateSet& rDoneStates){
398 // if the transition is uncontrollable, an uncontrollable string has been found -> LCC is fulfilled
401 // if the event is an uncontrollable low-level event, we go backward along uncontrollable transitions
408 // the end of the loop is reached, if no more uncontrollable event has been found from the current state
454 Int calcNaturalObserverLCC(const Generator& rGen, const EventSet& rControllableEvents, EventSet& rHighAlph){
497 Int calcMSAObserverLCC(const Generator& rGen, const EventSet& rControllableEvents, EventSet& rHighAlph){
520 void ExtendHighAlphabet(const Generator& rGen, EventSet& rHighAlph, map<Idx,Idx>& rMapStateToPartition){
556 map<Idx,map<Idx,pair<StateSet,IndexSet> > > eventStatesMap; // (coset, event, exit states, goal cosets)
586 // if there is more than one goal coset, the current event introduces nondeterminism in the current coset
594 // All outgoing transitions for any coset are determined. Now, the localViolatingEvents are added
597 // Only if there were no local violating events added to the high-level alphabet, the nondeterministic transitions are checked (Modification with respect to Lei Feng's algorithm)
611 if(nondeterministicStates[fIt->first].empty() == true) // no need to split if there are no nondeterministic states
634 bool CheckSplit(const Generator& rGen, const EventSet& rSplitAlphabet, const vector<pair<StateSet, Idx> >& rNondeterministicStates, Idx entryState){
638 // check if for any of the nondeterministic state sets, more than one state appears in the local accessible reach
667 void calcAbstAlphClosed(System& rGenObs, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents) {
668 OP_DF("calcAbstAlphClosed(" << rGenObs.Name() << "," << "rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
673 // the controllable events that have been changed by the called function are set in the System cGenObs
677 // calcAbstAlphClosed(rGenObs, rControllableEvents, rHighAlph, rNewHighAlph, rMapRelabeledEvents)
678 void calcAbstAlphClosed(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents) {
679 OP_DF("calcAbstAlphClosed(" << rGenObs.Name() << "," << "rControllableEvents, rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
688 if(rMapRelabeledEvents.find(rtIt->first.Ev) == rMapRelabeledEvents.end() ){// if the event does not exist, yet, a nex element in the map is created
690 if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
694 if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
701 void calcAbstAlphClosed(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Transition,Idx>& rMapChangedTrans)
703 OP_DF("calcAbstAlphClosed(" << rGenObs.Name() << ", rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTRans)");
716 // observer algorithm: In each step, a dynamic system is computed that fulfills the one-step observer condition.
717 // Iterative application of the bisimulation algorithm and the relabeling procedure yields an automaton rGenObs
718 // that, together with the new high-level alphabet rNewHighAlph fulfills the observer condition.
724 name = ("./Automata/Plots/" + rGenObs.Name() + "DynamicSystem_" + ToStringInteger(iterationCount));
733 name = ("./Automata/Plots/" + rGenObs.Name() + "Bisimulation_" + ToStringInteger(iterationCount));
739 // and relabel transitions in rGenObs if necessary. The high-level alphabet is modified accordingly
740 done=relabel(rGenObs, rControllableEvents, rNewHighAlph, mapStateToPartition, mapChangedTransReverse, rMapChangedTrans, mapRelabeledEvents);
746 void calcAbstAlphObs(System& rGenObs, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents) {
747 OP_DF("calcAbstAlphObs(" << rGenObs.Name() << "," << "rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
752 // the controllable events that have been changed by the called function are set in the System cGenObs
757 void calcAbstAlphObs(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents) {
758 OP_DF("calcAbstAlphObs(" << rGenObs.Name() << "," << "rControllableEvents, rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
767 if(rMapRelabeledEvents.find(rtIt->first.Ev) == rMapRelabeledEvents.end() ){// if the event does not exist, yet, a nex element in the map is created
769 if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
773 if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
780 void calcAbstAlphObs(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Transition,Idx>& rMapChangedTrans)
782 OP_DF("calcAbstAlphObs(" << rGenObs.Name() << ", rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTRans)");
795 // observer algorithm: In each step, a dynamic system is computed that fulfills the one-step observer condition.
796 // Iterative application of the bisimulation algorithm and the relabeling procedure yields an automaton rGenObs
797 // that, together with the new high-level alphabet rNewHighAlph fulfills the observer condition.
804 name = ("./Automata/Plots/" + rGenObs.Name() + "DynamicSystem_" + ToStringInteger(iterationCount));
812 name = ("./Automata/Plots/" + rGenObs.Name() + "Bisimulation_" + ToStringInteger(iterationCount));
818 // and relabel transitions in rGenObs if necessary. The high-level alphabet is modified accordingly
819 done=relabel(rGenObs, rControllableEvents, rNewHighAlph, mapStateToPartition, mapChangedTransReverse, rMapChangedTrans, mapRelabeledEvents);
825 void calcAbstAlphMSA(System& rGenObs, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents) {
826 OP_DF("calcAbstAlphMSA(" << rGenObs.Name() << "," << "rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
831 // the controllable events that have been changed by the called function are set in the System cGenObs
836 void calcAbstAlphMSA(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents) {
837 OP_DF("calcAbstAlphMSA(" << rGenObs.Name() << "," << "rControllableEvents, rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
846 if(rMapRelabeledEvents.find(rtIt->first.Ev) == rMapRelabeledEvents.end() ){// if the event does not exist, yet, a nex element in the map is created
848 if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
852 if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
859 void calcAbstAlphMSA(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Transition,Idx>& rMapChangedTrans)
861 OP_DF("calcAbstAlphMSA(" << rGenObs.Name() << ", rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTRans)");
874 // observer algorithm: In each step, a dynamic system is computed that fulfills the one-step observer condition.
875 // Iterative application of the bisimulation algorithm and the relabeling procedure yields an automaton rGenObs
876 // that, together with the new high-level alphabet rNewHighAlph fulfills the observer condition.
883 name = ("./Automata/Plots/" + rGenObs.Name() + "DynamicSystem_" + ToStringInteger(iterationCount));
892 name = ("./Automata/Plots/" + rGenObs.Name() + "Bisimulation_" + ToStringInteger(iterationCount));
898 // and relabel transitions in rGenObs if necessary. The high-level alphabet is modified accordingly
899 done=relabel(rGenObs, rControllableEvents, rNewHighAlph, mapStateToPartition, mapChangedTransReverse, rMapChangedTrans, mapRelabeledEvents);
905 // void calcAbstAlphObsOCC(System& rGenObs, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents){
906 // OP_DF("calcAbstAlphObsOCC(" << rGenObs.Name() << "," << "rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
907 // // The controllable events are separated from the System. All functions that are successively
920 // if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
923 // if(rGenObs.Alphabet().Exists(rtIt->second) )// FIXME: there seem to be relabeled transitions that do not exist
927 // // the controllable events that have been changed by the called function are set in the System cGenObs
931 // // calcAbstAlphObsOCC(rGenObs, rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTrans)
932 // void calcAbstAlphObsOCC(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Transition,Idx>& rMapChangedTrans)
934 // OP_DF("calcAbstAlphObsOCC(" << rGenObs.Name() << ", rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTRans)");
948 // // observer algorithm: In each step, a dynamic system is computed that fulfills the one-step observer condition
950 // // Iterative application of the bisimulation algorithm and the relabeling procedure yields an automaton rGenObs
951 // // that, together with the new high-level alphabet rNewHighAlph fulfills the observer condition and OCC.
957 // name = ("./Automata/Plots/" + rGenObs.Name() + "DynamicSystem_" + ToStringInteger(iterationCount));
967 // name = ("./Automata/Plots/" + rGenObs.Name() + "Bisimulation_" + ToStringInteger(iterationCount));
973 // // and relabel transitions in rGenObs if necessary. The high-level alphabet is modified accordingly
974 // done=relabel(rGenObs, rControllableEvents, rNewHighAlph, newPartitions, mapStateToPartition, mapChangedTransReverse, rMapChangedTrans, mapRelabeledEvents);
979 void calculateDynamicSystemObsOCC(const Generator& rGen, EventSet& rControllableEvents, EventSet& rHighAlph, Generator& rGenDyn){
980 OP_DF("calculateDynamicSystemObsOCC(" << rGen.Name() << "," << rControllableEvents.Name() << "," << rHighAlph.Name() << "," << rGenDyn.Name() << ")");
987 rGenDyn.InjectAlphabet(rHighAlph); // all high-level events are contained in the alphabet of rGenDyn
1000 map<Idx, map<Idx, bool> > exitLocalStatesMap; // map from each exit state to locally backward reachable states and a boolean that is false if there exists an uncontrollable path to the exit state
1001 map<Idx, StateSet> entryLocalStatesMap; // map from entry states to locally forward reachable states
1009 OP_DF("calculateDynamicSystemObsOCC: loop over all states; current state: " << rGen.StateName(*stIt)
1015 // which states can be reached on a controllable/uncontrollable path -> store in exitLocalStatesMap
1016 // in this case, also determine the corresponding entry states and compute their locally reachable states
1025 // if the local reach for the connected entry state has not been computed, yet, insert it in the
1033 // if the current state is an exit state, compute the backward local reach with the controllability properties of the
1037 exitLocalStatesMap[*stIt][*stIt] = false; // the exit state is reachable from the exit state via an uncontrollable path
1039 backwardReachabilityObsOCC(tset_X2EvX1, rControllableEvents, rHighAlph, *stIt, *stIt, false, exitLocalStatesMap, doneStates);
1044 // the generator rGenDyn is constructed by connecting all exit and entry states with their local state sets
1054 // go over all entry states reachable from the current exit state (via all feasible high-level events)
1058 OP_DF("calculateDynamicSystemObsOCC: insert transitions for the high-level event" << rGen.EventName(tsIt->Ev) << "[" << tsIt->Ev << "]");
1070 rGenDyn.SetTransition(lcIt->first,tsIt->Ev,*stIt); // insert a transition for each local state combination
1071 if( controllable || lcIt->second ){ // insert an clabel transition if the local path is controllable or the high-level event is controllable
1085 void forwardReachabilityObs(const Generator& rGen, const EventSet& rHighAlph, Idx lowState, Idx mLabel, Generator& rGenDyn) {
1086 OP_DF("forwardReachabilityObs(" << rGen.Name() << "," << rHighAlph.Name() << "," << lowState << "," << rGenDyn.EventName(mLabel) << "," << rGenDyn.Name() << ")");
1094 // algorithm: the locally reachable states from lowState are evaluated. If a reachable state is marked,
1131 // backwardReachabilityObsOCC(rTransSetX2EvX1, rControllableEvents, rHighAlph, exitState, currentState, controllablePath, rExitLocalStatesMap, rDoneStates)
1132 void backwardReachabilityObsOCC(const TransSetX2EvX1& rTransSetX2EvX1, const EventSet& rControllableEvents, const EventSet& rHighAlph, Idx exitState, Idx currentState, bool controllablePath, map<Idx, map<Idx, bool> >& rExitLocalStatesMap, StateSet& rDoneStates){
1133 OP_DF("backwardReachabilityObsOCC(rTransSetX2EvX1," << rControllableEvents.Name() << "," << rHighAlph.Name() << "," << exitState << "," << currentState << "," << controllablePath << ",rExitLocalStatesMap, rDoneStates)");
1134 // go along all backward transitions. Discard the goal state if it is reached via a high-level event or if it is in the rDoneStates and
1142 // we iterate over all backward transitions of the currentState to establish backward reachability
1144 // states reachable via a high-level event are not in the local backward reach and the controllability property of the current exitState does not change
1146 // if the state has not been visited, yet, the controllability of the current path are set in the rExitLocalStatesMap
1149 // the path is controllable if the current transition has a controllable event or the path was already controllable
1153 backwardReachabilityObsOCC(rTransSetX2EvX1, rControllableEvents, rHighAlph, exitState, tsIt->X1, currentControllablePath, rExitLocalStatesMap, rDoneStates);
1155 else{ // for an existing state, the controllability value can change from uncontrollable to controllable (if
1156 // a new controllable path has been found). It is important to note, that the OCC condition implies that
1157 // if there is one controllable path, then the the state is flagged controllable except for the case of the
1160 if(rExitLocalStatesMap[exitState][tsIt->X1] != currentControllablePath && currentControllablePath == true){
1162 // as the controllabiity attribute of the current state changed it is subject to a new backward reachability
1163 backwardReachabilityObsOCC(rTransSetX2EvX1, rControllableEvents, rHighAlph, exitState, tsIt->X1, true, rExitLocalStatesMap, rDoneStates);
1171 void calcAbstAlphObsLCC(System& rGenObs, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents){
1172 OP_DF("calcAbstAlphObsLCC(" << rGenObs.Name() << "," << "rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
1193 // the controllable events that have been changed by the called function are set in the System cGenObs
1198 void calcAbstAlphObsLCC(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Transition,Idx>& rMapChangedTrans)
1200 OP_DF("calcAbstAlphObsLCC(" << rGenObs.Name() << ", rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTRans)");
1213 // observer algorithm: In each step, a dynamic system is computed that fulfills the one-step observer condition
1215 // Iterative application of the bisimulation algorithm and the relabeling procedure yields an automaton rGenObs
1216 // that, together with the new high-level alphabet rNewHighAlph fulfills the observer condition and LCC.
1224 name = ("./Automata/Plots/" + rGenObs.Name() + "DynamicSystem_" + ToStringInteger(iterationCount));
1232 name = ("./Automata/Plots/" + rGenObs.Name() + "Bisimulation_" + ToStringInteger(iterationCount));
1238 // and relabel transitions in rGenObs if necessary. The high-level alphabet is modified accordingly
1239 done=relabel(rGenObs, rControllableEvents, rNewHighAlph, mapStateToPartition, mapChangedTransReverse, rMapChangedTrans, mapRelabeledEvents);
1245 void calcAbstAlphMSALCC(System& rGenObs, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Idx,set<Idx > > & rMapRelabeledEvents){
1246 OP_DF("calcAbstAlphMSALCC(" << rGenObs.Name() << "," << "rHighAlph, rNewHighAlph, rMapRelabeledEvents)");
1267 // the controllable events that have been changed by the called function are set in the System cGenObs
1272 void calcAbstAlphMSALCC(Generator& rGenObs, EventSet& rControllableEvents, EventSet& rHighAlph, EventSet& rNewHighAlph, map<Transition,Idx>& rMapChangedTrans)
1274 OP_DF("calcAbstAlphMSALCC(" << rGenObs.Name() << ", rControllableEvents, rHighAlph, rNewHighAlph, rMapChangedTRans)");
1287 // observer algorithm: In each step, a dynamic system is computed that fulfills the one-step observer condition
1289 // Iterative application of the bisimulation algorithm and the relabeling procedure yields an automaton rGenObs
1290 // that, together with the new high-level alphabet rNewHighAlph fulfills the observer condition and LCC.
1298 name = ("./Automata/Plots/" + rGenObs.Name() + "DynamicSystem_" + ToStringInteger(iterationCount));
1306 name = ("./Automata/Plots/" + rGenObs.Name() + "Bisimulation_" + ToStringInteger(iterationCount));
1312 // and relabel transitions in rGenObs if necessary. The high-level alphabet is modified accordingly
1313 done=relabel(rGenObs, rControllableEvents, rNewHighAlph, mapStateToPartition, mapChangedTransReverse, rMapChangedTrans, mapRelabeledEvents);
1319 void calculateDynamicSystemObsLCC(const Generator& rGen, EventSet& rControllableEvents, EventSet& rHighAlph, Generator& rGenDyn){
1320 OP_DF("calculateDynamicSystemObsLCC(" << rGen.Name() << "," << rControllableEvents.Name() << "," << rHighAlph.Name() << "," << rGenDyn.Name() << ")");
1339 map<Idx, map<Idx, bool> > exitLocalStatesMap; // map from each exit state to locally backward reachable states and a boolean that is false if there exists an uncontrollable path to the exit state
1340 map<Idx, StateSet> entryLocalStatesMap; // map from entry states to locally forward reachable states
1348 OP_DF("calculateDynamicSystemObsLCC: loop over all states; current state: " << rGen.StateName(*stIt)
1354 // which states can be reached on a controllable/uncontrollable path -> store in exitLocalStatesMap
1355 // in this case, also determine the corresponding entry states and compute their locally reachable states
1364 // if the local reach for the connected entry state has not been computed, yet, insert it in the
1372 // if the current state is an exit state, compute the backward local reach with the controllability properties of the
1376 exitLocalStatesMap[*stIt][*stIt] = false; // the exit state is reachable from the exit state via an uncontrollable path
1378 backwardReachabilityObsLCC(tset_X2EvX1, rControllableEvents, rHighAlph, *stIt, *stIt, false, exitLocalStatesMap, doneStates);
1383 // the generator rGenDyn is constructed by connecting all exit and entry states with their local state sets
1393 // go over all entry states reachable from the current exit state (via all feasible high-level events)
1397 OP_DF("calculateDynamicSystemObsLCC: insert transitions for the high-level event" << rGen.EventName(tsIt->Ev) << "[" << tsIt->Ev << "]");
1409 rGenDyn.SetTransition(lcIt->first,tsIt->Ev,*stIt); // insert a transition for each local state combination
1410 if( !(controllable || lcIt->second) ){ // insert an uclabel transition if the local path is uncontrollable
1423 // backwardReachabilityObsLCC(crTransSetX2EvX1, rControllableEvents, rHighAlph, exitState, currentState, controllablePath, rExitLocalStatesMap, rDoneStates)
1424 void backwardReachabilityObsLCC(const TransSetX2EvX1& rTransSetX2EvX1, const EventSet& rControllableEvents, const EventSet& rHighAlph, Idx exitState, Idx currentState, bool controllablePath, map<Idx, map<Idx, bool> >& rExitLocalStatesMap, StateSet& rDoneStates){
1425 OP_DF("backwardReachabilityObsOCC(rTransSetX2EvX1," << rControllableEvents.Name() << "," << rHighAlph.Name() << "," << exitState << "," << currentState << "," << controllablePath << ",rExitLocalStatesMap, rDoneStates)");
1426 // go along all backward transitions. Discard the goal state if it is reached via a high-level event or if it is in the rDoneStates and
1434 // we iterate over all backward transitions of the currentState to establish backward reachability
1436 // states reachable via a high-level event are not in the local backward reach and the controllability property of the current exitState does not change
1438 // if the state has not been visited, yet, the controllability of the current path are set in the rExitLocalStatesMap
1441 // the path is uncontrollable if the current transition has an uncontrollable event or the path was already uncontrollable
1445 backwardReachabilityObsLCC(rTransSetX2EvX1, rControllableEvents, rHighAlph, exitState, tsIt->X1, currentControllablePath, rExitLocalStatesMap, rDoneStates);
1447 else{ // for an existing state, the controllability value can change from controllable to uncontrollable (if
1448 // a new uncontrollable path has been found). It is important to note, that the LCC condition implies that
1449 // if there is one uncontrollable path, then the state is flagged uncontrollable except for the case of the
1452 if(rExitLocalStatesMap[exitState][tsIt->X1] != currentControllablePath && currentControllablePath == false){
1454 // as the controllabiity attribute of the current state changed it is subject to a new backward reachability
1455 backwardReachabilityObsLCC(rTransSetX2EvX1, rControllableEvents, rHighAlph, exitState, tsIt->X1, false, rExitLocalStatesMap, rDoneStates);
1462 // relabel(rGenRelabel, rControllableEvents, rHighAlph, rMapStateToPartition, rMapChangedTransReverse, rMapChangedTrans, rMapRelabeledEvents)
1463 bool relabel(Generator& rGenRelabel, EventSet& rControllableEvents, EventSet& rHighAlph, map<Idx,Idx>& rMapStateToPartition, map<Transition,Transition>& rMapChangedTransReverse, map<Transition,Idx>& rMapChangedTrans, map<Idx, EventSet>& rMapRelabeledEvents)
1466 OP_DF("relabel(" << rGenRelabel.Name() << "," << rControllableEvents.Name() << "," << rHighAlph.Name() << ", rMapStateToPartition, rMapChangedTransReverse, rMapChangedTrans, rMapRelabeledEvents)");
1489 // algorithm: The relabeling according to the state partition as computed by the bisimulation algorithm is
1490 // performed. A high-level transitions is relebaled with a new event, if a transition with the same event leads
1491 // from the same coset to a different coset (non-determinism in the projected automaton). A low-level transition
1492 // is relabeled if it connects different cosets (corresponds to unobservable transition betweeen cosets). The
1493 // also has build-in procedures to take care that as few new event labels as possible are introduced.
1508 // In the first case, there exists no entry for this transition in mapRelabel. Hence, this is the
1516 // Otherwise, there exists an entry for the current event leaving the current X1-coset. It has to be
1517 // verified if the transition goes to the same coset as the previously found transitions or not.
1520 // check if a transition with the same event has already been found that enters the same X2-coset. If
1522 if(mapRelabel[indexX1Partition][tIt->Ev].find(indexX2Partition) != mapRelabel[indexX1Partition][tIt->Ev].end())
1526 OP_DF("relabel: the same event leading to the same X2-coset has already been relabeld before. The current transition is relabeld correspondingly");
1529 newPair.second = Transition(tIt->X1,mapRelabel[indexX1Partition][tIt->Ev][indexX2Partition],tIt->X2);
1533 OP_DF("relabel: There already exists a high-level transition from the current X1-coset to the same X2-coset and the current transition ist labeled with the same event. No relabeling necessary");
1582 std::string eventName = ( rGenRelabel.EventSymbolTablep())->UniqueSymbol(rGenRelabel.EventSymbolTablep()->Symbol(tIt->Ev) + "newHLevent_1");
1590 OP_DF("relabel: No event that can be reused could be found. The new event " << rGenRelabel.EventName(newLabel) << " was created");
1613 std::string eventName = ( rGenRelabel.EventSymbolTablep())->UniqueSymbol(rGenRelabel.EventSymbolTablep()->Symbol(tIt->Ev) + "newHLevent_1");
1657 // a transition with the same original event tIt->Ev leaving the X1-coset has been found before
1658 // and it entered a different X2-coset. Check if one of them was relabeled with lsIt. If yes, then lsIt can
1660 if(mapRelabel[indexX1Partition][tIt->Ev].find(indexX2Partition) == mapRelabel[indexX1Partition][tIt->Ev].end())
1680 newPair.second = Transition(tIt->X1,mapRelabel[indexX1Partition][tIt->Ev][indexX2Partition],tIt->X2);
1682 OP_DF("relabel: A transition to same X2-coset has already been found and relabeled before; the current transition is also labeled with " << rGenRelabel.EventName(mapRelabel[indexX1Partition][tIt->Ev][indexX2Partition]));
1695 OP_DF("relabele: Low level event " << rGenRelabel.EventName(tIt->Ev) << " is relabeled with " << rGenRelabel.EventName(*lsIt) << " which can be reused");
1704 std::string eventName = ( rGenRelabel.EventSymbolTablep())->UniqueSymbol(rGenRelabel.EventSymbolTablep()->Symbol(tIt->Ev) + "newHLevent_1"); //??
1712 OP_DF("relabel: No label could be reused, and the new event " << rGenRelabel.EventName(newLabel) << " was created");
1731 // It is possible that events need not be relabeled. For example, if all occurrences of a low-level event have to
1732 // be relabeled and added to the high-level alphabet, it is possible to just add the original low-level event
1733 // to the high-level alphabet without any relabeling. Note that this information is only available after all
1747 OP_DF("relabel: Checking transition X1=" << rGenRelabel.StateName(etSetIt->first->X1)<< " ["<<etSetIt->first->X1
1748 << "] Ev=" << rGenRelabel.EventName(oldEvent) << " X2=" << rGenRelabel.StateName(etSetIt->first->X2)
1749 << " [" << etSetIt->first->X2 << "] which shall be relabeled with event " << rGenRelabel.EventName(newEvent));
1750 // check if the original event is a low-level event and if there is an event left that has not been relabeled. If all events are relabeled, then at least one label can be replaced by the original event label.
1751 if(notRelabeledLowEvents.find(oldEvent) == notRelabeledLowEvents.end() && !rHighAlph.Exists(oldEvent))
1755 // if a low-level event has been relabeled, the automaton under investigation is not the desired quotient automaton, yet.
1757 // if newEvent is the first new event created for relabeling oldEvent, the relabeling is discarded
1761 // if newEvent is the only event created for relabeling oldEvent, delete newEvent from rGenRelabel
1775 // find predecessor of newEvent in map rMapRelabeledEvents[oldEvent] and use that event for relabeling
1787 // as the relabeling of oldEvent is discarded, it is removed from the map of relebeled events and
1790 // mofidy alphabet of rGenRelabel and the abstraction alphabet by inserting the new high-level events and deleting the not needed new event labels.
1803 rControllableEvents.Erase(*setIt); // controllable event is erased if it does not exist anymore. Schmidt 10/07
1807 // check if quotient automaton is deterministic and free of unobservable transitions, i.e., no transitions are relabeled and no low-level events are declared as high-level events
1821 // if the current relabeled transition has already been relabeled in a previous step of the observer algorithm, the original transition is found in the rMapChangedTransReverse map.
1828 OP_DF("relabel: The transition X1= " << rGenRelabel.SStr((etSetIt->first)->X1) << " Ev=" << rGenRelabel.EStr((etSetIt->first)->Ev) << " X2= " << rGenRelabel.SStr((etSetIt->first)->X2) << " has already been relabeled in a former iteration step. The original transition was " << rGenRelabel.SStr(originalTrans.X1) << " Ev=" << rGenRelabel.EStr(originalTrans.Ev) << " X2= " << rGenRelabel.SStr(originalTrans.X2) << "; the new label is " << rGenRelabel.EStr((etSetIt->second).Ev));
1830 // the current relabeled transition is simply inserted in the rMapChangedTrans map with its original transition if it is the first relabeling.
1836 << " Ev=" << rGenRelabel.EStr((etSetIt->first)->Ev) << " X2= " << rGenRelabel.SStr((etSetIt->first)->X2) << " new label is " << rGenRelabel.EStr((etSetIt->second).Ev));
1848 void insertRelabeledEvents(System& rGenPlant, const map<Idx,set<Idx> >& rMapRelabeledEvents, Alphabet& rNewEvents) {
1871 void insertRelabeledEvents(Generator& rGenPlant, const map<Idx,set<Idx> >& rMapRelabeledEvents, EventSet& rNewEvents) {
1903 void insertRelabeledEvents(Generator& rGenPlant, const map<Idx,set<Idx> >& rMapRelabeledEvents) {
1927 void insertRelabeledEvents(Generator& rGenPlant, const EventRelabelMap& rMapRelabeledEvents, EventSet& rNewEvents) {
1955 bool EventRelabelMap::DoEqual(const EventRelabelMap& rOther) const { return mMap==rOther.mMap;}
Helper functions for projected generators. #define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase) faudes type implementation macros, overall Definition: cfl_types.h:946 Attribute class to model event controllability properties. Definition: cfl_cgenerator.h:56 Rti convenience wrapper for relabeling maps. Definition: op_observercomputation.h:1097 virtual ~EventRelabelMap(void) Definition: op_observercomputation.cpp:1948 virtual void DoAssign(const EventRelabelMap &rSrc) Definition: op_observercomputation.cpp:1954 virtual bool DoEqual(const EventRelabelMap &rOther) const Definition: op_observercomputation.cpp:1955 const std::map< Idx, std::set< Idx > > & StlMap(void) const Definition: op_observercomputation.cpp:1958 std::map< Idx, std::set< Idx > > mMap Definition: op_observercomputation.h:1114 Iterator class for high-level api to TBaseSet. Definition: cfl_baseset.h:387 Iterator BeginByX2(Idx x2) const Iterator to first Transition specified by successor state x2. Definition: cfl_transset.h:1385 Iterator EndByX2(Idx x2) const Iterator to first Transition after specified successor state x2. Definition: cfl_transset.h:1396 TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator Iterator on transition. Definition: cfl_transset.h:269 void EventAttribute(Idx index, const EventAttr &rAttr) Set attribute for existing event. Definition: cfl_agenerator.h:1287 bool InsEvent(Idx index) Add an existing event to alphabet by index. Definition: cfl_agenerator.h:1094 const TaEventSet< EventAttr > & Alphabet(void) const Return const reference to alphabet. Definition: cfl_agenerator.h:1358 bool SetTransition(Idx x1, Idx ev, Idx x2) Add a transition to generator by indices. Definition: cfl_agenerator.h:1197 EventSet ControllableEvents(void) const Get EventSet with controllable events. Definition: cfl_cgenerator.h:1124 Triple (X1,Ev,X2) to represent current state, event and next state. Definition: cfl_transset.h:57 Base class of all libFAUDES objects that participate in the run-time interface. Definition: cfl_types.h:239 std::string ToString(const std::string &rLabel="", const Type *pContext=0) const Write configuration data to a string. Definition: cfl_types.cpp:169 StateSet::Iterator StatesBegin(void) const Iterator to Begin() of state set. Definition: cfl_generator.cpp:1057 const TransSet & TransRel(void) const Return reference to transition relation. Definition: cfl_generator.cpp:1888 bool SetTransition(Idx x1, Idx ev, Idx x2) Add a transition to generator by indices. Definition: cfl_generator.cpp:1626 const EventSet & Alphabet(void) const Return const reference to alphabet. Definition: cfl_generator.cpp:1878 TransSet::Iterator TransRelBegin(void) const Iterator to Begin() of transition relation. Definition: cfl_generator.cpp:1067 void ClrTransition(Idx x1, Idx ev, Idx x2) Remove a transition by indices. Definition: cfl_generator.cpp:1660 SymbolTable * EventSymbolTablep(void) const Get Pointer to EventSymbolTable currently used by this vGenerator. Definition: cfl_generator.cpp:813 virtual void EventAttribute(Idx index, const Type &rAttr) Set attribute for existing event. Definition: cfl_generator.cpp:1722 void InjectStates(const StateSet &rNewStates) Inject a complete state set without consistency checks (without attributes) Definition: cfl_generator.cpp:1278 EventSet::Iterator AlphabetBegin(void) const Iterator to Begin() of alphabet. Definition: cfl_generator.cpp:1047 std::string TStr(const Transition &rTrans) const Return pretty printable transition (eg for debugging) Definition: cfl_generator.cpp:3841 virtual void DotWrite(const std::string &rFileName) const Writes generator to dot input format. Definition: cfl_generator.cpp:3000 StateSet::Iterator StatesEnd(void) const Iterator to End() of state set. Definition: cfl_generator.cpp:1062 TransSet::Iterator TransRelEnd(void) const Iterator to End() of transition relation. Definition: cfl_generator.cpp:1072 std::string EStr(Idx index) const Pretty printable event name for index (eg for debugging). Definition: cfl_generator.cpp:3828 bool InsEvent(Idx index) Add an existing event to alphabet by index. Definition: cfl_generator.cpp:1198 EventSet::Iterator AlphabetEnd(void) const Iterator to End() of alphabet. Definition: cfl_generator.cpp:1052 std::string SStr(Idx index) const Return pretty printable state name for index (eg for debugging) Definition: cfl_generator.cpp:3834 bool ExistsMarkedState(Idx index) const Test existence of state in mMarkedStates. Definition: cfl_generator.cpp:1806 void InjectAlphabet(const EventSet &rNewalphabet) Set mpAlphabet without consistency check. Definition: cfl_generator.cpp:1170 virtual void InsertSet(const TBaseSet &rOtherSet) Insert elements given by rOtherSet. Definition: cfl_baseset.h:1987 virtual const AttributeVoid & Attribute(const T &rElem) const Attribute access. Definition: cfl_baseset.h:2290 void ComputeBisimulation(const Generator &rGenOrig, map< Idx, Idx > &rMapStateToPartition) Computation of the coarsest bisimulation relation for a specified generator. Definition: cfl_bisimulation.cpp:1272 Int calcMSAObserverLCC(const Generator &rGen, const EventSet &rControllableEvents, EventSet &rHighAlph) MSA-observer computation including local control consistency (LCC) by adding events to the high-level... Definition: op_observercomputation.cpp:497 Idx calcClosedObserver(const Generator &rGen, EventSet &rHighAlph) L(G)-observer computation by adding events to the high-level alphabet. Definition: op_observercomputation.cpp:413 Int calcNaturalObserverLCC(const Generator &rGen, const EventSet &rControllableEvents, EventSet &rHighAlph) Lm(G)-observer computation including local control consistency (LCC) by adding events to the high-lev... Definition: op_observercomputation.cpp:454 void ExtendHighAlphabet(const Generator &rGen, EventSet &rHighAlph, map< Idx, Idx > &rMapStateToPartition) Extension of the high-level alphabet to achieve the Lm-observer property. Definition: op_observercomputation.cpp:520 Int calcNaturalObserver(const Generator &rGen, EventSet &rHighAlph) Lm(G)-observer computation by adding events to the high-level alphabet. Definition: op_observercomputation.cpp:433 Int calcMSAObserver(const Generator &rGen, EventSet &rHighAlph) MSA-observer computation by adding events to the high-level alphabet. Definition: op_observercomputation.cpp:476 bool recursiveCheckMSABackward(const Generator &rGen, const TransSetX2EvX1 &rRevTransSet, const EventSet &rHighAlph, Idx currentState, StateSet &rDoneStates) Check if the msa-observer conditions is fulfilled for a given state. Definition: op_observercomputation.cpp:278 void calcAbstAlphObs(System &rGenObs, EventSet &rHighAlph, EventSet &rNewHighAlph, EventRelabelMap &rMapRelabeledEvents) Rti convenience wrapper. Definition: op_observercomputation.cpp:1914 void recursiveCheckLCC(const TransSetX2EvX1 &rRevTransSet, const EventSet &rControllableEvents, const EventSet &rHighAlph, Idx currentState, StateSet &rDoneStates) Find states that fulfill the lcc condition. Definition: op_observercomputation.cpp:387 void calcAbstAlphMSA(Generator &rGenObs, EventSet &rControllableEvents, EventSet &rHighAlph, EventSet &rNewHighAlph, map< Transition, Idx > &rMapChangedTrans) MSA-observer computation. Definition: op_observercomputation.cpp:859 void calculateDynamicSystemMSA(const Generator &rGen, EventSet &rHighAlph, Generator &rGenDyn) Computation of the dynamic system for Delta_msa (local fulfillment of the msa-observer property). Definition: op_observercomputation.cpp:195 void insertRelabeledEvents(Generator &rGenPlant, const EventRelabelMap &rMapRelabeledEvents) Rti convenience wrapper. Definition: op_observercomputation.cpp:1934 void calculateDynamicSystemClosedObs(const Generator &rGen, EventSet &rHighAlph, Generator &rGenDyn) Computation of the dynamic system for Delta_sigma (reachable states after the occurrence of one high-... Definition: op_observercomputation.cpp:46 void calculateDynamicSystemLCC(const Generator &rGen, const EventSet &rControllableEvents, const EventSet &rHighAlph, Generator &rGenDyn) Computation of the dynamic system for Delta_lcc (fulfillment of the local control consistency propert... Definition: op_observercomputation.cpp:303 void LocalCoaccessibleReach(const TransSetX2EvX1 &rRevTransRel, const EventSet &rHighAlph, Idx lowState, StateSet &rCoaccessibleReach) Compute the coaccessible reach for a local automaton. Definition: cfl_localgen.cpp:129 void calcAbstAlphMSALCC(Generator &rGenObs, EventSet &rControllableEvents, EventSet &rHighAlph, EventSet &rNewHighAlph, map< Transition, Idx > &rMapChangedTrans) MSA-observer computation including local control consistency (LCC). Definition: op_observercomputation.cpp:1272 void LocalAccessibleReach(const Generator &rLowGen, const EventSet &rHighAlph, Idx lowState, StateSet &rAccessibleReach) Compute the accessible reach for a local automaton. Definition: cfl_localgen.cpp:161 bool CheckSplit(const Generator &rGen, const EventSet &rSplitAlphabet, const vector< pair< StateSet, Idx > > &rNondeterministicStates, Idx entryState) Definition: op_observercomputation.cpp:634 void backwardReachabilityObsOCC(const TransSetX2EvX1 &rTransSetX2EvX1, const EventSet &rControllableEvents, const EventSet &rHighAlph, Idx exitState, Idx currentState, bool controllablePath, map< Idx, map< Idx, bool > > &rExitLocalStatesMap, StateSet &rDoneStates) Definition: op_observercomputation.cpp:1132 bool recursiveCheckMSAForward(const Generator &rGen, const EventSet &rHighAlph, Idx currentState, StateSet &rDoneStates) Check if the msa-observer conditions is fulfilled for a given state. Definition: op_observercomputation.cpp:252 bool relabel(Generator &rGenRelabel, EventSet &rControllableEvents, EventSet &rHighAlph, map< Idx, Idx > &rMapStateToPartition, map< Transition, Transition > &rMapChangedTransReverse, map< Transition, Idx > &rMapChangedTrans, map< Idx, EventSet > &rMapRelabeledEvents) Relabeling algorithm for the computation of an Lm-observer. Definition: op_observercomputation.cpp:1463 void calcAbstAlphClosed(Generator &rGenObs, EventSet &rControllableEvents, EventSet &rHighAlph, EventSet &rNewHighAlph, map< Transition, Idx > &rMapChangedTrans) L(G)-observer computation. Definition: op_observercomputation.cpp:701 void calcAbstAlphObsLCC(Generator &rGenObs, EventSet &rControllableEvents, EventSet &rHighAlph, EventSet &rNewHighAlph, map< Transition, Idx > &rMapChangedTrans) Lm-observer computation including local control consistency (LCC). Definition: op_observercomputation.cpp:1198 long int Int Type definition for integer type (let target system decide, minimum 32bit) Definition: cfl_definitions.h:47 void calculateDynamicSystemObs(const Generator &rGen, EventSet &rHighAlph, Generator &rGenDyn) Computation of the dynamic system for Delta_obs (local reachability of a marked state). Definition: op_observercomputation.cpp:159 Methods to compute natural projections that exhibit the observer property. libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen |