diag_eventdiagnosis.h

Go to the documentation of this file.
00001 /** @file diag_eventdiagnosis.h
00002 Functions to check a system's diagnosability with respect to failure events (diagnosability and I-diagnosability) and computation of an event-diagnoser.
00003 */
00004 
00005 #ifndef DIAG_EVENTDIAGNOSIS_H
00006 #define DIAG_EVENTDIAGNOSIS_H
00007 
00008 #include <vector>
00009 #include "corefaudes.h"
00010 #include "diag_debug.h"
00011 #include "diag_generator.h"
00012 #include "diag_attrdiagstate.h"
00013 #include "diag_attrfailureevents.h"
00014 #include "diag_attrfailuretypes.h"
00015 #include "diag_attrlabelset.h"
00016 
00017 
00018 namespace faudes {
00019 
00020 /** @name Functions (diagnosability with respect to a failure partition) */
00021 /** @{ doxygen group */
00022 
00023 /**
00024 Test a system's diagnosability with respect to a given failure partition.
00025 Standard diagnosability of a plant is validated with respect to a given failure %partition. According to: "A Polynomial Algorithm for Testing Diagnosability of Discrete Event Systems" by Shengbing Jiang, Zhongdong Huang, Vigyan Chandra, and Ratnesh Kumar.
00026 @param rGen
00027   Input generator, is a model of the original plant containing the relevant failures events.
00028 @param rFailureTypeMap
00029   Failure %partition: maps failure type names to failure events.  
00030 @param rReportString
00031   User-readable information of violating condition (in case of negative test result).
00032 @ingroup DiagnosisPlugIn
00033 */
00034 bool IsEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReportString);
00035 
00036 
00037 /**
00038 Test a system's I-diagnosability with respect to a given failure partition.
00039 Validates I-Diagnosability with respect to a given failure and indicator %partition. The algorithm is a modification of IsDiagnosable().
00040 @param rGen
00041   Input generator, is a model of the original plant containing the relevant failures events.
00042 @param rFailureTypeMap
00043   Failure %partition: maps failure type names to failure events and indicator events.  
00044 @param rReportString
00045   User-readable information of violating condition (in case of negative test result).
00046 @ingroup DiagnosisPlugIn
00047 */
00048 bool IsIndicatorEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReportString);
00049 
00050 /**
00051 Check if a generator meets the general assumptions of diagnosability as required by IsDiagnosable(const System&, const AttributeFailureTypeMap&, std::string&) and IsIndicatorDiagnosable(const System&, const AttributeFailureTypeMap&, std::string&).
00052 It is examined if the following assumptions hold:
00053 <ol>
00054   <li> The failure and indicator events are part of the generator's alphabet. </li>
00055   <li> The generator is live. </li>
00056   <li> There do not exist any cycles of unobservable events. </li> 
00057   <li> All failure events are unobservable. </li>
00058 </ol>
00059 @param rGen
00060   Input generator, is a model of the original plant containing the relevant failures events.
00061 @param rFailureTypeMap
00062   Failure %partition: maps failure type names to failure events and indicator events.  
00063 @param rReportString
00064   User-readable information of violationg condition (in case of negative result).
00065 @return
00066   True if all assumptions are met. 
00067 @exception Exception
00068   - A failure event does not form part of the alphabet of the generator (id 302).
00069   - A indicator event does not form part of the alphabet of the generator (id 303).  
00070 @ingroup DiagnosisPlugIn
00071 */
00072 bool MeetsDiagnosabilityAssumptions(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReportString);
00073 
00074 /** @} doxygen group */
00075 
00076 
00077 /**
00078 Convert the reverse composition map of Parallel() by switching first and second entry.
00079 @param rReverseCompositionMap
00080   Input map as generated by Parallel().
00081 @param rCompositionMap
00082   Converted map.
00083 */
00084 void ConvertParallelCompositionMap(  const std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap, 
00085                         std::map<Idx,std::pair<Idx,Idx> >& rCompositionMap);
00086                         
00087 /** 
00088 Test if a generator is live.
00089 @param rGen
00090   Input generator.
00091 @param rReport
00092   User-readable information of violating condition (in case of negative result).
00093 @return
00094   True if generator is live.
00095 */
00096 bool IsLive(const System &rGen, std::string& rReport);
00097 
00098 /** 
00099 Test if there exist any cycles of unobservable events in a generator.
00100 @param rGen
00101   Input generator.
00102 @param rReport
00103   User-readable information of violating condition (in case of positive test result).
00104 @return
00105   True if there exists a cycle of unobservable events.
00106 */
00107 bool CycleOfUnobsEvents(const System& rGen, std::string& rReport);
00108 
00109 /**
00110 Check if all failure events are unobservable events in a generator's alphabet.
00111 @param rGen
00112   Input generator, is a model of the original plant containing the relevant failures events.
00113 @param rFailureTypeMap
00114   Failure %partition: maps failure type names to failure events and indicator events.  
00115 @param rReport
00116   User-readable information of violating condition (in case of negative result).
00117 @return
00118   True if all failures events are unobservable.
00119 */
00120 bool FailuresUnobservable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReport);
00121 
00122 /** 
00123 Test if there exist any cycles in a generator.
00124 @param rGen
00125   Input generator.
00126 @param rReport
00127   User-readable information of violating condition (in case of positive test result).
00128 @return
00129   True if there exists a cycle.
00130 */
00131 bool ExistsCycle(const System& rGen, std::string& rReport);
00132 
00133 /** 
00134 Auxiliary function for ExistsCycle(const System&, std::string&). Starting from a state currState, this function makes a depth-first-search through the generator rGen.
00135 @param rGen
00136   Input generator.
00137 @param rTodo
00138   States to process.
00139 @param currState
00140   Current state.
00141 @param statesOnPath
00142   States that occurred on the way to current state.
00143 @param rReport
00144   User-readable information of violating condition (in case of negative test result).
00145 @return
00146   True if a cycle is found.
00147 */
00148 bool ExistsCycleSearch(const System& rGen, StateSet& rTodo, Idx currState, StateSet statesOnPath, std::string& rReport);
00149 
00150 /** 
00151 Find all start/end states of cycles of unobservable events in a generator. 
00152 @param rGen
00153   Input generator.
00154 @param rCycleOrigins
00155   Output variable for the states that have been found.
00156 */
00157 void CycleStartStates(const System& rGen, StateSet& rCycleOrigins);
00158 
00159 /** 
00160 Auxiliary function for CycleStartStates(). Parses through the active event set of the current state and checks whether any of the successor states already occurred on the path to current state (then a cycle is found).
00161 @param rGen
00162   Input generator.
00163 @param rTodo
00164   States that remain to be processed.
00165 @param currState
00166   The current state.
00167 @param statesOnPath
00168   States that occurred on the path.
00169 @param rCycleOriginStates
00170   Output variable for the states that have been found.
00171 */
00172 void CycleStartStatesSearch(const System& rGen, StateSet& rTodo, Idx currState, StateSet statesOnPath, StateSet& rCycleOriginStates);
00173 
00174 /**
00175 Remove states with same failure labels from rGd and from rReverseCompositionMap and perform cycle detection.
00176 @param rGd
00177   Input diagnoser generator.
00178 @param rGobs
00179   Generator G_o to look up failure labels.  
00180 @param rReverseCompositionMap
00181   Mapping of G_d states with G_o states.
00182 @param rFailureType
00183   The considered failure type.
00184 @param rReportString
00185   User-readable information of violating condition (in case of negative test result).
00186 @return
00187   True if violating cycles exist.
00188 */
00189 bool ExistsViolatingCyclesInGd(System& rGd, const Diagnoser& rGobs, std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap, const std::string& rFailureType, std::string& rReportString);
00190 
00191 /** 
00192 Compute G_o for a single failure type of a generator.
00193 @param rOrigGen
00194   Input generator, which is a model of the original plant containing the relevant failures events.
00195 @param rFailureType
00196   Failure type name.
00197 @param rFailureEvents
00198   Failure events belonging to the failure type.
00199 @param rGobs
00200   Output variable for G_o.
00201 */
00202 void ComputeGobs(const System& rOrigGen, const std::string& rFailureType, const EventSet& rFailureEvents, Diagnoser& rGobs);
00203 
00204 /**
00205 Compute G_o for a given generator with a given failure %partition (according to Jiang).
00206 @param rOrigGen
00207   Input generator, which is a model of the original plant containing the relevant failures events.
00208 @param rAttrFTMap
00209   Failure %partition.
00210 @param rGobs
00211   Output variable for G_o. 
00212 @exception Exception
00213   - Input generator has no unique initial state (id 301).
00214 */
00215 void ComputeGobs(const System& rOrigGen, const AttributeFailureTypeMap& rAttrFTMap, Diagnoser& rGobs);
00216 
00217 /**
00218 Compute the diagnosability testing generator G_d as a parallel composition of G_o with itself (according to Jiang).
00219 @param rGobs
00220   Input diagnoser G_o.
00221 @param rReverseCompositionMap
00222   Output variable containing the mapping of G_o states and G_d states (generated by Parallel()).
00223 @param rGd
00224   Output variable for G_d.
00225 */
00226 void ComputeGd(const Diagnoser& rGobs, std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap, System& rGd);
00227 
00228 /**
00229 Extract all traces of a generator G_d that start with an indicator event that follows a failure event of a certain failure type.
00230 @param rGd
00231   Input generator G_d which will be prunded.
00232 @param rGobs
00233   Generator G_o (containing failure label information).
00234 @param rFailureType
00235   Failure type index.
00236 @param rIndicatorEvents
00237   Set of indicator events.
00238 @param rReverseCompositionMap
00239   Mapping of G_d states with G_o states.
00240 */
00241 void TrimNonIndicatorTracesOfGd(System& rGd, const Diagnoser& rGobs, const Idx rFailureType,
00242                 const EventSet& rIndicatorEvents, const std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap);
00243 
00244 /**
00245 Auxiliary function for TrimNonIndicatorTracesOfGd(). Parse through active transition set of the current state and delete transitions if occurring event is not an indicator event or there did not occur a failure before the indicator.
00246 @param rGd
00247   Input generator G_d which will be pruned.
00248 @param rGobs
00249   Generator G_o (containing failure label information).
00250 @param rFailureType
00251   Failure type index.
00252 @param rIndicatorEvents
00253   Set of indicator events.
00254 @param rCompositionMap
00255   Inverted mapping of G_d states with G_o states.
00256 @param state
00257   Current state.
00258 @param rStatesDone
00259   States that have been processed already.
00260 */                
00261 void TrimNonIndicatorTracesOfGdRecursive(System& rGd, const Diagnoser& rGobs, const Idx rFailureType, 
00262                             const EventSet& rIndicatorEvents, std::map<Idx,std::pair<Idx,Idx> >& rCompositionMap,
00263                             Idx state, StateSet& rStatesDone);
00264 
00265 /**
00266 Compute the reachability from a given generator state through a trace that consists of arbitrarily many unobservable events followed by one observable event. 
00267 @param rGen
00268   Input generator.
00269 @param rUnobsEvents
00270   Unobservable events in the generators alphabet.
00271 @param rFailures
00272   Unobservable failure events in the generators alphabet.
00273 @param State
00274   A state of the generators state set.
00275 @param rAttrFTMap
00276   Failure %partition.
00277 @param rReachabilityMap
00278   Output variable for the reachability. Maps occurring observable events to the reachable generator states and the corresponding failure types that occurred within the unobservable part of the trace.
00279 */
00280 void ComputeReachability(const System& rGen, const EventSet& rUnobsEvents, const EventSet& rFailures, Idx State, 
00281                 const AttributeFailureTypeMap& rAttrFTMap, std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap);
00282 
00283 /**
00284 Auxiliary function for ComputeReachability(const System&, const EventSet&, const EventSet&, Idx, const AttributeFailureTypeMap&, std::map<Idx,std::multimap<Idx,DiagLabelSet>>&). Is recursively called for every occurring state on the trace (that consists of arbitrarily many unobservable events followed by one observable event).
00285 @param rGen
00286   Input generator.
00287 @param rUnobsEvents
00288   Unobservable events in the generators alphabet.
00289 @param rFailures
00290   Unobservable failure events in the generators alphabet.
00291 @param State
00292   The current state within the trace.
00293 @param rAttrFTMap
00294   Failure %partition.
00295 @param rReachabilityMap
00296   Output variable for the reachability. Maps occurring observable events to the reachable generator states and the coresponing failure types that occurred within the unobservable part of the trace.
00297 @param FToccurred
00298   Collects occurring failure types.
00299 */                
00300 void ComputeReachabilityRecursive(const System& rGen, const EventSet& rUnobsEvents,
00301                       const EventSet& rFailures, Idx State, const AttributeFailureTypeMap& rAttrFTMap,
00302                       std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap, const DiagLabelSet FToccurred);
00303 
00304 /**
00305 Obtain all transitions from other states into a given state of a generator.
00306 @param rGen
00307   A generator.
00308 @param state
00309   A state from the generators state set.
00310 @return
00311   A transition set.
00312 */                      
00313 TransSet ActiveBackwardTransSet(const System& rGen, Idx state);
00314 
00315 
00316 /**
00317 Compute a standard diagnoser from an input generator and a failure partition.
00318 @param rOrigGen
00319   Input plant including failure events.
00320 @param rFailureTypeMap
00321   Failure %partition: maps failure type names to failure events.
00322 @param rDiagGen
00323   Diagnoser generator for output.
00324 */
00325 void EventDiagnoser(const System& rOrigGen, const std::map<std::string,EventSet>& rFailureTypeMap, Diagnoser& rDiagGen);
00326 
00327 /** @name Functions (diagnoser computation) */
00328 /** @{ doxygen group */
00329 
00330 /**
00331 Compute a standard diagnoser from an input generator and a failure partition.
00332 @param rOrigGen
00333   Input plant including failure events.
00334 @param rAttrFTMap
00335   Failure type map of plant.
00336 @param rDiagGen
00337   Diagnoser generator for output. 
00338 @exception Exception
00339   - Input generator has no unique initial state (id 301).
00340 @ingroup DiagnosisPlugIn
00341 */
00342 void EventDiagnoser(const System& rOrigGen, const AttributeFailureTypeMap& rAttrFTMap, Diagnoser& rDiagGen);
00343 
00344 /** @} doxygen group */
00345 
00346 /**
00347 Generate a new label. From the last label and the failure types that occurred on the way, the new label is generated.
00348 @param lastLabel
00349   Diagnoser label of state estimate.
00350 @param failureTypes
00351   Failure types that occurred.
00352 @param newLabel
00353   Output variable for the new label.
00354 */
00355 void LabelPropagation(const DiagLabelSet& lastLabel, const DiagLabelSet& failureTypes, DiagLabelSet& newLabel);
00356 
00357 /**
00358 Perform label correction on propagated failure type labels.
00359 @param mm
00360   Propagated absolute failure type labels for a diagnoser state.
00361 @param attr
00362   Output variable for the diagnoser state attribute.
00363 */
00364 void LabelCorrection(const std::multimap<Idx,DiagLabelSet>& mm, AttributeDiagnoserState& attr);
00365 
00366 /**
00367  * Function definition for run-time interface 
00368  */
00369 bool IsEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap);
00370 
00371 
00372 /**
00373  * Function definition for run-time interface 
00374  */
00375 bool IsIndicatorEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap);
00376 
00377 
00378 } // namespace faudes
00379 
00380 #endif

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen