diag_languagediagnosis.h
Go to the documentation of this file.
1 /** @file diag_languagediagnosis.h
2 Functions to check a system's diagnosability with respect to a specification automaton and compute a language-diagnoser.
3 */
4 
5 #ifndef DIAG_LANGUAGEDIAGNOSIS_H
6 #define DIAG_LANGUAGEDIAGNOSIS_H
7 
8 #include <vector>
9 #include "corefaudes.h"
10 #include "diag_generator.h"
11 #include "diag_eventdiagnosis.h"
13 
14 #include "diag_debug.h"
15 
16 namespace faudes {
17 
18 ///////////////////////////////////////////////////////////////////////////////
19 // Functions for specification framework
20 ///////////////////////////////////////////////////////////////////////////////
21 /** @name Functions (diagnosability with respect to a specification) */
22 /** @{ doxygen group */
23 
24 /**
25 Tests a system's diagnosability with respect to a given specification.
26 @param rGen
27  Input generator.
28 @param rSpec
29  Specification automaton.
30 @param rReportString
31  User-readable information of violating condition (in case of negative test result).
32 @return
33  True if input generator is diagnosable.
34 @ingroup DiagnosisPlugIn
35 */
36 extern FAUDES_API bool IsLanguageDiagnosableX(const System& rGen, const System& rSpec, std::string& rReportString);
37 
38 /** @} doxygen group */
39 
40 /**
41 Compute G_o for a generator that marks the faulty behaviour of a plant.
42 Every specification violation will be labelled with label "F".
43 @param rGenMarkedNonSpecBehaviour
44  Input generator that specifies specification violations by marked states.
45 @param rGobs
46  Output variable for G_o.
47 */
48 extern FAUDES_API void ComputeGobs(const System& rGenMarkedNonSpecBehaviour, Diagnoser& rGobs);
49 
50 /**
51 Compute the reachability from a state of a generator that marks its faulty behaviour.
52 States are said to be reachable if they can be reached through a trace that consists
53 of arbitrarily many unobservable events followed by one observable event.
54 @param rGen
55  Input generator.
56 @param rUnobsEvents
57  Unobservable events in the generators alphabet.
58 @param State
59  A state of the generators state set.
60 @param rReachabilityMap
61  Output variable for the reachability. Maps occurring observable events to the reachable generator states and a label that contains information about specification violations.
62 */
63 extern FAUDES_API void ComputeReachability(const System& rGen, const EventSet& rUnobsEvents, Idx State,
64  std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap);
65 
66 /**
67 Auxiliary function for ComputeReachability(const System&, const EventSet&, Idx State, 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).
68 @param rGen
69  Input generator.
70 @param rUnobsEvents
71  Unobservable events in the generators alphabet.
72 @param State
73  The current state within the trace.
74 @param done
75  Progress.
76 @param rReachabilityMap
77  Output variable for the reachability. Maps occurring observable events to the reachable generator states and a label that contains information about specification violations.
78  */
79 void ComputeReachabilityRecursive(const System& rGen, const EventSet& rUnobsEvents, Idx State, StateSet done,
80  std::map<Idx,std::multimap<Idx,DiagLabelSet> >& rReachabilityMap);
81 
82 
83 /**
84  * Function definition for run-time interface
85  */
86 extern FAUDES_API bool IsLanguageDiagnosable(const System& rGen, const System& rSpec);
87 
89 
95 
96 
97  VerifierState(Idx state1 = 0, Idx state2 = 0, Idx state3 = 0, VerifierStateLabel label = NORMAL){ mSpec1State = state1; mSpec2State = state2; mPlantState = state3; mLabel = label; }
98 
99  bool operator< (const VerifierState& rOther) const{
100  if(mSpec1State < rOther.mSpec1State)
101  return true;
102  else if(mSpec1State > rOther.mSpec1State)
103  return false;
104  if(mSpec2State < rOther.mSpec2State)
105  return true;
106  else if(mSpec2State > rOther.mSpec2State)
107  return false;
108  if(mPlantState < rOther.mPlantState)
109  return true;
110  else
111  return false;
112  }
113 };
114 
115 /**
116  * Test function to verify language-diagnosability
117  */
118 extern FAUDES_API bool IsLanguageDiagnosable(const System& rGen, const System rSpec, std::string& rReportString);
119 
120 /** @name Functions (verification and computation of loop-preserving observers) */
121 /** @{ doxygen group */
122 
123 /**
124  * Verifies a loop-preserving observer.
125  * @param rGen
126  * Original generator.
127  * @param rHighAlph
128  * Abstraction alphabet.
129  * @return
130  * True if natural projection is a loop-preserving observer
131  * @ingroup DiagnosisPlugIn
132 */
133 extern FAUDES_API bool IsLoopPreservingObserver(const System& rGen, const EventSet& rHighAlph);
134 
135 /**
136  * Computes a loop-preserving observer with minimal state size of the abstraction
137  * @param rGen
138  * Original generator
139  * @param rInitialHighAlph
140  % Initial abstraction alphabet
141  * @param rHighAlph
142  * Resulting abstraction alphabet
143  * @ingroup DiagnosisPlugIn
144  */
145 extern FAUDES_API void LoopPreservingObserver(const System& rGen, const EventSet& rInitialHighAlph, EventSet& rHighAlph);
146 
147 /** @} doxygen group */
148 
149 /** rec_ComputeLoopPreservingObserver(rGen, rInitialHighAlph, rHighAlph, rDdffVector, numberEvents, currentNumberEvents, currentLocation, hosenEvents) */
150 extern FAUDES_API bool rec_ComputeLoopPreservingObserver(const System& rGen, const EventSet& rInitialHighAlph, EventSet& rHighAlph,
151  const std::vector<Idx>& rDdffVector, Idx numberEvents, Idx currentNumberEvents, Idx currentLocation, EventSet chosenEvents);
152 
153 
154 /** @name Functions (diagnoser computation) */
155 /** @{ doxygen group */
156 
157 /**
158  * Compute a standard diagnoser from an input generator and a specification.
159  * @param rGen
160  * Input plant
161  * @param rSpec
162  * Specification generator.
163  * @param rDiagGen
164  * Diagnoser generator for output.
165  * @ingroup DiagnosisPlugIn
166 */
167 extern FAUDES_API void LanguageDiagnoser(const System& rGen, const System& rSpec, Diagnoser& rDiagGen);
168 
169 /** @} doxygen group */
170 
171 } // namespace faudes
172 
173 #endif
#define FAUDES_API
Interface export/import symbols: windows.
Definition: cfl_platform.h:81
Set of indices.
Definition: cfl_indexset.h:78
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
Generator with controllability attributes.
Provides the structure and methods to build and handle diagnosers.
Includes all libFAUDES headers, no plugins.
Includes debugging to diagnosis plug-in.
Functions to check a system's diagnosability with respect to failure events (diagnosability and I-dia...
Structure of diagnosers and methods to handle them.
NameSet EventSet
Convenience typedef for plain event sets.
Definition: cfl_nameset.h:531
void LanguageDiagnoser(const System &rGen, const System &rSpec, Diagnoser &rDiagGen)
Compute a standard diagnoser from an input generator and a specification.
void LoopPreservingObserver(const System &rGen, const EventSet &rInitialHighAlph, EventSet &rHighAlph)
Computes a loop-preserving observer with minimal state size of the abstraction.
FAUDES_API bool IsLanguageDiagnosableX(const System &rGen, const System &rSpec, std::string &rReportString)
Tests a system's diagnosability with respect to a given specification.
bool IsLoopPreservingObserver(const System &rGen, const EventSet &rHighAlph)
Verifies a loop-preserving observer.
TcGenerator< AttributeVoid, AttributeVoid, AttributeCFlags, AttributeVoid > System
Convenience typedef for std System.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
bool IsLanguageDiagnosable(const System &rGen, const System &rSpec)
Function definition for run-time interface.
TdiagGenerator< AttributeFailureTypeMap, AttributeDiagnoserState, AttributeCFlags, AttributeVoid > Diagnoser
void ComputeReachability(const System &rGen, const EventSet &rUnobsEvents, const EventSet &rFailures, Idx State, const AttributeFailureTypeMap &rAttrFTMap, map< Idx, multimap< Idx, DiagLabelSet > > &rReachabilityMap)
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 rec_ComputeLoopPreservingObserver(const System &rGen, const EventSet &rInitialHighAlph, EventSet &rHighAlph, const std::vector< Idx > &rDiffVector, Idx numberEvents, Idx currentNumberEvents, Idx currentLocation, EventSet chosenEvents)
rec_ComputeLoopPreservingObserver(rGen, rInitialHighAlph, rHighAlph, rDdffVector, numberEvents,...
void ComputeGobs(const System &rOrigGen, const string &rFailureType, const EventSet &rFailureEvents, Diagnoser &rGobs)
Methods to verify the obsrver condition for natural projections.
bool operator<(const VerifierState &rOther) const
VerifierState(Idx state1=0, Idx state2=0, Idx state3=0, VerifierStateLabel label=NORMAL)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen