|
|
||||||
|
diag_eventdiagnosis.cpp
Go to the documentation of this file.
2 Functions to check a system's event-diagnosability and computation of an event-diagnoser. Covers diagnosability with respect to failure events (diagnosability, I-diagnosability).
13 bool IsEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, string& rReportString) {
28 for (ftIt = rFailureTypeMap.mFailureTypeMap.Begin(); ftIt != rFailureTypeMap.mFailureTypeMap.End(); ftIt++) {
30 FD_DD("IsEventDiagnosable(): Warning: Existing indicator events are ignored! If you want to check for I-diagnosability use IsIdiagnosable() instead.");
31 rReportString.append("IsEventDiagnosable(): Warning: Existing indicator events are ignored! If you want to check for I-diagnosability use IsIdiagnosable() instead.\n");
43 for (ftIt = rFailureTypeMap.mFailureTypeMap.Begin(); ftIt != rFailureTypeMap.mFailureTypeMap.End(); ftIt++) {
45 + " with failures " + rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mFailureEvents.ToString());
50 ComputeGobs(rGen, rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt), rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mFailureEvents, genGobs);
52 //genGobs.GraphWrite("tmp_Gobs_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
64 if(ExistsViolatingCyclesInGd(genGd, genGobs, reverseCompositionMap, rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt), rReportString)) {
66 //genGd.GraphWrite("tmp_Gd_pruned_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
70 //genGd.GraphWrite("tmp_Gd_pruned_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
85 bool IsIndicatorEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, string& rReportString) {
97 for (ftIt = rFailureTypeMap.mFailureTypeMap.Begin(); ftIt != rFailureTypeMap.mFailureTypeMap.End(); ftIt++) {
99 FD_DD("IsIndicatorEventDiagnosable(): Warning: There are no indicator events for failure type " << rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) << "!");
100 rReportString.append("IsIndicatorEventDiagnosable(): Warning: There are no indicator events for failure type " + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + "!\n");
110 for (ftIt = rFailureTypeMap.mFailureTypeMap.Begin(); ftIt != rFailureTypeMap.mFailureTypeMap.End(); ftIt++) {
117 ComputeGobs(rGen, rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt), rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mFailureEvents, genGobs);
119 //genGobs.GraphWrite("tmp_I_Gobs_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
129 // Additionally for I-diagnosability: Remove all traces which do not contain a failure event followed by an indicator event
130 FD_DD("Removing all traces not containing an indicator event " + rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mIndicatorEvents.ToString());
131 TrimNonIndicatorTracesOfGd(genGd, genGobs, *ftIt, rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mIndicatorEvents, reverseCompositionMap);
132 //genGd.Write("tmp_I_Gd_iTraces_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".gen");
133 //genGd.GraphWrite("tmp_I_Gd_iTraces_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
137 if(ExistsViolatingCyclesInGd(genGd, genGobs, reverseCompositionMap, rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt), rReportString)) {
138 //genGd.Write("tmp_I_Gd_pruned_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".gen");
139 //genGd.GraphWrite("tmp_I_Gd_pruned_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
142 //genGd.Write("tmp_I_Gd_pruned_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".gen");
143 //genGd.GraphWrite("tmp_I_Gd_pruned_" + rFailureTypeMap.mFailureTypeMap.SymbolicName(*ftIt) + ".png");
153 bool IsIndicatorEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap) {
160 bool MeetsDiagnosabilityAssumptions(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, string& rReportString) {
165 for (ftIt = rFailureTypeMap.mFailureTypeMap.Begin(); ftIt != rFailureTypeMap.mFailureTypeMap.End(); ftIt++) {
167 for (evIt = rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mFailureEvents.Begin(); evIt != rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mFailureEvents.End(); evIt++) {
170 errstr << "Failure " << rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mFailureEvents.SymbolicName(*evIt) << " is not in alphabet of generator!" << endl;
175 for (evIt = rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mIndicatorEvents.Begin(); evIt != rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mIndicatorEvents.End(); evIt++) {
178 errstr << "Indicator " << rFailureTypeMap.mFailureTypeMap.Attribute(*ftIt).mIndicatorEvents.SymbolicName(*evIt) << " is not in alphabet of generator!" << endl;
265 bool FailuresUnobservable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, string& rReport) {
274 FD_DD("FailuresUnobservable(): Failure event \"" << failures.SymbolicName(*evIt) << "\" is not unobservable in generator!");
275 rReport.append("Failure event \"" + failures.SymbolicName(*evIt) + "\" is observable in generator --> ");
306 bool ExistsCycleSearch(const System& rGen, StateSet& rTodo, Idx currState, StateSet statesOnPath, string& rReport) {
354 void CycleStartStatesSearch(const System& rGen, StateSet& rTodo, Idx currState, StateSet statesOnPath, StateSet& rCycleOriginStates) {
380 bool ExistsViolatingCyclesInGd(System& rGd, const Diagnoser& rGobs, map<pair<Idx,Idx>,Idx>& rReverseCompositionMap, const string& rFailureType, string& rReportString) {
390 FD_DD("state " << rcmIt->second << " (" << rcmIt->first.first << "," << rcmIt->first.second << ")");
391 // if both states in G_o are equal or just contain the same failure label: delete corresponding state in G_d
414 rReportString.append("While checking diagnosability for failure type " + rFailureType + ": " + \
423 void ComputeGobs(const System& rOrigGen, const string& rFailureType, const EventSet& rFailureEvents, Diagnoser& rGobs) {
431 void ComputeGobs(const System& rOrigGen, const AttributeFailureTypeMap& rAttrFTMap, Diagnoser& rGobs) {
479 map<Idx,multimap<Idx,DiagLabelSet> > reachMap; // maps executable events to all reachable states and occuring relative failure types
506 for(currDStateMapIt = currDStateMap.Begin(); currDStateMapIt != currDStateMap.End(); ++ currDStateMapIt){
510 ComputeReachability(rOrigGen, gUnobservableEvents, failureEvents, gStateEstimate, rAttrFTMap, reachMap);
528 FD_DD(endl << "_" << rOrigGen.EventName(it->first) << " ("<< it->second.size() << " state estimates)");
550 // if newAttr equals any existing state attribute than we create a transition to this very state
566 FD_DD("Create new state " << nextDState << " and transition " << currDState << " --" << rOrigGen.EventName(it->first) << "--> " << nextDState);
588 void ComputeGd(const Diagnoser& rGobs, map<pair<Idx,Idx>,Idx>& rReverseCompositionMap, System& rGd) {
614 TrimNonIndicatorTracesOfGdRecursive(rGd, rGobs, rFailureType, rIndicatorEvents, CompositionMap, rGd.InitState(), statesDone);
618 void TrimNonIndicatorTracesOfGdRecursive(System& rGd, const Diagnoser& rGobs, const Idx rFailureType,
645 // If there exists a self-loop of an indicator event (after the occurrence of a failure event), return.
646 // This needs to be checked because otherwise the following for-loop could cut parts of the future traces before noticing the self-loop.
670 // (we use the _next_ label (and not the last one) to make sure not to miss out failures that occur immediately before the indicator event)
683 // if transition event is not an indicator event or there did not occur a failure _before_ the indicator
693 // if there do not exist any further transitions form other states into the next state: continue trimming at next state
696 TrimNonIndicatorTracesOfGdRecursive(rGd, rGobs, rFailureType, rIndicatorEvents, rCompositionMap, nextState, rStatesDone);
703 void ComputeReachability(const System& rGen, const EventSet& rUnobsEvents, const EventSet& rFailures, Idx State,
704 const AttributeFailureTypeMap& rAttrFTMap, map<Idx,multimap<Idx,DiagLabelSet> >& rReachabilityMap) {
710 ComputeReachabilityRecursive(rGen, rUnobsEvents, rFailures, State, rAttrFTMap, rReachabilityMap, FTonPath);
736 multimap<Idx,DiagLabelSet> stateFailureTypeMap; // maps generator states onto occurred failure types (=labels), part of rReachabilityMap
748 FD_DD(tIt->X1 << "--" << rGen.EventName(tIt->Ev) << "-->" << tIt->X2 << " for " << FToccurred.ToString());
764 ComputeReachabilityRecursive(rGen, rUnobsEvents, rFailures, tIt->X2, rAttrFTMap, rReachabilityMap, newFT);
768 FD_DD(rGen.EventName(tIt->Ev) << " is observable: add it to rReachabilityMap " << FToccurred.ToString());
775 for (mmLabelIt = stateFailureTypeMap.begin(); mmLabelIt != stateFailureTypeMap.end(); mmLabelIt++) {
787 for (mmLabelIt = stateFailureTypeMap.lower_bound(tIt->X2); mmLabelIt != stateFailureTypeMap.upper_bound(tIt->X2); mmLabelIt++) {
816 void EventDiagnoser(const System& rOrigGen, const map<string,EventSet>& rFailureTypeMap, Diagnoser& rDiagGen) {
824 void EventDiagnoser(const System& rOrigGen, const AttributeFailureTypeMap& rAttrFTMap, Diagnoser& rDiagGen) {
881 map<Idx,multimap<Idx,DiagLabelSet> > reachMap; // maps executable events to all reachable states and occuring relative failure types
882 map<Idx,multimap<Idx,DiagLabelSet> > reachMapWholeState; // map for whole diagnoser state, contains propagated absolute failure type labels
916 for(currDStateMapIt = currDStateMap.Begin(); currDStateMapIt != currDStateMap.End(); ++ currDStateMapIt){
919 ComputeReachability(rOrigGen, gUnobservableEvents, failureEvents, gStateEstimate, rAttrFTMap, reachMap);
926 // parse through state failure type mappings of state failure type map (for current event in reachMap)
933 for (mmit2 = tmpPropagatedLabels.lower_bound(newState); mmit2 != tmpPropagatedLabels.upper_bound(newState); mmit2++) {
952 for (mmit2 = bufferPropLabels.lower_bound(mmit->first); mmit2 != bufferPropLabels.upper_bound(mmit->first); mmit2++) {
1020 void LabelPropagation(const DiagLabelSet& lastLabel, const DiagLabelSet& failureTypes, DiagLabelSet& newLabel) {
1058 // if there is only one label for a particular state: no correction is needed and the label is copied to diagnoser state attribute
1063 // if there are several labels: correct label before adding it to the diagnoser state attribute
Implements state estimates for the current status of the generator. Definition: diag_attrdiagstate.h:21 const TaIndexSet< DiagLabelSet > & DiagnoserStateMap(void) const Get mDiagnoserStateMap. Definition: diag_attrdiagstate.cpp:43 void AddStateLabelMap(Idx gstate, const DiagLabelSet &labels) Add state estimates to mDiagnoserStateMap. Definition: diag_attrdiagstate.cpp:71 Partitions the failure and indicator events. Definition: diag_attrfailuretypes.h:25 EventSet AllFailureEvents(void) const Obtain all failure events in mFailureTypeMap. Definition: diag_attrfailuretypes.cpp:132 TaNameSet< AttributeFailureEvents > mFailureTypeMap Failure and indicator event partition. Definition: diag_attrfailuretypes.h:36 void AddFailureTypeMap(const std::map< std::string, EventSet > &rFailureMap) Inserts entire failure type map to mFailureTypeMap. Definition: diag_attrfailuretypes.cpp:110 Idx AddFailureTypeMapping(const std::string &failureType, const EventSet &rfailureEvents) Add a set of failure events to failure type map. Definition: diag_attrfailuretypes.cpp:85 Idx FailureType(Idx failureEvent) const Returns failure type of failure event. Definition: diag_attrfailuretypes.cpp:120 Implements the label representation for state estimates. Definition: diag_attrlabelset.h:19 NameSet::Iterator Iterator Convenience definition of NameSet::Iterator. Definition: diag_attrlabelset.h:43 void InsertSet(const DiagLabelSet &rSet) Insert elements of rSet. Definition: diag_attrlabelset.cpp:99 void SymbolicName(Idx index, const std::string &rName) Set new name for existing index. Definition: cfl_nameset.cpp:400 Iterator class for high-level api to TBaseSet. Definition: cfl_baseset.h:396 Iterator BeginByX2(Idx x2) const Iterator to first Transition specified by successor state x2. Definition: cfl_transset.h:1389 Iterator EndByX2(Idx x2) const Iterator to first Transition after specified successor state x2. Definition: cfl_transset.h:1400 TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator Iterator on transition. Definition: cfl_transset.h:273 bool InsEvent(Idx index) Add an existing event to alphabet by index. Definition: cfl_agenerator.h:1096 const TaStateSet< StateAttr > & States(void) const Return reference to state set. Definition: cfl_agenerator.h:1365 const TaEventSet< EventAttr > & Alphabet(void) const Return const reference to alphabet. Definition: cfl_agenerator.h:1360 bool SetTransition(Idx x1, Idx ev, Idx x2) Add a transition to generator by indices. Definition: cfl_agenerator.h:1199 const ATransSet & TransRel(void) const Return reference to transition relation. Definition: cfl_agenerator.h:1370 void StateAttribute(Idx index, const StateAttr &rAttr) Set attribute for existing state. Definition: cfl_agenerator.h:1329 StateAttr * StateAttributep(Idx index) State attribute pointer (to access Attribute methods) note: may insert explicit default attribute. Definition: cfl_agenerator.h:1355 const Attr & Attribute(const Idx &rElem) const Definition: cfl_indexset.h:535 EventSet UnobservableEvents(void) const Get EventSet with unobservable events. Definition: cfl_cgenerator.h:1259 EventSet ObservableEvents(void) const Get EventSet with observable events. Definition: cfl_cgenerator.h:1247 Provides the structure and methods to build and handle diagnosers. Definition: diag_generator.h:26 EventSet GetAllFailureEvents(void) const Returns the all failure events of the failure partition. Definition: diag_generator.h:294 void InsStateLabelMapping(Idx dStateIndex, Idx gStateIndex, Idx labelIndex) Inserts a generator state estimate to a diagnoser state. Definition: diag_generator.h:299 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 InitStatesBegin(void) const Iterator to Begin() of mInitStates. Definition: cfl_generator.cpp:1150 bool InitStatesEmpty(void) const Check if set of initial states are empty. Definition: cfl_generator.cpp:663 EventSet ActiveEventSet(Idx x1) const Return active event set at state x1. Definition: cfl_generator.cpp:1938 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 TransSet ActiveTransSet(Idx x1) const Return active transition set at state x1. Definition: cfl_generator.cpp:1948 TransSet::Iterator TransRelEnd(void) const Iterator to End() of transition relation. Definition: cfl_generator.cpp:1072 Idx InsInitState(void) Create new anonymous state and set as initial state. Definition: cfl_generator.cpp:1287 StateSet::Iterator InitStatesEnd(void) const Iterator to End() of mInitStates. Definition: cfl_generator.cpp:1155 StateSet SuccessorStates(Idx x1) const Return the successor states of state x1. Definition: cfl_generator.cpp:1969 Functions to check a system's diagnosability with respect to failure events (diagnosability and I-dia... virtual void InsertSet(const TBaseSet &rOtherSet) Insert elements given by rOtherSet. Definition: cfl_baseset.h:1996 void EventDiagnoser(const System &rOrigGen, const AttributeFailureTypeMap &rAttrFTMap, Diagnoser &rDiagGen) Compute a standard diagnoser from an input generator and a failure partition. Definition: diag_eventdiagnosis.cpp:824 void Parallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen) Parallel composition. Definition: cfl_parallel.cpp:32 void ConvertParallelCompositionMap(const map< pair< Idx, Idx >, Idx > &rReverseCompositionMap, map< Idx, pair< Idx, Idx > > &rCompositionMap) Definition: diag_eventdiagnosis.cpp:210 bool ExistsViolatingCyclesInGd(System &rGd, const Diagnoser &rGobs, map< pair< Idx, Idx >, Idx > &rReverseCompositionMap, const string &rFailureType, string &rReportString) Definition: diag_eventdiagnosis.cpp:380 bool FailuresUnobservable(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap, string &rReport) Definition: diag_eventdiagnosis.cpp:265 void ComputeGd(const Diagnoser &rGobs, map< pair< Idx, Idx >, Idx > &rReverseCompositionMap, System &rGd) Definition: diag_eventdiagnosis.cpp:588 bool IsEventDiagnosable(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap) Function definition for run-time interface. Definition: diag_eventdiagnosis.cpp:78 void ComputeGobs(const System &rOrigGen, const AttributeFailureTypeMap &rAttrFTMap, Diagnoser &rGobs) Compute G_o for a given generator with a given failure partition (according to Jiang). Definition: diag_eventdiagnosis.cpp:431 TransSet ActiveBackwardTransSet(const System &rGen, Idx state) Obtain all transitions from other states into a given state of a generator. Definition: diag_eventdiagnosis.cpp:802 bool ExistsCycleSearch(const System &rGen, StateSet &rTodo, Idx currState, StateSet statesOnPath, string &rReport) Definition: diag_eventdiagnosis.cpp:306 bool IsIndicatorEventDiagnosable(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap) Function definition for run-time interface. Definition: diag_eventdiagnosis.cpp:153 bool ExistsCycle(const System &rGen, string &rReport) Definition: diag_eventdiagnosis.cpp:283 void CycleStartStatesSearch(const System &rGen, StateSet &rTodo, Idx currState, StateSet statesOnPath, StateSet &rCycleOriginStates) Auxiliary function for CycleStartStates(). Definition: diag_eventdiagnosis.cpp:354 void CycleStartStates(const System &rGen, StateSet &rCycleOrigins) Find all start/end states of cycles of unobservable events in a generator. Definition: diag_eventdiagnosis.cpp:334 void TrimNonIndicatorTracesOfGd(System &rGd, const Diagnoser &rGobs, const Idx rFailureType, const EventSet &rIndicatorEvents, const map< pair< Idx, Idx >, Idx > &rReverseCompositionMap) Definition: diag_eventdiagnosis.cpp:606 bool IsLive(const System &rGen, string &rReport) Definition: diag_eventdiagnosis.cpp:225 void ComputeReachability(const System &rGen, const EventSet &rUnobsEvents, const EventSet &rFailures, Idx State, const AttributeFailureTypeMap &rAttrFTMap, map< Idx, multimap< Idx, DiagLabelSet > > &rReachabilityMap) Definition: diag_eventdiagnosis.cpp:703 void LabelPropagation(const DiagLabelSet &lastLabel, const DiagLabelSet &failureTypes, DiagLabelSet &newLabel) Generate a new label. Definition: diag_eventdiagnosis.cpp:1020 void ComputeReachabilityRecursive(const System &rGen, const EventSet &rUnobsEvents, const EventSet &rFailures, Idx State, const AttributeFailureTypeMap &rAttrFTMap, map< Idx, multimap< Idx, DiagLabelSet > > &rReachabilityMap, const DiagLabelSet FToccurred) Definition: diag_eventdiagnosis.cpp:729 bool CycleOfUnobsEvents(const System &rGen, string &rReport) Definition: diag_eventdiagnosis.cpp:241 bool MeetsDiagnosabilityAssumptions(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap, string &rReportString) Definition: diag_eventdiagnosis.cpp:160 void TrimNonIndicatorTracesOfGdRecursive(System &rGd, const Diagnoser &rGobs, const Idx rFailureType, const EventSet &rIndicatorEvents, map< Idx, pair< Idx, Idx > > &rCompositionMap, Idx state, StateSet &rStatesDone) Definition: diag_eventdiagnosis.cpp:618 void LabelCorrection(const multimap< Idx, DiagLabelSet > &mm, AttributeDiagnoserState &attr) Definition: diag_eventdiagnosis.cpp:1047 libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen |