DiaDes  0.1
DIAgnosis of Discrete-Event System
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Diades::Automata::ClassicalDiagnoser Class Reference

#include <ClassicalDiagnoser.hh>

Public Types

enum  EventType { Diagnosed, Observable }
 
enum  FaultStatus { Safe, Sure, Ambiguous }
 
typedef Diades::Utils::Exception< ClassicalDiagnoserException
 
- Public Types inherited from Diades::Automata::ObservableComponent
typedef reference_wrapper< ObservableComponent const > CRef
 
typedef reference_wrapper< ObservableComponentRef
 
typedef Diades::Utils::Exception< ComponentException
 
- Public Types inherited from Diades::Automata::Component
typedef Diades::Utils::Exception< ComponentException
 
typedef ComponentPointer
 
typedef const ComponentConstPointer
 
typedef Diades::Graph::NodeIterator StateIterator
 
typedef Diades::Graph::EdgeIterator TransitionIterator
 
typedef list< Transition >::const_iterator EventTransitionIterator
 
typedef unordered_set< State >::const_iterator InitialStateIterator
 
typedef Diades::Graph::InEdgeIterator InputTransitionIterator
 
typedef Diades::Graph::OutEdgeIterator OutputTransitionIterator
 
typedef set< Event >::const_iterator EventIterator
 
typedef unordered_set< Transition >::const_iterator OutputEventTransitionIterator
 
typedef unordered_set< Transition >::const_iterator InputEventTransitionIterator
 
typedef unordered_set< State >::const_iterator LabelledStateIterator
 
typedef std::string StateLabel
 

Public Member Functions

 ClassicalDiagnoser ()
 
 ClassicalDiagnoser (const ObservableComponent &model, const unordered_set< Event > &faults, bool silentClosure=false)
 
FaultStatus getFaultStatus (State diagnoserState, const Event &fault) const
 
virtual ~ClassicalDiagnoser ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
Accessors
unordered_set< Event >::const_iterator beginOfDiagnosedEvents () const
 
unordered_set< Event >::const_iterator endOfDiagnosedEvents () const
 
unsigned numberOfDiagnosedEvents () const
 
Diagnosis operators
State initialState () const
 
bool initialize ()
 
void getDiagnosis (Diagnosis &diagnosis) const
 
void diagnose (const Event &obs)
 
bool isConsistent (const Event &obs) const
 
I/O operators

Size of the diagnoser

Returns
the memory usage of the diagnoser
bool diagnoser2dot (const string &fileName, string &log) const
 
bool diagnoser2hd (const string &fileName, string &log) const
 
- Public Member Functions inherited from Diades::Automata::ObservableComponent
 ObservableComponent ()
 
 ObservableComponent (const ObservableComponent &component)
 
 ~ObservableComponent ()
 
virtual void clear ()
 
void setMask (const ObservableMask &mask)
 
const ObservableMaskmask () const
 
EventIterator observableBegin () const
 
EventIterator observableEnd () const
 
unsigned numberOfObservables () const
 
bool containsObservableEvent (const Event &e) const
 
LabelledStateIterator beginOfSourceStateOfObservableEvent (const Event &e) const
 
LabelledStateIterator endOfSourceStateOfObservableEvent (const Event &e) const
 
LabelledStateIterator beginOfTargetStateOfObservableEvent (const Event &e) const
 
LabelledStateIterator endOfTargetStateOfObservableEvent (const Event &e) const
 
EventTransitionIterator observableTransitionBegin (const Event &e) const
 
EventTransitionIterator observableTransitionEnd (const Event &e) const
 
EventTransitionIterator unobservableTransitionBegin () const
 
EventTransitionIterator unobservableTransitionEnd () const
 
OutputEventTransitionIterator outputObservableTransitionBegin (State s, Event e) const
 
OutputEventTransitionIterator outputObservableTransitionEnd (State s, Event e) const
 
InputEventTransitionIterator inputObservableTransitionBegin (State s, Event e) const
 
InputEventTransitionIterator inputObservableTransitionEnd (State s, Event e) const
 
virtual bool project (const ObservableComponent *comp, const set< Event > &projectedEvents)
 
virtual bool project (const ObservableComponent *comp, const set< Event > &projectedEvents, unordered_map< Diades::Automata::State, unordered_set< Diades::Automata::State > > &dictionary)
 
virtual bool component2dot (const string &fileName) const
 
virtual bool component2dot (ostream &os) const
 
virtual void updateMask (const Event &event, const set< string > &obsLabel)
 
virtual bool exportDesCompModel (const string &filename) const
 
virtual bool exportDesCompModel (ostream &os) const
 
- Public Member Functions inherited from Diades::Automata::Component
ConstPointer getPointer () const
 
Pointer getPointer ()
 
 Component ()
 
 Component (const Component &component)
 
virtual ~Component ()
 
bool operator== (const Component &component) const
 
bool operator!= (const Component &component) const
 
int id () const
 
void setId (int identifier)
 
Graph::Graphbehaviour ()
 
const Graph::Graphbehaviour () const
 
bool isEmpty () const
 
bool isValid () const
 
void setName (const string &name)
 
const string & name () const
 
void insertEvent (const Event &event)
 
unsigned numberOfEvents () const
 
void insertEvent (EventIterator start, EventIterator end)
 
const EventgetEvent (Transition t) const
 
const set< Event > & events () const
 
EventIterator eventBegin () const
 
EventIterator eventEnd () const
 
bool containsEvent (const Event &e) const
 
void setFaulty (const Event &e)
 
bool isFaulty (const Event &e) const
 
const set< Event > & faultyEvents () const
 
EventIterator faultyEventBegin () const
 
EventIterator faultyEventEnd () const
 
void setNormal (const Event &e)
 
bool isNormal (const Event &e) const
 
const set< Event > & normalEvents () const
 
EventIterator normalEventBegin () const
 
EventIterator normalEventEnd () const
 
void replaceEvent (const Event &e1, const Event &e2)
 
State newState ()
 
State newState (const StateLabel &label)
 
const StateLabelgetLabel (State state) const
 
State getState (const StateLabel &label) const
 
void deleteState (State state)
 
void deleteState (StateIterator start, StateIterator end)
 
unsigned numberOfStates () const
 
StateIterator stateBegin () const
 
StateIterator stateEnd () const
 
void setInitial (State state)
 
void unsetInitial (State state)
 
void setAllInitialStates ()
 
void clearAllInitialStates ()
 
InitialStateIterator initialStateBegin () const
 
InitialStateIterator initialStateEnd () const
 
unsigned numberOfInitialStates () const
 
bool isInitial (State state) const
 
virtual void mergeInfoStates (const vector< const Component *> &components, const vector< State > &states, State currentState)
 
Transition newTransition (State source, State target, Event event)
 
Transition newTransition (const StateLabel &source, const StateLabel &target, Event event)
 
void deleteTransition (Transition t)
 
void deleteTransition (TransitionIterator start, TransitionIterator end)
 
void deleteTransition (EventTransitionIterator start, EventTransitionIterator end)
 
LabelledStateIterator beginOfSourceStateOfEvent (const Event &e) const
 
LabelledStateIterator endOfSourceStateOfEvent (const Event &e) const
 
LabelledStateIterator beginOfTargetStateOfEvent (const Event &e) const
 
LabelledStateIterator endOfTargetStateOfEvent (const Event &e) const
 
EventTransitionIterator eventTransitionBegin (const Event &e) const
 
EventTransitionIterator eventTransitionEnd (const Event &e) const
 
OutputEventTransitionIterator outputEventTransitionBegin (State s, Event e) const
 
OutputEventTransitionIterator outputEventTransitionEnd (State s, Event e) const
 
InputEventTransitionIterator inputEventTransitionBegin (State s, Event e) const
 
InputEventTransitionIterator inputEventTransitionEnd (State s, Event e) const
 
TransitionIterator transitionBegin () const
 
TransitionIterator transitionEnd () const
 
OutputTransitionIterator outputTransitionBegin (State s) const
 
OutputTransitionIterator outputTransitionEnd (State s) const
 
InputTransitionIterator inputTransitionBegin (State s) const
 
InputTransitionIterator inputTransitionEnd (State s) const
 
unsigned numberOfTransitions () const
 
bool sanityCheck (string &log) const
 
bool isDeterministic () const
 
virtual bool project (const Component *comp, const set< Event > &projectedEvents)
 
virtual bool project (const Component *comp, const set< Event > &projectedEvents, unordered_map< Diades::Automata::State, unordered_set< Diades::Automata::State > > &dictionary)
 
virtual bool project (const Component *comp, const set< Event > &projectedEvents, const unordered_set< State > &acceptors, unordered_set< State > &newAcceptors)
 
bool minimize ()
 
bool minimize (unordered_set< State > &acceptors)
 
bool isComplete () const
 
virtual bool import (const string &filename)
 
virtual bool importDesCompModel (const string &filename)
 
virtual bool importDesCompModel (istream &stream)
 
- Public Member Functions inherited from Diades::Utils::Loggable
 Loggable ()
 
 Loggable (const string &loggerName)
 
 Loggable (Logger &logger)
 
void changeLogger (const string &newLoggerName)
 
void changeLogger (Logger &newLogger)
 
Diades::Utils::Log log (Log::Level level, const char *msg)
 

Static Public Member Functions

static string typeName ()
 
- Static Public Member Functions inherited from Diades::Automata::ObservableComponent
static string typeName ()
 
- Static Public Member Functions inherited from Diades::Automata::Component
static string typeName ()
 the name by default More...
 

Protected Member Functions

virtual void computeDiagnoser (const ObservableComponent &model, const unordered_set< Event > &faults, bool silentClosure)
 
- Protected Member Functions inherited from Diades::Automata::ObservableComponent
virtual bool parseDesCompFaultyEvents (istream &stream)
 
virtual bool parseDesCompNormalEvents (istream &stream)
 
virtual bool parseDesCompObservableEvents (istream &stream)
 
virtual void exportDesCompEvent (ostream &os, const Event &evt) const
 
- Protected Member Functions inherited from Diades::Automata::Component
virtual void determine (const Component *comp, const unordered_set< State > &acceptors, unordered_set< State > &newAcceptors)
 
virtual void determine (const Component *comp)
 
virtual bool parseDesCompName (istream &stream)
 
virtual bool parseDesCompStates (istream &stream)
 
virtual bool parseDesCompMaskedEvents (istream &stream, unsigned number, map< string, set< string > > &maskEvents)
 
virtual bool parseDesCompTransitions (istream &stream)
 

Private Types

typedef int ModelState
 
typedef boost::dynamic_bitset FaultSet
 
typedef pair< ModelState, FaultSetDiagnosisHypothesis
 
typedef multimap< ModelState, FaultSetDiagnoserInfoState
 
typedef unordered_map< Event, unordered_multimap< State, FaultSet > > ReachableInfo
 

Private Member Functions

void computeSilentClosure (const ObservableComponent &model, State source, const unordered_set< Event > &faults, unordered_multimap< State, FaultSet > &result)
 
void initModelStatesLabels (const ObservableComponent &model, vector< State > &modelStateOf, ConstNodeMap< int > &valueOf)
 
void computeReachableStates (const ObservableComponent &model, ConstNodeMap< ReachableInfo > &reachables, bool silentClosure, ConstNodeMap< unordered_multimap< State, FaultSet > > &silent)
 
void computeNonDeterministicDiagnoser (const ObservableComponent &model, const unordered_set< Event > &faults, Graph::Graph &nonDeterministicDiagnoser, NodeMap< pair< int, FaultSet > > &stateInfoNonDet, EdgeMap< Event > &transInfoNonDet, unordered_set< State > &initialStateNonDetState, bool silentClosure)
 

Private Attributes

unordered_set< Event_diagnosedEvents
 
vector< FaultSet::size_type > faultToIndex
 
vector< EventindexToFault
 
NodeMap< DiagnoserInfoStatestateInfo
 
State currentDiagnoserState
 
vector< string > labelStates
 

Additional Inherited Members

- Static Public Attributes inherited from Diades::Automata::Component
static const string defaultComponentName
 
- Protected Attributes inherited from Diades::Automata::Component
Diades::Graph::Graph _behav
 
unordered_set< State_initial
 
Diades::Graph::NodeMap< int > _isInitial
 

Detailed Description

Classical Diagnoser of a model

The class Classical Diagnoser implements the classical diagnoser of a given model G

Author
Y. Pencole
Version
1.0

Definition at line 70 of file ClassicalDiagnoser.hh.

Member Typedef Documentation

◆ DiagnoserInfoState

Definition at line 99 of file ClassicalDiagnoser.hh.

◆ DiagnosisHypothesis

index of the fault for bitset

Definition at line 98 of file ClassicalDiagnoser.hh.

◆ Exception

Definition at line 79 of file ClassicalDiagnoser.hh.

◆ FaultSet

typedef boost::dynamic_bitset Diades::Automata::ClassicalDiagnoser::FaultSet
private

Definition at line 95 of file ClassicalDiagnoser.hh.

◆ ModelState

map between a code and a diagnosed label Information on a state A list of pairs (s,{f1,f2}) meaning that the system may be in state s and the events f1 and f2 have occurred.

Definition at line 94 of file ClassicalDiagnoser.hh.

◆ ReachableInfo

typedef unordered_map< Event, unordered_multimap< State, FaultSet > > Diades::Automata::ClassicalDiagnoser::ReachableInfo
private

for diagnosis

Definition at line 105 of file ClassicalDiagnoser.hh.

Member Enumeration Documentation

◆ EventType

Enumerator
Diagnosed 
Observable 

Definition at line 74 of file ClassicalDiagnoser.hh.

◆ FaultStatus

Enumerator
Safe 
Sure 
Ambiguous 

Definition at line 75 of file ClassicalDiagnoser.hh.

Constructor & Destructor Documentation

◆ ClassicalDiagnoser() [1/2]

Diades::Automata::ClassicalDiagnoser::ClassicalDiagnoser ( )
inline

Default constructor

Definition at line 195 of file ClassicalDiagnoser.hh.

◆ ClassicalDiagnoser() [2/2]

Diades::Automata::ClassicalDiagnoser::ClassicalDiagnoser ( const ObservableComponent model,
const unordered_set< Event > &  faults,
bool  silentClosure = false 
)

Creation of a Classical Diagnoser from a given model

Parameters
modelan observable model (namely an ObservableComponent)
faultsthe set of faults in the ObservableComponent Computation of the diagnoser based on the model. This diagnoser is the classical deterministic one. The diagnoser is only based on the observable events of the model and nothing else. The considered failure events are the complete set of failure events from the given model.
silentClosureif true the diagnoser also include the silent closure

◆ ~ClassicalDiagnoser()

virtual Diades::Automata::ClassicalDiagnoser::~ClassicalDiagnoser ( )
inlinevirtual

Load constructor

Parameters
fileNamename of the file to load Destructor

Definition at line 235 of file ClassicalDiagnoser.hh.

References Diades::Graph::Graph::clear().

Member Function Documentation

◆ beginOfDiagnosedEvents()

unordered_set<Event>::const_iterator Diades::Automata::ClassicalDiagnoser::beginOfDiagnosedEvents ( ) const
inline

Iterator on the diagnosed events (begin())

Returns
an iterator on the diagnosed events of the diagnoser

Definition at line 249 of file ClassicalDiagnoser.hh.

Referenced by Diades::Automata::FaultDiagnosis::FaultDiagnosis().

◆ computeDiagnoser()

virtual void Diades::Automata::ClassicalDiagnoser::computeDiagnoser ( const ObservableComponent model,
const unordered_set< Event > &  faults,
bool  silentClosure 
)
protectedvirtual

compute the diagnoser Computation of the diagnoser based on the model. In the resulted diagnoser, only the events in the list observables are considered as observable.

Parameters
modelthe involved ObservableComponent
faultsthe events of model that are considered as fault events
silentClosureif true the diagnoser also include the silent closure

◆ computeNonDeterministicDiagnoser()

void Diades::Automata::ClassicalDiagnoser::computeNonDeterministicDiagnoser ( const ObservableComponent model,
const unordered_set< Event > &  faults,
Graph::Graph nonDeterministicDiagnoser,
NodeMap< pair< int, FaultSet > > &  stateInfoNonDet,
EdgeMap< Event > &  transInfoNonDet,
unordered_set< State > &  initialStateNonDetState,
bool  silentClosure 
)
private

compute a graph with some features that represents the non-deterministic diagnoser of the model

Parameters
modelModel used to compute the diagnoser
faultsthe events of model that are considered as fault events
nonDeterministicDiagnoserthe returned graph
stateInfoNonDetinformation associated to each state of the graph, namely an index representing a state of model and a set of fault codes that could have occured before reaching this state
transInfoNonDetthe code for each transition of the graph
initialStateNonDetStatethe returned initial states of the graph
silentClosureif true non-deterministic diagnoser also include the silent closure

◆ computeReachableStates()

void Diades::Automata::ClassicalDiagnoser::computeReachableStates ( const ObservableComponent model,
ConstNodeMap< ReachableInfo > &  reachables,
bool  silentClosure,
ConstNodeMap< unordered_multimap< State, FaultSet > > &  silent 
)
private

compute the reachable states Computation of the states s' of the model that are reachable by the diagnoser from another reachable state s. Associate to each reachable state s', the faults that could bave occurred between s and s'

Parameters
modelthe model to explore
reachablesthe returned structure
silentClosureif true add the silent closure in the reachables
silentthe silent close (not utilized when not(silentClosure))

◆ computeSilentClosure()

void Diades::Automata::ClassicalDiagnoser::computeSilentClosure ( const ObservableComponent model,
State  source,
const unordered_set< Event > &  faults,
unordered_multimap< State, FaultSet > &  result 
)
private

Compute the silent closure of the state "source"

Parameters
modela model
sourcea State of the model
faultsthe set of fault events
resultthe set { (s1,F1), (s2,F2), ..., (sn,Fn) } such that si can be silently reached from state 'source' and the set of fault events Fi has occurred between 'source' and 'si'

◆ diagnose()

void Diades::Automata::ClassicalDiagnoser::diagnose ( const Event obs)
Parameters
obsan observation

Referenced by Diades::Automata::FaultDiagnosis::diagnoserDiagnose().

◆ diagnoser2dot()

bool Diades::Automata::ClassicalDiagnoser::diagnoser2dot ( const string &  fileName,
string &  log 
) const

Export the diagnoser in the dot format

Parameters
fileNameexported file
logto report some problems
Returns
true if the export is a success

◆ diagnoser2hd()

bool Diades::Automata::ClassicalDiagnoser::diagnoser2hd ( const string &  fileName,
string &  log 
) const

Export the diagnoser in the hd format (HyDiag format)

Parameters
fileNameexported file
logto report some problems
Returns
true if the export is a success The format is defined as follows: Format of the file to import:
*  Number_of_diagnoser_states
*  Number_of_observable_events
*  Initial_Belief_State_1
*  Belief_State_2 Belief_State_3 Belief_State_4 ...
*  observable_event_1 observable_event_2 ...
*  target_index_1_1  target_2_1  ...
*  ...
*  target_index_Number_of_observable_events_1 ...
*  
A belief state is a string without whitespaces An observable event is a string without whitespaces A belief state has index i if it is the i+1th belief state listed in the file. An observable event has index i if it is the ith belief state listed in the file. Therefore, the initial state has index 0, etc. The set of index ending the file describes a transition matrix. target_index_i_j denotes the index of the diagnoser state that is the target of the diagnoser state whose index is j when the observable event whose index is i occurs.

◆ endOfDiagnosedEvents()

unordered_set<Event>::const_iterator Diades::Automata::ClassicalDiagnoser::endOfDiagnosedEvents ( ) const
inline

