Algorithmadvanced
Diagnoser automaton
Also called Sampath diagnoser.
Builds an automaton over the observable events whose states are sets of plant states with fault labels. It detects faults online and tests diagnosability by a search for indeterminate cycles.
- Time
- O(2^(n 2^m) n^4 16^m q) worst
- Space
- O(2^(n 2^m) n^4 16^m q) extra
- Where
- m = the number of fault types; n = the number of states of the plant; q = the number of observable events
- Model
- Word RAM
- Properties
- deterministicexactoffline
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Meera Sampath, Raja Sengupta, Stéphane Lafortune, Kasim Sinnamohideen, Demosthenis Teneketzis, 1995
The diagnoser of a partially observed discrete-event system is a deterministic automaton that reads only the observable events. Each of its states is the set of all pairs (plant state, faults so far) that agree with what has been observed. A state whose pairs all carry a fault of type says " has certainly occurred". A state where some pairs carry and some do not says "uncertain". Online, the diagnoser runs next to the plant and reports a fault as soon as it is certain. Offline, Sampath, Sengupta, Lafortune, Sinnamohideen and Teneketzis (1995) used it to decide diagnosability: the plant is diagnosable exactly when the diagnoser has no indeterminate cycle, a cycle along which a faulty and a fault-free explanation stay together forever. The construction is a subset construction over the plant states with fault labels, so it can have exponentially many states. The twin plant test answers the offline question in polynomial time, but it does not give an online detector.
In plain words
You watch a machine, but some of its events are hidden from you, and a fault is one of the hidden events. After each event you see, you write down every place the machine could be in now, and for each place whether a fault has happened on the way there. If every entry says "fault", you raise the alarm. If none does, all is well. If some do and some do not, you wait.
Do this once for every sequence of observations you could ever see, and you get a finite machine: the diagnoser. To learn whether you will always reach a verdict, look for a loop in which a "fault" entry and a "no fault" entry can follow each other forever. If there is such a loop, some faults are never found. If there is none, every fault is found after a bounded wait.
The problem
The input is a deterministic plant , the observable events , and a map from each fault event to its fault type. Fault events are unobservable, and there are types. A label is a set of fault types, and is the set of types of the fault events in . The natural projection erases the unobservable events.
The first output is the diagnoser: the reachable part of the deterministic automaton over whose state after the observed word is
The second output, for a chosen type , is the answer to: is diagnosable? The test assumes, as Sampath et al. do, that has no cycle of unobservable events.
For a pair and an event , MOVES is the set of pairs over all unobservable strings such that is defined at . It is computed by a search over pairs.
The algorithm
DIAGNOSER(G, Σo, faults)- 1
q0 ← {(x0, ∅)} - 2
states ← {q0}; queue ← [q0] - 3
while queue is not empty do - 4
q ← pop the front of queue - 5
for each σ in Σo do - 6
r ← ∅ - 7
for each pair p in q do r ← r ∪ MOVES(p)[σ] - 8
if r ≠ ∅ then δd(q, σ) ← r; if r is not in states then add r to states and to queue - 9
return (q0, states, δd) DIAGNOSABLE(G, Σo, faults, F)- 10
D ← DIAGNOSER(G, Σo, faults) - 11
T ← the triples (q, a, b) with q a state of D, a and b pairs in q, F in the label of a and F not in the label of b - 12
for each (q, a, b) in T, σ in Σo with δd(q, σ) defined, a' in MOVES(a)[σ], b' in MOVES(b)[σ] with F not in the label of b' do add the edge (q, a, b) → (δd(q, σ), a', b') - 13
return true if the graph on T has no cycle, else false
Lines L1 to L9 are a breadth-first subset construction over pairs. Line L7 follows the unobservable events, collects the fault types they carry into the label, and stops at the next observable event . So a diagnoser state lists the plant states that are entered by an observable event, not those in the middle of an unobservable run. Line L8 keeps only nonempty sets: an observation that the plant cannot produce has no transition.
Lines L10 to L13 are the test. A triple says that, after the same observation, a faulty explanation and a fault-free explanation are both possible. An edge of line L12 extends both explanations by the same observable event, and keeps the second one fault-free. A cycle of triples is an indeterminate cycle: two explanations, one with the fault and one without, that can go on forever with the same observation. Line L13 uses Kahn's algorithm, as in topological sort: remove nodes with in-degree 0 until none is left, and report a cycle if some node remains.
Example
The plant has states 0 to 4, initial state 0, and transitions , , , , and . The events , and are observable, and is the fault, of type . A pair is written if the label is empty and otherwise. The table shows lines L4 to L8, with the events in the order , , , and only the events where is not empty.
| step | at L4 | at L5 | at L7 | line L8 | verdict on |
|---|---|---|---|---|---|
| 1 | new state | normal | |||
| 2 | new state | uncertain | |||
| 3 | known | normal | |||
| 3 | new state | certain | |||
| 4 | known | certain |
At step 2, MOVES follows to and then to , and it follows to and then to . The diagnoser has 4 states and 5 transitions. Online, after the observation it is uncertain, and after it reports the fault.
For the test, line L11 finds one triple, . Line L12 adds no edge from it: on , the pair has no move, and on , the pair has none. The graph has no cycle, so is diagnosable.
Now change the plant after the fault to , and , with and observable. The diagnoser is . The triples and form a cycle, so is not diagnosable: the faulty run and the normal run look the same forever. The tests of the implementation check both plants and compare the diagnoser states with a brute force enumeration of strings.
Correctness
By induction on the observed word, the state that lines L1 to L9 reach on is exactly : line L7 extends every explanation of by an unobservable run and the event , and every explanation of arises this way. There are at most sets of pairs, so the construction stops.
For the test: a cycle of triples gives, by the meaning of the states, a faulty string and a fault-free string with the same projection that can both be pumped around the cycle. So the delay after the fault is unbounded and is not diagnosable. Conversely, if is not diagnosable, there are arbitrarily long continuations after a fault with a fault-free twin. Because there is no unobservable cycle, a long continuation has many observable events, so it gives a long path of triples, and a path longer than the number of triples repeats one. The full proof is in the correctness proof.
Proof: The diagnoser holds the exact state estimate, and the indeterminate cycle test decides diagnosabilityfull
Setting. The plant is a deterministic automaton with state set , initial state and alphabet , where is the set of observable events. The fault events are unobservable, and each one has a fault type. The label of a string is the set of fault types of the fault events in . Labels only grow along a string. is the natural projection that erases the unobservable events. For a pair and , MOVES is the set of pairs over all with defined at . The function computes it by a search over pairs, so it stops even if has a cycle of unobservable events.
For let
Lemma 1 (meaning of a state). For each : if , the diagnoser reaches the state on . If , the diagnoser has no run on .
Proof. By induction on . For , only qualifies, so , which is the state of line L1. Assume the claim for , and let . A string that qualifies for ends with . Write , where is the longest prefix of before the last that is empty or ends with an observable event. Then qualifies for , , and the pair of is in MOVES for the pair of . Conversely, each pair in MOVES for is the pair of such a string . So is the union of MOVES over . This is the set that lines L6 and L7 build from the state . Line L8 adds the transition exactly when the set is not empty. If , then as well, and there is no run.
Theorem (construction). Lines L1 to L9 stop, and they return the part of the diagnoser that is reachable from .
Proof. A state is a set of pairs with and a set of fault types. With fault types there are pairs, so at most states. Each state enters the queue once, so the loop of line L3 stops. By Lemma 1, each transition that line L8 adds is a transition of the diagnoser, and the search adds every transition from every reached state.
The test. Fix a fault type . Lines L11 and L12 build the graph . Its nodes are the triples with a reached diagnoser state, , in the label of and not in the label of . There is an edge from to if , MOVES, MOVES and is not in the label of , for some . Then , and is in the label of , because labels only grow.
The type is diagnosable if there is an integer with this property: for every that ends with a fault event of type and every with and , every with has a fault event of type .
Theorem (test). Assume that has no cycle of unobservable events. Then is diagnosable if and only if has no cycle. Line L13 returns this answer.
Proof that a cycle gives no diagnosability. Let be a node on a cycle with the observable word , . By Lemma 1 there is with , a string for and a string for , both with projection . has a fault of type , and has none. Each edge of the cycle extends the strings by and with . One turn around the cycle brings back to itself, so it gives a string from to with and . In the same way it gives from to with , and has no fault of type , because the label of does not get . Let be the prefix of that ends with its first fault event of type , and write . For every , take and . Then , , , , and has no fault of type . So no works.
Proof that no cycle gives diagnosability. Let be the number of nodes of , and . Take , and as in the definition, with , and assume that has no fault of type . Because has no cycle of unobservable events, a run of unobservable events visits each state at most once, so it has at most events. So if has observable events, , and . Let , let be the observable events of , and let . For , let be the prefix of that ends with , and the prefix of that ends with its -th observable event. Both qualify for , so their pairs and are in . contains , so is in the label of , and is not in the label of . So is a node of , and by the definition of MOVES there is an edge from node to node . This is a path with nodes in a graph with nodes, so a node repeats, and has a cycle. This contradicts the assumption, so every such has a fault of type .
Line L13 runs Kahn's algorithm. It removes nodes of in-degree 0 until none is left, and it removes all nodes if and only if the graph has no cycle.
The first part of the proof does not use the assumption on unobservable cycles. The second part uses it to turn the length of into a number of observable events. Neither part uses the assumption of Sampath et al. that is live.
Cost. has at most nodes, where is the number of diagnoser states, and each node has at most edges. So the test is polynomial in the size of the diagnoser, and the diagnoser can be exponential in .
Complexity
The model is the word RAM with hashing. Let , the number of fault types and . There are pairs.
- The diagnoser has at most states. With MOVES cached per pair, one transition at lines L6 and L7 costs set operations, so lines L1 to L9 take time.
- Line L11 makes at most triples, and line L12 gives each at most edges. Kahn's algorithm is linear in the size of this graph. So lines L10 to L13 take time and space.
With this is the bound in the front matter. The bound on is the bound of the subset construction. Observers of automata can be exponential in , so this growth does occur. In practice, is small, but can still grow exponentially in . Online, a precomputed diagnoser takes time per observed event. Without precomputation, one step of lines L6 and L7 on the current state takes set operations for the observed , and memory for one state.
Properties
- Exact. The diagnoser state is the exact set of explanations, not an approximation.
- Deterministic. The diagnoser is deterministic, even though the plant with its unobservable events is not, seen through the projection.
- Online use. It reports a fault of type at the first observation after which every explanation carries . No observer that uses only the observations can report it earlier without the risk of a false alarm.
- Several fault types at once. One diagnoser serves all types. The test of lines L10 to L13 runs once per type.
- Exponential size. Its size is the main cost. The diagnosability test alone does not need it; see the twin plant.
Variants and improvements
- Twin plant and verifier. Jiang, Huang, Chandra and Kumar (2001) and Yoo and Lafortune (2002) test diagnosability without the diagnoser, on a product of the plant with itself, in polynomial time. See twin plant diagnosability test.
- On-the-fly diagnoser. Keep only the current state and compute the next one when an event is observed. This avoids the exponential precomputation, at the cost of the work of line L7 at each step.
- Decentralized diagnosis. Several local diagnosers, each with its own observable events, report to a coordinator. Diagnosability then becomes a joint condition on all of them.
- Stochastic diagnosis. With probabilities on the transitions, the state becomes a probability distribution over pairs, as in the forward algorithm of a hidden Markov model, and a fault is reported when its probability passes a threshold.
- Observer. Without fault labels, the same construction is the observer of the plant, used for state estimation and for checking observability properties.
When to use it
Use the diagnoser when you need an online fault detector and the plant is small enough that the set of explanations stays manageable. It also gives the offline verdict and a readable reason for it. If you only need to know whether the plant is diagnosable, use the twin plant test, which is polynomial. If the plant is large, run the diagnoser on the fly instead of building it in advance.
Pitfalls
- Testing for a cycle of uncertain states instead of triples (line L11). A cycle of uncertain diagnoser states does not prove that the fault is not diagnosable. In the plant , , , , with and observable, the diagnoser state has an self-loop and is uncertain. But the fault is diagnosable: the faulty explanation cannot follow , so it does not stay on that loop, and the first reveals the fault. The triples of line L11 track which explanation stays on the cycle, and there the graph has no cycle. The tests check this plant.
- Cutting the unobservable runs short at line L7. MOVES must follow unobservable runs of any length before the observable event, and add the fault types of the whole run to the label. If it follows at most one unobservable event, it loses the explanations where two hidden events come in a row, such as a fault and then another hidden event. If it does not record the fault types along the run, every label stays empty and the diagnoser never reports a fault.
- Letting the fault-free explanation become faulty at line L12. An edge must keep out of the label of . If may pick up a fault, two faulty explanations can form a cycle, and the test says "not diagnosable" for a diagnosable plant.
- Unobservable cycles (line L13). The equivalence needs a plant without a cycle of unobservable events. In the plant , , with only observable, the plant can loop on forever after the fault and no observation ever comes, so the fault is not diagnosable. But the state is never entered by an observable event, so it is in no diagnoser state, line L11 finds no triple, and line L13 answers "diagnosable". Check the assumption first, for example with a cycle search on the unobservable transitions.
- The size of the diagnoser. Lines L1 to L9 can produce exponentially many states. Do not build the diagnoser only to answer the offline question.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/diagnoser-automaton/. The authors are listed in prov/8VN8F2.jsonl.
"""The diagnoser of Sampath et al. (1995) for a partially observed automaton.
The plant G is a dict with the keys "init" and "delta" (a dict that maps
(state, event) to the next state). `observable` is the set of observable
events. `faults` maps each fault event to its fault type; fault events must
be unobservable. A label is a frozenset of fault types; the empty label is
"normal".
diagnoser(g, observable, faults) returns {"init", "states", "delta"}. A
diagnoser state is a frozenset of pairs (x, label). After an observed word
y, the state holds exactly the pairs (state of G, faults so far) of the
strings s of L(G) with P(s) = y that end with an observable event (or s is
empty and y is empty). This needs no cycle of unobservable events in G.
diagnosable(g, observable, faults, kind) decides diagnosability for one
fault type by a search for an indeterminate cycle: a cycle in the graph of
triples (diagnoser state, a pair with the fault, a pair without it).
Cost: the diagnoser has at most 2^(|X| 2^m) states for |X| states of G and
m fault types. Each diagnoser transition costs O(|X|^2 4^m) set operations
after the moves of every pair are cached.
"""
from collections import deque
from typing import Hashable, Iterable
Pair = tuple
Label = frozenset
def out_edges(delta: dict) -> dict:
out: dict = {}
for (q, e), r in delta.items():
out.setdefault(q, {})[e] = r
return out
def moves(out: dict, pair: Pair, observable: set, faults: dict) -> dict:
"""For a pair (x, label), map each observable event sigma to the set of pairs reached by u sigma, u unobservable."""
result: dict = {}
seen = {pair}
stack = [pair]
while stack:
x, label = stack.pop()
for e, y in out.get(x, {}).items():
if e in observable:
result.setdefault(e, set()).add((y, label))
else:
nxt = (y, label | {faults[e]} if e in faults else label)
if nxt not in seen:
seen.add(nxt)
stack.append(nxt)
return result
class _Moves:
"""Cache of moves() for one plant."""
def __init__(self, g: dict, observable: Iterable, faults: dict):
self.out = out_edges(g["delta"])
self.observable = set(observable)
self.faults = dict(faults)
self.cache: dict = {}
def __call__(self, pair: Pair) -> dict:
if pair not in self.cache:
self.cache[pair] = moves(self.out, pair, self.observable, self.faults)
return self.cache[pair]
def diagnoser(g: dict, observable: Iterable, faults: dict) -> dict:
"""The diagnoser automaton of g, built on the reachable diagnoser states."""
mv = _Moves(g, observable, faults)
events = sorted(mv.observable, key=repr)
q0 = frozenset({(g["init"], Label())}) # @line L1
states = {q0}
delta = {}
queue = deque([q0]) # @line L2
while queue: # @line L3
q = queue.popleft() # @line L4
for sigma in events: # @line L5
nxt: set = set() # @line L6
for pair in q: # @line L7
nxt |= mv(pair).get(sigma, set())
if nxt: # @line L8
r = frozenset(nxt)
delta[(q, sigma)] = r
if r not in states:
states.add(r)
queue.append(r)
return {"init": q0, "states": states, "delta": delta} # @line L9
def verdict(q: frozenset, kind: Hashable) -> str:
"""'F' if every pair of q has the fault type, 'N' if none has it, else 'uncertain'."""
has = [kind in label for _, label in q]
if all(has):
return "F"
if not any(has):
return "N"
return "uncertain"
def observe(d: dict, word: Iterable) -> frozenset:
"""The diagnoser state after the observed word, or None if the word cannot be observed."""
q = d["init"]
for sigma in word:
q = d["delta"].get((q, sigma))
if q is None:
return None
return q
def has_cycle(nodes: set, succ: dict) -> bool:
"""Kahn's algorithm: True if the graph on nodes has a cycle."""
indeg = {v: 0 for v in nodes}
for v in nodes:
for w in succ.get(v, ()):
indeg[w] += 1
queue = deque(v for v in nodes if indeg[v] == 0)
removed = 0
while queue:
v = queue.popleft()
removed += 1
for w in succ.get(v, ()):
indeg[w] -= 1
if indeg[w] == 0:
queue.append(w)
return removed < len(nodes)
def diagnosable(g: dict, observable: Iterable, faults: dict, kind: Hashable) -> bool:
"""True if the fault type `kind` is diagnosable: no indeterminate cycle in the diagnoser."""
mv = _Moves(g, observable, faults)
d = diagnoser(g, observable, faults) # @line L10
nodes = set()
for q in d["states"]: # @line L11
for a in q:
for b in q:
if kind in a[1] and kind not in b[1]:
nodes.add((q, a, b))
succ: dict = {}
for q, a, b in nodes: # @line L12
for sigma in mv.observable:
r = d["delta"].get((q, sigma))
if r is None:
continue
for a2 in mv(a).get(sigma, ()):
for b2 in mv(b).get(sigma, ()):
if kind not in b2[1]:
succ.setdefault((q, a, b), []).append((r, a2, b2))
return not has_cycle(nodes, succ) # @line L13
def has_uncertain_cycle(g: dict, observable: Iterable, faults: dict, kind: Hashable) -> bool:
"""True if the diagnoser has a cycle of uncertain states. If False, the fault type is diagnosable; True proves nothing."""
d = diagnoser(g, observable, faults)
nodes = {q for q in d["states"] if verdict(q, kind) == "uncertain"}
succ: dict = {}
for (q, _), r in d["delta"].items():
if q in nodes and r in nodes:
succ.setdefault(q, []).append(r)
return has_cycle(nodes, succ)
test_diagnoser_automaton.py 186 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/diagnoser-automaton/. The authors are listed in prov/8VN8F2.jsonl.
import itertools
import random
from diagnoser_automaton import diagnosable, diagnoser, has_uncertain_cycle, observe, verdict
N = frozenset()
F = frozenset({"F"})
def plant(edges, init=0):
return {"init": init, "delta": {(x, e): y for x, e, y in edges}}
# The worked example of the page: the normal cycle a u b, and a fault after a.
EXAMPLE = plant([(0, "a", 1), (1, "u", 2), (2, "b", 0), (1, "f", 3), (3, "b", 4), (4, "c", 4)])
# Diagnosable, but the diagnoser has a cycle of uncertain states.
UNCERTAIN = plant([(1, "a", 1), (1, "f", 5), (5, "a", 2), (2, "b", 6), (6, "b", 6)], init=1)
# Not diagnosable: after the fault the plant shows a b a b ... as the normal plant does.
AMBIGUOUS = plant([(0, "a", 1), (1, "u", 2), (2, "b", 0), (1, "f", 3), (3, "b", 4), (4, "a", 5), (5, "b", 4)])
def brute_states(g, observable, faults, max_obs):
"""Group the strings of L(G) that end with an observable event (or are empty) by their projection."""
out = {}
for (x, e), y in g["delta"].items():
out.setdefault(x, []).append((e, y))
groups = {(): {(g["init"], N)}}
stack = [(g["init"], N, ())]
while stack:
x, label, obs = stack.pop()
for e, y in out.get(x, []):
if e in observable:
if len(obs) < max_obs:
groups.setdefault(obs + (e,), set()).add((y, label))
stack.append((y, label, obs + (e,)))
else:
stack.append((y, label | {faults[e]} if e in faults else label, obs))
return groups
def oracle_verifier(g, observable, fault_events):
"""An independent twin plant: a cycle of states (x, faulty, y) with the flag set means not diagnosable."""
out = {}
for (x, e), y in g["delta"].items():
out.setdefault(x, {})[e] = y
start = (g["init"], False, g["init"])
seen = {start}
stack = [start]
succ = {}
while stack:
x, f, y = v = stack.pop()
nxt = []
for e, x2 in out.get(x, {}).items():
if e not in observable:
nxt.append((x2, f or e in fault_events, y))
elif e in out.get(y, {}):
nxt.append((x2, f, out[y][e]))
for e, y2 in out.get(y, {}).items():
if e not in observable and e not in fault_events:
nxt.append((x, f, y2))
succ[v] = nxt
for w in nxt:
if w not in seen:
seen.add(w)
stack.append(w)
nodes = {v for v in seen if v[1]}
color = {}
for root in nodes:
if root in color:
continue
color[root] = 1
it = [(root, iter(succ[root]))]
while it:
v, children = it[-1]
for w in children:
if w not in nodes:
continue
if color.get(w) == 1:
return False
if w not in color:
color[w] = 1
it.append((w, iter(succ[w])))
break
else:
color[v] = 2
it.pop()
return True
def random_plant(rng, n, observable, unobservable):
edges = {}
for x in range(n):
for e in observable:
if rng.random() < 0.45:
edges[(x, e)] = rng.randrange(n)
for e in unobservable:
if x < n - 1 and rng.random() < 0.35:
edges[(x, e)] = rng.randrange(x + 1, n)
if not any(k[0] == x for k in edges):
edges[(x, rng.choice(observable))] = rng.randrange(n)
return {"init": 0, "delta": edges}
def test_page_example():
d = diagnoser(EXAMPLE, {"a", "b", "c"}, {"f": "F"})
q0 = frozenset({(0, N)})
q1 = frozenset({(1, N)})
q2 = frozenset({(0, N), (4, F)})
q3 = frozenset({(4, F)})
assert d["states"] == {q0, q1, q2, q3}
assert d["delta"] == {(q0, "a"): q1, (q1, "b"): q2, (q2, "a"): q1, (q2, "c"): q3, (q3, "c"): q3}
assert [verdict(q, "F") for q in (q0, q1, q2, q3)] == ["N", "N", "uncertain", "F"]
assert observe(d, "abababc") == q3
assert observe(d, "aa") is None
assert diagnosable(EXAMPLE, {"a", "b", "c"}, {"f": "F"}, "F")
def test_uncertain_cycle_but_diagnosable():
d = diagnoser(UNCERTAIN, {"a", "b"}, {"f": "F"})
assert len(d["states"]) == 3
assert has_uncertain_cycle(UNCERTAIN, {"a", "b"}, {"f": "F"}, "F")
assert diagnosable(UNCERTAIN, {"a", "b"}, {"f": "F"}, "F")
def test_not_diagnosable():
assert not diagnosable(AMBIGUOUS, {"a", "b"}, {"f": "F"}, "F")
d = diagnoser(AMBIGUOUS, {"a", "b"}, {"f": "F"})
assert verdict(observe(d, "abababab"), "F") == "uncertain"
def test_no_fault_event():
g = plant([(0, "a", 1), (1, "u", 0)])
d = diagnoser(g, {"a"}, {})
assert all(verdict(q, "F") == "N" for q in d["states"])
assert diagnosable(g, {"a"}, {}, "F")
def test_two_fault_types():
g = plant([(0, "f1", 1), (0, "f2", 2), (1, "a", 3), (2, "a", 4), (3, "b", 3), (4, "c", 4)])
faults = {"f1": 1, "f2": 2}
d = diagnoser(g, {"a", "b", "c"}, faults)
q = observe(d, "a")
assert q == frozenset({(3, frozenset({1})), (4, frozenset({2}))})
assert verdict(q, 1) == "uncertain" and verdict(observe(d, "ab"), 1) == "F"
assert diagnosable(g, {"a", "b", "c"}, faults, 1) and diagnosable(g, {"a", "b", "c"}, faults, 2)
def test_states_against_brute_force():
rng = random.Random(11)
observable = ["a", "b"]
for _ in range(300):
g = random_plant(rng, 4, observable, ["u", "f"])
d = diagnoser(g, set(observable), {"f": "F"})
groups = brute_states(g, set(observable), {"f": "F"}, 4)
for k in range(5):
for word in itertools.product(observable, repeat=k):
q = observe(d, word)
if word in groups:
assert q == frozenset(groups[word])
else:
assert q is None
def test_random_against_twin_plant():
rng = random.Random(5)
observable = ["a", "b"]
counts = [0, 0]
for _ in range(600):
g = random_plant(rng, 4, observable, ["u", "f"])
got = diagnosable(g, set(observable), {"f": "F"}, "F")
assert got == oracle_verifier(g, set(observable), {"f"})
counts[got] += 1
assert min(counts) >= 50
def test_random_two_types_against_twin_plant():
rng = random.Random(8)
observable = ["a", "b"]
faults = {"f": 1, "g": 2}
for _ in range(300):
g = random_plant(rng, 4, observable, ["f", "g", "u"])
for kind, events in ((1, {"f"}), (2, {"g"})):
assert diagnosable(g, set(observable), faults, kind) == oracle_verifier(g, set(observable), events)
History
Sampath, Sengupta, Lafortune, Sinnamohideen and Teneketzis introduced diagnosability and the diagnoser in the IEEE Transactions on Automatic Control in 1995, with the condition that the diagnoser has no indeterminate cycle. In 1996 the same group described the use of the diagnoser for fault detection in physical systems in the IEEE Transactions on Control Systems Technology. Because the diagnoser can be exponential, Jiang, Huang, Chandra and Kumar (2001) and Yoo and Lafortune (2002) gave polynomial tests on a product of the plant with itself. The diagnoser stays the standard online detector.
References
- M. Sampath, R. Sengupta, S. Lafortune, K. Sinnamohideen and D. Teneketzis, Diagnosability of discrete-event systems, IEEE Transactions on Automatic Control 40(9), 1995, pages 1555 to 1575, the construction of the diagnoser and the necessary and sufficient condition for diagnosability in terms of indeterminate cycles
- M. Sampath, R. Sengupta, S. Lafortune, K. Sinnamohideen and D. C. Teneketzis, Failure diagnosis using discrete-event models, IEEE Transactions on Control Systems Technology 4(2), 1996, pages 105 to 124, the use of the diagnoser for online fault detection
- Christos G. Cassandras and Stéphane Lafortune, Introduction to Discrete Event Systems, third edition, Springer, 2021, Chapter 2, Languages and Automata (observers and diagnosers)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 8VN8F2 Edit this page History Report an error Markdown