How to use dd-diagnoser

Yannick Pencolé

The program dd-diagnoser is a simple program that computes the whole finite-state machine defined by [2] that is called a diagnoser. This program takes as input a finite-state machine (called the global model in [2]) and generates as output the diagnoser in different formats.

1  Usage

Usage: dd-diagnoser           [--help]
                           [--with-silent-closure]
                           [--no-failures | --failures  evt1 [evt2 ...]]
                           [--observables  obs1 [obs2 ...]]
                           [--hd filename1]
                           [--dot filename2]
                           [--cpp filename3]
                           infile.des_comp

2  Input file

The input file is a file suffixed des_comp that describes a discrete-event system. Here is a simple example that we will call model.des_comp:

example
5
0 1 2 3 4 
1
f
1
uo
0
2
o1 o2
7
0 -> 1 f
1 -> 2 o1
2 -> 2 o2
2 -> 0 uo
0 -> 3 uo
3 -> 4 o1
4 -> 4 o1

The first line is an identifier for the model to be described (here, it is example). The second line is the number of states in the model. The third line lists the set of states (here it is numbers from 0 to 4, but it can be more sophisticated identifiers). The state in the first position is the initial state of the system. On line 4, it is the number of fault events and line 5 gives the list of faults events (here there is on fault event f). Lines 6-7 are for the description of the unobservable events that are not considered as faulty. Line 8 denotes the number of shared events, in this model it is 0 as it is a global model, there is no shared events. Finally lines 9-10 describe the observable events. Due to historical issue, no event can be defined in more than class: an observable event cannot be faulty, etc. As it will be described in Section 4, this limitation will be removed by the use of the option of the program dd-diagnoser. To end the description of the input file, the number of transitions is written (that is 7 here) and the list of transitions is finally given. A transition has the form state -> state event.

Using the program component_to_dot on the previous file model.des_comp, you will obtain the file model.des_comp.dot that is the model in GraphViz format. The result is illustrated below, typing:

component_to_dot model.des_comp
dot -Tpdf -o model.pdf model.des_comp.dot

you will get the following figure in model.pdf.

3  Use of the program dd-diagnoser

3.1  Basic use

Simply calling dd-diagnoser with an input file will produce a new file that encodes the diagnoser. This file can be used with the program diagnose to perform diagnosis based on the machine encoded in the output file created by the program dd-diagnoser. The following command

dd-diagnoser model.des_comp

produces the file Diagnoser_example.diagnoser. The purpose of the file Diagnoser_example.diagnoser is too propose a precompiled and standalone version of the diagnoser to be used by other programs of diades (and especially the program diagnose).

3.2  Export to Graphviz format

The content of Diagnoser_example.diagnoser is not human-friendly as it results from an internal diades encoding. In order to visualize the resulting diagnoser, it is possible to export the diagnoser in the GraphViz format. The following commands

dd-diagnoser model.des_comp --dot diagnoser.dot
dot -Tpdf diagnoser.pdf diagnoser.dot

produce in diagnoser.pdf the following figure:

For details about how it is obtained, see [2]. Be careful here, the diagnoser is a machine whose size is exponential to the number of states and faults of the underlying model. Diades is quite efficient to build a diagnoser however, it may be long and last but not least Graphviz may not be able to print it out because the resulting dot file is too large.

3.3  Diagnoser extended with the silent closure

By default, a diagnoser state contains a set of diagnosis candidates, each candidate (x,F) asserts that the system may be in state x and the set of faults F may have happened before reaching state x after a sequence of observations. State x is the target state of a transition associated to the last observation of the sequence. Now it is possible to extend the diagnoser to also perform prediction on the silent part of the system after state x. With the so-called silent closure extension, the diagnoser states also contain the set of possible states and faults that can occur AFTER the last observable occurrence.

The following commands

dd-diagnoser model.des_comp --dot diagnoser_extended.dot --with-silent-closure
dot -Tpdf diagnoser_extended.pdf diagnoser_extended.dot

produce in diagnoser_extended.pdf the following figure:

3.4  Embedding the diagnoser into a c++ program

Instead of using the internal format of diades to perform diagnosis, you may require to embed the diagnoser into your own code. dd-diagnoser can export the resulting diagnosis in a c++ program. The command

dd-diagnoser model.des_comp --cpp diagnoser

produces 3 c++ files: diagnoser.cc diagnoser.hh diagnoser_main.cc. The two first files encode the diagnoser in c++ class called Diagnoser. With the interface defined in this c++ class it is possible to run the diagnoser in any piece of c++ code. As an example, the file diagnoser_main.cc is created to show how to use the diagnoser. To get a fully functional program, it is then sufficient to compile them:

g++ -o my_first_diagnoser diagnoser.cc diagnoser_main.cc

The created program my_first_diagnoser is very simple. It takes as input a sequence of observations and perform the diagnosis, for example:

my_first_diagnoser example.o1 example.o1 example.o1 example.o2

will produce as output:

Initial diagnosis:f: Safe
Observation:example.o1
Updated diagnosis:f: Ambiguous
Observation:example.o1
Updated diagnosis:f: Ambiguous
Observation:example.o1
Updated diagnosis:f: Ambiguous
Observation:example.o2
Updated diagnosis:f: Sure

4  Advanced use of dd-diagnoser

4.1  Export to the HyDiag format

dd-diagnoser can also be used to compute a diagnoser in the hd format. This format is the one used by the software HyDiag (diagnosis of hybrid systems) developed by Medhi Bayoudh in LAAS [1]. The hd format is described as follows:

Number_of_diagnoser_states
Number_of_observable_events
Initial_Belief_State
Belief_State_0 Belief_State_1 Belief_State_2 ...
observable_event_0 observable_event_1 ...
index_1_1  index_2_1                ... index_Number_of_diagnoser_states_1
     ...
index_1_Number_of_observable_events ... index_Number_of_diagnoser_states_Number_of_observable_events

Line 1 contains the number of diagnoser states (called belief states). Line 2 contains the number of observable events in the diagnoser. Line 3 contains the initial belief state of the diagnoser. Line 4 contains the list of belief states. A belief state is a string without whitespaces that corresponds to the information associated to a state of the diagnoser, for example (2,{f})(4,{}) is a belief state of the above diagnoser. Each belief state is implicitly associated to an index. The first belief state in the list is associated to index 0, the second to index 1, etc. Line 5 lists the observable events. Each observable event is also is a string without whitespaces and is also implicitly associated to an index (the first to index 0, the second to index 1, etc.). Then the transition system of the diagnoser is represented as a matrix. The line i of the matrix is associated to the observation of index i-1. The row j of the matrix is associated to the state of index j-1. The value x of the matrix at row i column j is the index of the target state of the transition from source state of index j-1 triggered by the observable event of index i-1. In other words, the value x stands for the transition Belief_state_j-1 -> Belief_state_x observable_event_i-1. If such a transition does not exist, the value is -1. The diagnoser depicted above is described in the hd format as follows:

5
2
{(0,{})}
{(0,{})} {(2,{f})(4,{})} {(2,{f})(4,{})(4,{f})} {(2,{f})} {(2,{f})(4,{f})} 
o1 o2 
1 2 2 4 4 
-1 3 3 3 3 

4.2  Use of the other options

The input file states which events are faulty and/or observable (see Section 2 for details). However, for flexibility reasons, dd-diagnoser can change the event assignments with help of the options --no-failure, --failures, --observables. With the option --no-failure, any event declared as faulty in the des_comp file is set to be non faulty (and non-observables if they are not part of the event list after --observables). The command

dd-diagnoser --no-failures model.des_comp --dot observer.dot 
dot -Tpdf -o observer.pdf observer.dot

produces the file observer.pdf with the following observer:

In the same manner, the event list after --failures is set to be faulty and the event list after --observables is set to be observable. For example, the following command

dd-diagnoser --failures example.f example.o1 --observables example.o2 example.uo  model.des_comp --dot other_diagnoser.dot
dot -Tpdf -o other_diagnoser.pdf other_diagnoser.dot

produces the file other_diagnoser.pdf with the following diagnoser:

References

[1]
M. Bayoudh, L. Travé-Massuyès, and Olive X. Hybrid systems diagnosis by coupling continuous and discrete event techniques. In Proceedings of the 17th International Federation of Automatic Control, World Congress, IFAC-WC, pages 7265–7270, Seoul, Korea, 2008.
[2]
M. Sampath, R. Sengupta, S. Lafortune, K. Sinnamohideen, and D. Teneketzis. Diagnosability of discrete-event systems. IEEE TAC, 40:1555–1575, Sep 1995.

This document was translated from LATEX by HEVEA.