Iterator on the diagnosed events (end())

Returns
an iterator on the diagnosed events of the diagnoser

Definition at line 256 of file ClassicalDiagnoser.hh.

Referenced by Diades::Automata::FaultDiagnosis::FaultDiagnosis().

◆ getDiagnosis()

void Diades::Automata::ClassicalDiagnoser::getDiagnosis ( Diagnosis diagnosis) const
Returns
the current diagnosis

Referenced by Diades::Automata::FaultDiagnosis::getDiagnosis().

◆ getFaultStatus()

FaultStatus Diades::Automata::ClassicalDiagnoser::getFaultStatus ( State  diagnoserState,
const Event fault 
) const

Get the fault status of a given fault in a fiven state

Parameters
diagnoserStatethe state to look at
faultthe fault event to look at
Returns
the status of the fault

◆ initialize()

bool Diades::Automata::ClassicalDiagnoser::initialize ( )
inline

Initialize the diagnosis process

Returns
true if the process initialistion has not failed (lack of initial states may fail the process)

Definition at line 286 of file ClassicalDiagnoser.hh.

References Diades::Utils::log().

Referenced by Diades::Automata::FaultDiagnosis::FaultDiagnosis().

◆ initialState()

State Diades::Automata::ClassicalDiagnoser::initialState ( ) const
inline

Get the initial state of the diagnoser (if several, then take one of them, that is is your responsability to set up it correctly)

Definition at line 278 of file ClassicalDiagnoser.hh.

◆ initModelStatesLabels()

void Diades::Automata::ClassicalDiagnoser::initModelStatesLabels ( const ObservableComponent model,
vector< State > &  modelStateOf,
ConstNodeMap< int > &  valueOf 
)
private

Initialise the state labels from the model (labelStates)

Parameters
modelthe model from which the diagnoser is computed
modelStateOfmapping between internal coding and model state
valueOfmapping etween model state and internal coding

◆ isConsistent()

bool Diades::Automata::ClassicalDiagnoser::isConsistent ( const Event obs) const
Parameters
obsan observation
Returns
true if the observation obs is expected in the current diagnoser state, false otherwise

◆ numberOfDiagnosedEvents()

unsigned Diades::Automata::ClassicalDiagnoser::numberOfDiagnosedEvents ( ) const
inline
Returns
the number of diagnosed events

Definition at line 263 of file ClassicalDiagnoser.hh.

◆ serialize()

template<class Archive >
void Diades::Automata::ClassicalDiagnoser::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

output stream operator (saving) input stream operator (loading)

Definition at line 365 of file ClassicalDiagnoser.hh.

◆ typeName()

static string Diades::Automata::ClassicalDiagnoser::typeName ( )
inlinestatic

Definition at line 78 of file ClassicalDiagnoser.hh.

Member Data Documentation

◆ _diagnosedEvents

unordered_set<Event> Diades::Automata::ClassicalDiagnoser::_diagnosedEvents
private

Definition at line 85 of file ClassicalDiagnoser.hh.

◆ currentDiagnoserState

State Diades::Automata::ClassicalDiagnoser::currentDiagnoserState
private

Definition at line 103 of file ClassicalDiagnoser.hh.

◆ faultToIndex

vector<FaultSet::size_type> Diades::Automata::ClassicalDiagnoser::faultToIndex
private

Definition at line 96 of file ClassicalDiagnoser.hh.

◆ indexToFault

vector<Event> Diades::Automata::ClassicalDiagnoser::indexToFault
private

index of the fault for bitset

Definition at line 97 of file ClassicalDiagnoser.hh.

◆ labelStates

vector<string> Diades::Automata::ClassicalDiagnoser::labelStates
private

Label of a model state

Definition at line 109 of file ClassicalDiagnoser.hh.

◆ stateInfo

NodeMap< DiagnoserInfoState > Diades::Automata::ClassicalDiagnoser::stateInfo
private

Definition at line 101 of file ClassicalDiagnoser.hh.


The documentation for this class was generated from the following file: