diag_eventdiagnosis.h
Go to the documentation of this file.
1/** @file diag_eventdiagnosis.h
2Functions to check a system's diagnosability with respect to failure events (diagnosability and I-diagnosability) and computation of an event-diagnoser.
3*/
4
5#ifndef DIAG_EVENTDIAGNOSIS_H
6#define DIAG_EVENTDIAGNOSIS_H
7
8#include <vector>
9#include "corefaudes.h"
10#include "diag_debug.h"
11#include "diag_generator.h"
12#include "diag_attrdiagstate.h"
15#include "diag_attrlabelset.h"
16
17
18namespace faudes {
19
20/** @name Functions (diagnosability with respect to a failure partition) */
21/** @{ doxygen group */
22
23/**
24Test a system's diagnosability with respect to a given failure partition.
25Standard 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.
26@param rGen
27 Input generator, is a model of the original plant containing the relevant failures events.
28@param rFailureTypeMap
29 Failure %partition: maps failure type names to failure events.
30@param rReportString
31 User-readable information of violating condition (in case of negative test result).
32@ingroup DiagnosisPlugIn
33*/
34extern FAUDES_API bool IsEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReportString);
35
36
37/**
38Test a system's I-diagnosability with respect to a given failure partition.
39Validates I-Diagnosability with respect to a given failure and indicator %partition. The algorithm is a modification of IsDiagnosable().
40@param rGen
41 Input generator, is a model of the original plant containing the relevant failures events.
42@param rFailureTypeMap
43 Failure %partition: maps failure type names to failure events and indicator events.
44@param rReportString
45 User-readable information of violating condition (in case of negative test result).
46@ingroup DiagnosisPlugIn
47*/
48extern FAUDES_API bool IsIndicatorEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReportString);
49
50/**
51Check 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&).
52It is examined if the following assumptions hold:
53<ol>
54 <li> The failure and indicator events are part of the generator's alphabet. </li>
55 <li> The generator is live. </li>
56 <li> There do not exist any cycles of unobservable events. </li>
57 <li> All failure events are unobservable. </li>
58</ol>
59@param rGen
60 Input generator, is a model of the original plant containing the relevant failures events.
61@param rFailureTypeMap
62 Failure %partition: maps failure type names to failure events and indicator events.
63@param rReportString
64 User-readable information of violationg condition (in case of negative result).
65@return
66 True if all assumptions are met.
67@exception Exception
68 - A failure event does not form part of the alphabet of the generator (id 302).
69 - A indicator event does not form part of the alphabet of the generator (id 303).
70@ingroup DiagnosisPlugIn
71*/
72extern FAUDES_API bool MeetsDiagnosabilityAssumptions(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReportString);
73
74/** @} doxygen group */
75
76
77/**
78Convert the reverse composition map of Parallel() by switching first and second entry.
79@param rReverseCompositionMap
80 Input map as generated by Parallel().
81@param rCompositionMap
82 Converted map.
83*/
84extern FAUDES_API void ConvertParallelCompositionMap( const std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap,
85 std::map<Idx,std::pair<Idx,Idx> >& rCompositionMap);
86
87/**
88Test if a generator is live.
89@param rGen
90 Input generator.
91@param rReport
92 User-readable information of violating condition (in case of negative result).
93@return
94 True if generator is live.
95*/
96extern FAUDES_API bool IsLive(const System &rGen, std::string& rReport);
97
98/**
99Test if there exist any cycles of unobservable events in a generator.
100@param rGen
101 Input generator.
102@param rReport
103 User-readable information of violating condition (in case of positive test result).
104@return
105 True if there exists a cycle of unobservable events.
106*/
107extern FAUDES_API bool CycleOfUnobsEvents(const System& rGen, std::string& rReport);
108
109/**
110Check if all failure events are unobservable events in a generator's alphabet.
111@param rGen
112 Input generator, is a model of the original plant containing the relevant failures events.
113@param rFailureTypeMap
114 Failure %partition: maps failure type names to failure events and indicator events.
115@param rReport
116 User-readable information of violating condition (in case of negative result).
117@return
118 True if all failures events are unobservable.
119*/
120extern FAUDES_API bool FailuresUnobservable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap, std::string& rReport);
121
122/**
123Test if there exist any cycles in a generator.
124@param rGen
125 Input generator.
126@param rReport
127 User-readable information of violating condition (in case of positive test result).
128@return
129 True if there exists a cycle.
130*/
131extern FAUDES_API bool ExistsCycle(const System& rGen, std::string& rReport);
132
133/**
134Auxiliary function for ExistsCycle(const System&, std::string&). Starting from a state currState, this function makes a depth-first-search through the generator rGen.
135@param rGen
136 Input generator.
137@param rTodo
138 States to process.
139@param currState
140 Current state.
141@param statesOnPath
142 States that occurred on the way to current state.
143@param rReport
144 User-readable information of violating condition (in case of negative test result).
145@return
146 True if a cycle is found.
147*/
148extern FAUDES_API bool ExistsCycleSearch(const System& rGen, StateSet& rTodo, Idx currState, StateSet statesOnPath, std::string& rReport);
149
150/**
151Find all start/end states of cycles of unobservable events in a generator.
152@param rGen
153 Input generator.
154@param rCycleOrigins
155 Output variable for the states that have been found.
156*/
157extern FAUDES_API void CycleStartStates(const System& rGen, StateSet& rCycleOrigins);
158
159/**
160Auxiliary 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).
161@param rGen
162 Input generator.
163@param rTodo
164 States that remain to be processed.
165@param currState
166 The current state.
167@param statesOnPath
168 States that occurred on the path.
169@param rCycleOriginStates
170 Output variable for the states that have been found.
171*/
172extern FAUDES_API void CycleStartStatesSearch(const System& rGen, StateSet& rTodo, Idx currState, StateSet statesOnPath, StateSet& rCycleOriginStates);
173
174/**
175Remove states with same failure labels from rGd and from rReverseCompositionMap and perform cycle detection.
176@param rGd
177 Input diagnoser generator.
178@param rGobs
179 Generator G_o to look up failure labels.
180@param rReverseCompositionMap
181 Mapping of G_d states with G_o states.
182@param rFailureType
183 The considered failure type.
184@param rReportString
185 User-readable information of violating condition (in case of negative test result).
186@return
187 True if violating cycles exist.
188*/
189extern FAUDES_API bool ExistsViolatingCyclesInGd(System& rGd, const Diagnoser& rGobs, std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap, const std::string& rFailureType, std::string& rReportString);
190
191/**
192Compute G_o for a single failure type of a generator.
193@param rOrigGen
194 Input generator, which is a model of the original plant containing the relevant failures events.
195@param rFailureType
196 Failure type name.
197@param rFailureEvents
198 Failure events belonging to the failure type.
199@param rGobs
200 Output variable for G_o.
201*/
202extern FAUDES_API void ComputeGobs(const System& rOrigGen, const std::string& rFailureType, const EventSet& rFailureEvents, Diagnoser& rGobs);
203
204/**
205Compute G_o for a given generator with a given failure %partition (according to Jiang).
206@param rOrigGen
207 Input generator, which is a model of the original plant containing the relevant failures events.
208@param rAttrFTMap
209 Failure %partition.
210@param rGobs
211 Output variable for G_o.
212@exception Exception
213 - Input generator has no unique initial state (id 301).
214*/
215extern FAUDES_API void ComputeGobs(const System& rOrigGen, const AttributeFailureTypeMap& rAttrFTMap, Diagnoser& rGobs);
216
217/**
218Compute the diagnosability testing generator G_d as a parallel composition of G_o with itself (according to Jiang).
219@param rGobs
220 Input diagnoser G_o.
221@param rReverseCompositionMap
222 Output variable containing the mapping of G_o states and G_d states (generated by Parallel()).
223@param rGd
224 Output variable for G_d.
225*/
226extern FAUDES_API void ComputeGd(const Diagnoser& rGobs, std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap, System& rGd);
227
228/**
229Extract all traces of a generator G_d that start with an indicator event that follows a failure event of a certain failure type.
230@param rGd
231 Input generator G_d which will be prunded.
232@param rGobs
233 Generator G_o (containing failure label information).
234@param rFailureType
235 Failure type index.
236@param rIndicatorEvents
237 Set of indicator events.
238@param rReverseCompositionMap
239 Mapping of G_d states with G_o states.
240*/
241extern FAUDES_API void TrimNonIndicatorTracesOfGd(System& rGd, const Diagnoser& rGobs, const Idx rFailureType,
242 const EventSet& rIndicatorEvents, const std::map<std::pair<Idx,Idx>,Idx>& rReverseCompositionMap);
243
244/**
245Auxiliary 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.
246@param rGd
247 Input generator G_d which will be pruned.
248@param rGobs
249 Generator G_o (containing failure label information).
250@param rFailureType
251 Failure type index.
252@param rIndicatorEvents
253 Set of indicator events.
254@param rCompositionMap
255 Inverted mapping of G_d states with G_o states.
256@param state
257 Current state.
258@param rStatesDone
259 States that have been processed already.
260*/
261extern FAUDES_API void TrimNonIndicatorTracesOfGdRecursive(System& rGd, const Diagnoser& rGobs, const Idx rFailureType,
262 const EventSet& rIndicatorEvents, std::map<Idx,std::pair<Idx,Idx> >& rCompositionMap,
263 Idx state, StateSet& rStatesDone);
264
265/**
266Compute the reachability from a given generator state through a trace that consists of arbitrarily many unobservable events followed by one observable event.
267@param rGen
268 Input generator.
269@param rUnobsEvents
270 Unobservable events in the generators alphabet.
271@param rFailures
272 Unobservable failure events in the generators alphabet.
273@param State
274 A state of the generators state set.
275@param rAttrFTMap
276 Failure %partition.
277@param rReachabilityMap
278 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.
279*/
280extern FAUDES_API void ComputeReachability(const System& rGen, const EventSet& rUnobsEvents, const EventSet& rFailures, Idx State,
281 const AttributeFailureTypeMap& rAttrFTMap, std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap);
282
283/**
284Auxiliary 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).
285@param rGen
286 Input generator.
287@param rUnobsEvents
288 Unobservable events in the generators alphabet.
289@param rFailures
290 Unobservable failure events in the generators alphabet.
291@param State
292 The current state within the trace.
293@param rAttrFTMap
294 Failure %partition.
295@param rReachabilityMap
296 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.
297@param FToccurred
298 Collects occurring failure types.
299*/
300extern FAUDES_API void ComputeReachabilityRecursive(const System& rGen, const EventSet& rUnobsEvents,
301 const EventSet& rFailures, Idx State, const AttributeFailureTypeMap& rAttrFTMap,
302 std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap, const DiagLabelSet FToccurred);
303
304/**
305Obtain all transitions from other states into a given state of a generator.
306@param rGen
307 A generator.
308@param state
309 A state from the generators state set.
310@return
311 A transition set.
312*/
313extern FAUDES_API TransSet ActiveBackwardTransSet(const System& rGen, Idx state);
314
315
316/**
317Compute a standard diagnoser from an input generator and a failure partition.
318@param rOrigGen
319 Input plant including failure events.
320@param rFailureTypeMap
321 Failure %partition: maps failure type names to failure events.
322@param rDiagGen
323 Diagnoser generator for output.
324*/
325extern FAUDES_API void EventDiagnoser(const System& rOrigGen, const std::map<std::string,EventSet>& rFailureTypeMap, Diagnoser& rDiagGen);
326
327/** @name Functions (diagnoser computation) */
328/** @{ doxygen group */
329
330/**
331Compute a standard diagnoser from an input generator and a failure partition.
332@param rOrigGen
333 Input plant including failure events.
334@param rAttrFTMap
335 Failure type map of plant.
336@param rDiagGen
337 Diagnoser generator for output.
338@exception Exception
339 - Input generator has no unique initial state (id 301).
340@ingroup DiagnosisPlugIn
341*/
342extern FAUDES_API void EventDiagnoser(const System& rOrigGen, const AttributeFailureTypeMap& rAttrFTMap, Diagnoser& rDiagGen);
343
344/** @} doxygen group */
345
346/**
347Generate a new label. From the last label and the failure types that occurred on the way, the new label is generated.
348@param lastLabel
349 Diagnoser label of state estimate.
350@param failureTypes
351 Failure types that occurred.
352@param newLabel
353 Output variable for the new label.
354*/
355extern FAUDES_API void LabelPropagation(const DiagLabelSet& lastLabel, const DiagLabelSet& failureTypes, DiagLabelSet& newLabel);
356
357/**
358Perform label correction on propagated failure type labels.
359@param mm
360 Propagated absolute failure type labels for a diagnoser state.
361@param attr
362 Output variable for the diagnoser state attribute.
363*/
364extern FAUDES_API void LabelCorrection(const std::multimap<Idx,DiagLabelSet>& mm, AttributeDiagnoserState& attr);
365
366/**
367 * Function definition for run-time interface
368 */
369extern FAUDES_API bool IsEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap);
370
371
372/**
373 * Function definition for run-time interface
374 */
375extern FAUDES_API bool IsIndicatorEventDiagnosable(const System& rGen, const AttributeFailureTypeMap& rFailureTypeMap);
376
377
378} // namespace faudes
379
380#endif
#define FAUDES_API
uint32_t Idx
void ConvertParallelCompositionMap(const map< pair< Idx, Idx >, Idx > &rReverseCompositionMap, map< Idx, pair< Idx, Idx > > &rCompositionMap)
bool ExistsViolatingCyclesInGd(System &rGd, const Diagnoser &rGobs, map< pair< Idx, Idx >, Idx > &rReverseCompositionMap, const string &rFailureType, string &rReportString)
bool FailuresUnobservable(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap, string &rReport)
void ComputeGd(const Diagnoser &rGobs, map< pair< Idx, Idx >, Idx > &rReverseCompositionMap, System &rGd)
TransSet ActiveBackwardTransSet(const System &rGen, Idx state)
bool ExistsCycleSearch(const System &rGen, StateSet &rTodo, Idx currState, StateSet statesOnPath, string &rReport)
bool IsIndicatorEventDiagnosable(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap, string &rReportString)
bool ExistsCycle(const System &rGen, string &rReport)
void CycleStartStatesSearch(const System &rGen, StateSet &rTodo, Idx currState, StateSet statesOnPath, StateSet &rCycleOriginStates)
void CycleStartStates(const System &rGen, StateSet &rCycleOrigins)
void TrimNonIndicatorTracesOfGd(System &rGd, const Diagnoser &rGobs, const Idx rFailureType, const EventSet &rIndicatorEvents, const map< pair< Idx, Idx >, Idx > &rReverseCompositionMap)
bool IsLive(const System &rGen, string &rReport)
bool IsEventDiagnosable(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap, string &rReportString)
void ComputeReachability(const System &rGen, const EventSet &rUnobsEvents, const EventSet &rFailures, Idx State, const AttributeFailureTypeMap &rAttrFTMap, map< Idx, multimap< Idx, DiagLabelSet > > &rReachabilityMap)
void EventDiagnoser(const System &rOrigGen, const map< string, EventSet > &rFailureTypeMap, Diagnoser &rDiagGen)
void LabelPropagation(const DiagLabelSet &lastLabel, const DiagLabelSet &failureTypes, DiagLabelSet &newLabel)
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)
bool CycleOfUnobsEvents(const System &rGen, string &rReport)
bool MeetsDiagnosabilityAssumptions(const System &rGen, const AttributeFailureTypeMap &rFailureTypeMap, string &rReportString)
void TrimNonIndicatorTracesOfGdRecursive(System &rGd, const Diagnoser &rGobs, const Idx rFailureType, const EventSet &rIndicatorEvents, map< Idx, pair< Idx, Idx > > &rCompositionMap, Idx state, StateSet &rStatesDone)
void LabelCorrection(const multimap< Idx, DiagLabelSet > &mm, AttributeDiagnoserState &attr)
void ComputeGobs(const System &rOrigGen, const string &rFailureType, const EventSet &rFailureEvents, Diagnoser &rGobs)

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen