Abstract
As an efficient way for fault diagnosis, diagnostic policy is to build a test sequence to achieve specified fault diagnosis and accurate failure location with minimal test cost. Traditional diagnostic policy building methods are not suitable for unreliable and imperfect tests due to the uncertainty caused by various outside or inside interference in the real-world systems extensively. Therefore, in this paper, a novel method for diagnostic policy based on Q-learning is proposed to get the optimal policy of long run in the realistic systems. We construct the diagnostic policy model based on the framework of RL. Then the probability of false alarm or misdetection can be learnt from the environment not partial statistic data through Q-learning algorithm. And the optimal diagnostic policy with imperfect tests is obtained with high efficiency, also considering the test cost and information gain. The proposed method is illustrated by a real-world application. The effectiveness and feasibility of this method are also verified by comparison results.
Introduction
With more advanced technologies widely applied in military equipment and battlefield conditions getting worse, the structure of weapon system is becoming more and more complex. Highly safety and reliability requirements have added more difficulties to the support and maintenance of the complex weapon systems, as well as system design and agent literature [1–2], which challenges the ability, efficiency and flexibility of test and diagnosis when faults occur. And meanwhile, the life-cycle maintenance cost of a complex weapon system may be 3 to 10 times of the purchase or produce cost [3]. As an important part of fault diagnosis, diagnostic policy is a fault detection sequence or sequential test set to achieve specified fault diagnosis and accurate failure location, which can improve diagnosis efficiency, enhance equipment availability and reduce maintenance and operations costs.
The diagnostic policy has been proved to be a NP-complete problem [4]. The theory and method to build optimal diagnostic policy have been studied for nearly half of the century [5–7]. Pattipati et al. [1] proposed a Dynamic Programming (DP) algorithm to get the optimal policy, but it brings too much calculation. And they designed the AO* algorithms [8] consisted of AND/OR search algorithm and the improved Information Heuristic algorithms [9], which is easy to get stuck in backtracking. A bottom-up Test Sequence Generation method [10] is studied to be more optimal than AO*, while it may cause combinatorial explosion. And the hybrid methods of these algorithms. Essentially, they belong to the class of DP algorithm. Recently, the evolutionary algorithms have been applied to get the optimal test sequencing, such as Genetic Algorithm (GA) [11], Ant Colony Algorithm (ACA) [12, 13], Particle Swarm Optimization (PSO) [14] and Binary Particle Swarm Optimization (DBPSO) [3]. In the case of all the information of the diagnosis object and diagnosis environment are accurate and complete, namely the tests are completely reliable, a satisfactory solution of optimal or near-optimal diagnostic policy can be acquired with these methods above.
However, in real-world systems, the tests are imperfect (or unreliable) for various internal or external interferences [15] of the equip system, such as electromagnetic interference, unreliable sensors, operator error test environmental conditions and limitation of access to a faulty component directly [16]. And unreliable tests introduce an important element of uncertainty into the diagnosis inference. For this, Zeng et al. [17] used the Bayes network classifier to handle the randomness and uncertainty data in cooling system of ship diesel engine. Yang et al. [18] presented a Hidden Markov Model (HMM) based algorithm of fault diagnosis in system to deal with the partial and imperfect tests, and also introduced a method online to estimate the parameters of it. And they also proposed some evaluation functions and two types of diagnostic strategy optimization generation methods emphasizing on mean cost and diagnosis accuracy respectively with unreliable tests [19]. An uncertain AO* algorithm [20] was presented to get the optimal diagnostic strategy with the unreliable reliable parameters (detection and false alarm probabilities) of test were transformed into misdiagnosis cost. Zhang et al. [21] also proposed to solve the sequential fault diagnosis problem with imperfect tests through the AND/OR graph search algorithm and information heuristic search to reduce life cycle cost. In addition, Ye et al. [22] improved a dynamic greedy algorithm to select the optimal test set under unreliable tests based on diagnostic dictionary matrix, and defined a new function of fault detection and isolation fee as the criterion. But the methods aforementioned to get the optimal diagnostic policy with imperfect tests inherently rely on the statistical probability distribution of false alarm or misdetection which is difficult to acquire, to describe the uncertainty of test results. Moreover, the history data statistics under unreliable tests may be incomplete and partial for most specific application environments and equipment, and it’s usually hard to determine which kind or kinds of interferences that contribute to the uncertainty of test results inreality.
In this paper, we consider the diagnostic policy problem with imperfect tests to be a Reinforcement Learning (RL) problem. What RL does is to evaluate the goodness of policies and learning from the good action sequences [23] to create an optimal policy, and it has been widely applied in various fields [24–27]. As a model-free technique of RL, Q-learning is most popular of not requiring any background knowledge of the environment, and proved to handle the discrete-time systems with uncertain information feasibly [28]. Q-learning has been applied successfully in lighting and blind control [29], access control in wireless network [30], data classification [31] and so on. Hence, Q-learning is applied in the paper to obtain the optimal diagnostic policy in a long run with imperfect tests.
The paper is organized as follows. Section 2 introduces the basic framework of Markov Decision Process (MDP), for the RL problem is often described by MDP model. A generalized formulation of fault diagnostic policy with imperfect tests is presented in Section 3. And the diagnostic policy method based on Q-learning is proposed in Section 4. A case study of the proposed method is discussed in Section 5 with the simulation results and comparisons with traditional policies. Section 6 gives a summary of this work.
MDP framework
MDP provides the basic mathematical model of a discrete-time system. And the classical
discrete-time Markov Decision Process (MDP) can be described as a five-tuple
In MDP, a total amount of the long-run reward that the agent received of interacting with its environment starting in any state s′ ∈ S from k = 0 over a finite time steps can be expressed as:
where
r
k
= r (sk +1|s
k
,
a
k
) (k = 0, 1, ···), and
0 < γ < 1 is a discount factor and the larger value of it means
that the rewards of the subsequent states are more important in decision-making.
Consequently, the value of a state s ∈ S is the expected
return of a MDP’s trajectory starting from state s and applying a policy π
which is a mapping of states and actions, called value function, denoted as
V
π
(s), and it can be given
by:
Considering that the reward is obtained at each state with a specified test action, a
similar state-action value function of the cumulative reward following policy
π, denoted as
Q
π
(s, a)
is given by
Q-value function is useful for that they achieve the weighted summation over different decisions with the transition function unnecessary. It requires no forward-reasoning step to compute an optimal test action in a state. This is the reason that Q-value function is chosen instead of V-function in model-free methods when P or R is unknown.
Comparing Equation (3) with Equation (5), the relationship between these two
optimal functions is given as
Then the optimal test decision at state s can be obtained as
With the above analysis, the Q-value function is more available in learning method for P is unknown or the model of environment is incomplete to get an optimal policy π*.
Problem statement
General diagnostic policy is to build a test sequence to achieve specified fault
diagnosis and accurate fault location with minimal test cost. It can be defined as
quintuple function <F, p, T,
C, B>. F = (f1,
f2, …,
f
m
) (m > 0) is a
set of independent failure sources of the system, and
f
i
(0 < i ⩽ m)
is the condition that only i-th failure
occurred. (p = p (f1) ,
p (f2) , …,
p (f
m
)) (m > 0)
is a set of the priori probability distributions of failure
source. T = (t1,
t2, …,
t
n
) (n > 0) is a
set of n available tests with binary outcome, and each test
t
j
(1 ⩽ j ⩽ n)
checks a subset of failure sources. C = (c1,
c2, …,
c
n
) (n > 0) is a
set of test cost measured considering time, manpower or some other economic factors,
where each
c
j
(1 ⩽ j ⩽ n)
correspondences to test
t
j
. B = [b
ij
] is a
binary matrix of dimension
m × n (m,
n > 0) which represents the logic relationship between the
failure state
f
i
(1 ⩽ i ⩽ m)
and test
t
j
(1 ⩽ j ⩽ n),
which also called FT matrix. Besides,
b
ij
= 1 when test
t
j
can detect the failure
f
i
, or
b
ij
= 0.
By the way, FT matrix can be derived from fault tree, simulated analysis, and classical testability model as information flow model and multi-signal model. The dynamic requirements and uncertainties should be considered in practical application environments to get accurate and reliable diagnosis results, which is to build an optimal test sequencing with imperfect tests achieving fast fault isolation at least cost.
Diagnostic policy model
Fault diagnosis is a process to reduce the uncertainty of system state constantly, the
possible fault state of the system can be deduced with test results at each step, namely
fault inference machine. Formally it could be described as:
Generally speaking, the system state of next moment is only related to the current state and the chosen action while has nothing to do with the previous actions and visited states before, which is a typical Markov Decision Process. The whole fault diagnosis process utilizing diagnostic policy is shown as Fig. 1.

Fault diagnosis tree.
In Section 2, the general framework of MDP is introduced. Similarly, the fault diagnosis model based on RL can be formalized with the information in diagnosis process as Fig. 1.
The state space S contains all the failure states of a system F1, F2, …, F m (m > 1), denoted as S = (F1, F2, . . . , F m ), which can be deduced from Fig. 1. And all the possible tests that could be the action to be executed under each failure state s = F n (1 ⩽ n ⩽ m) form the action space A, namely A = (t1, t2, . . . , t d ) (d ⩾ 1). And A (F n ) (1 ⩽ n ⩽ m) represents the set of available tests that could be selected at the particular fault state F n and A (F n ) ⊆ A, which can be obtained according to dependent matrix B. In the ideal situation, the diagnosis model of a system is completely known or the tests are perfect, i.e. the state transition probability p (s′|s, a) ∈ P and reward r (s′|s, a) ∈ R are known for any s, s′ ∈ S, a ∈ A. In this paper, the reward in fault diagnosis process contains the test cost c j ∈ C for executing a test. Moreover, the information obtained from a test is also considered to be a part of the reward, as the goal of fault diagnosis problem is to achieve fast fault diagnosis with minimize the cost required.
Based on Markov property as Equation (9)
and the total probability formula, for any π ∈ Π, the
probability of state s or
F
n
(1 ⩽ n ⩽ m)
transferring to state s′ or
F
np
for any policy π at
any time can be defined as:
The model of environment and the diagnostic system is unavailable in many actual applications for the intrinsic uncertainty in the weapon systems and the dynamics of diagnosis environments, namely P and R are incomplete or unknown. Even considering the interferences from outside and inside, electromagnetic interference and imprecise measurement [15], there still exist some fields lack of history data which may cause great deviation on probabilities even in the similar conditions. So the traditional methods to obtain the optimal diagnostic policy won’t work with imperfect tests in real-world.
Therefore it need detour another way and a method of learning based on a model-free algorithm is proposed in this work.
In RL, the agent learns its environment in relation to a fixed target by receiving the rewards of actions on the environment [32]. The agent adopts its valid reward in the space of state-action with the reward already obtained for the action sequences and derives to the maximum reward for the optimal action of all state-action pairs. The RL-based diagnostic policy architecture is shown in Fig. 2, and especially the environment contains the weapon system or equipment under diagnosis as well as its applied surroundings of all interference.

The policy building framework based on RL.
In this work, a model-free method of RL is needed, such as Sarsa, TD (Temporal Difference) and Q-learning. Among them, Q-learning is the simple algorithm for solving optimal policy with the learning object is Q-value function. So it is selected to solve the diagnostic policy problem with imperfect tests.
Since P is unknown, the diagnosis agent generates a policy π, and samples following this policy, then sampling trajectory is acquired after executing tests for T steps, as shown in Fig. 3. The information exchanged with the diagnosis environment is achieved in this process, also called the history or the sequences of experience, denotes (s1, a1, r1, s2, a2, r2, s3 . . .). Monte Carlo reinforcement learning algorithm [33] can be used to get the Q-value estimation through averaging the cumulative rewards of multiple sampling trajectories. But it may involve large amount of calculation. Actually the computation of Q-value can be achieved by incremental method. As known in Equation (2), the sum of current reward and discount estimate of future rewards is one of the data to update the estimated Q-value, then the update formula can be given as follows:

Sampling trajectory of a policy.
An important part of Q-value estimation is the tradeoff between exploring its environment to gather statistical knowledge and exploiting the current experience to choose the best test action. For this, the ɛ-greedy exploration strategy is adopted of good performance, and expressed as:
In this work, we set it as:
According to the information theory, the fault isolation ability of a test can be
evaluated by its information gain. Based on Equation (8), the information gain is given by:
Moreover, the cost of executing the test should also be considered since we expect high
diagnosis efficiency with minimum cost. In our work, the information gain and test cost
are integrated to be the reward in Q-learning as the feedback of selecting a test. The
reward of chosen test
a
k
= t
l
at state
s
k
= F
m
is given by:
Hence, the diagnostic policy method based on Q-learning is built to generate optimal policy feasibly. The details of this method are given in Table 1.
The Q-learning based method of optimal diagnostic policy
To validate the diagnostic policy building method based on Q-learning, a case of application in the real world is given. Guided missile launcher of a specific aircraft is an important interface unit to accomplish the mechanical, electrical, RF and pneumatic connection between the aircraft and missile, and the detection content is mainly focused on electric parameters. According to the signals between aircraft and launcher as well as the structure of the device, the test requirement and test content can be analyzed. This device has 13 failure states and 12 tests. Failure rate of each state and test cost is shown in Table 2.
Dependency matrix of missile launcher
Dependency matrix of missile launcher
According to the fault diagnosis processing and principle, the fault diagnosis tree of this system can be rational and clearly constructed as Fig. 1 with the information in Table 2. And the ambiguous fault groups, i.e. the failure states of this system, are identified logically from that and shown in Table 3.
Fault states table of the missile launcher
As shown in Tables 2 and 3, the state space and the action space of the diagnostic policy building problem are clearly confirmed, and there are 6 terminal states which are F13, F15, F16, F19, F20 and F23. Also the rewards of all state transitions with the chosen test action can be calculated by Equations (13) to (17), which are not be listed due to limited space here.
In practice, as mentioned in Section 3.2, the availability of the priori transition model or a perfect environment model of complete knowledge is absence. To verify the effectiveness of the proposed method, the diagnostic environment for learning should be built in simulation experiment first of all. Therefore, we make an assumption that the transition probability is known forehead in this work. In simple terms, we assume and regard the accuracy of the test result reflects the real fault state with the deviation of interference to be the state transition probability as shown in Table 3, for the state transition in fault diagnosis process is relied on the result of chosen test. Moreover, if the failures of an ambiguous group can’t be detected or differentiated by a test action, the system state does not transfer and remains unchanged with probability of 1.
To illustrate how Q-learning solves the diagnostic policy building problem with imperfect test, some simulations are implemented with the data above. Programmed following the steps of algorithm in Table 1, firstly the diagnostic environment model is built in a simulation environment as the transition probability is assigned in advance. And the optimal diagnostic policy based on Q-learning can be obtained after 60000 iterations. All the simulations are completed in MATLAB environment.
For the Q-learning based method to get the optimal policy, the transition probability P is unknown, the solution relies on the Q-value gathered through interacting with the diagnostic environment not computing the V-function as MDP. Take failure state F9 as an example, the calculation processes of the Q-value under taking test action t1 and t5 are shown in Fig. 4. All Q-values are initialized to 0, and γ=0.9, with ɛ as Equation (13). After 60000 times of iteration, the values tend to be stable.

The iteration processes of Q (F9, t1) and Q (F9, t5).
The learning rate is set as
Furthermore, the Q-values of failure state F9 under different actions is shown in Fig. 5. Also, we can easily figure out the best test action of system failure state F9 is t3 which is corresponded with the maximum Q-value.

Q-values corresponding to different actions of F9.
Similarly, the maximum Q-values corresponding to all failure states can be obtained after 60000 iterations and the stability is achieved. The results are shown in Fig. 6.

Maximum Q-values of different states.
Figure 6 shows the maximum Q-values of each failure state, and the best action-state pairs corresponds to that are F1 ⟶ t4, F2 ⟶ t2, F3 ⟶ t4, F4 ⟶ t3, F5 ⟶ t4, F6 ⟶ t2, F7 ⟶ t2, F8 ⟶ t2, F9 ⟶ t3, F10 ⟶ t4, F11 ⟶ t4, F12 ⟶ t4, F13 ⟶ t1, F14 ⟶ t5, F15 ⟶ t1, F16 ⟶ t1, F17 ⟶ t4, F18 ⟶ t4, F19 ⟶ t1, F20 ⟶ t1, F21 ⟶ t2, F22 ⟶ t4, F23 ⟶ t1, F24 ⟶ t3, F25 ⟶ t5, F26 ⟶ t2. Those results illustrate that the proposed method based on Q-learning is able to get the optimal policy through learning, even the diagnostic environment model is unavailable for tests are imperfect.
Since the optimal diagnostic policy is obtained precisely, the performance of it is studied next. The visiting rate is the number of times that a certain state is reached or stayed within a certain period of time. So in our work, it’s used to describe the diagnostic ability of different policies. The visiting rates of each state can be proved through 1500 Monte Carlo experiments using the Q-learning policy and the results are shown in Fig. 7.

Average occupancy for each state in finite time with initial state of F1 (a) and F2 (b).
From these figures above, after 5 steps diagnosis of test and state transition, the visiting rate of terminal states (F13, F15, F16, F19, F20, F23) is 49.5% of F1 to be the initial failure state, and the occupancy of terminal states under initial state F2 is 65.6%. So the average visiting rate of terminal states is different with different initial states and it increases with the ambiguity decreasing of system failure state for F2 is a subset of F1, which consists with the principle of fault diagnosis.
Moreover, comparisons are made among the Q-learning based policy and classic policies,
i.e. greedy policy and random policy, to discuss the fault diagnosis capability and
diagnosis performance ofthem. Random policy: the test system chooses one test from test action
space A with equal probability at each step. Greedy policy: also named one-step optimal policy and is given as
Q-learning policy: the test action
of each step is determined according to the method in algorithm in Table 1.
The details of them are shown in Fig. 8. And the state transfer situations of different policies in one single experiment are shown in Fig. 9.

Test actions of chosen under different policies.

States transfer under different policies.
The test action chosen of some states may be the same even under different policies according to the results. To discuss the diagnostic performance of these three different policies, the expectation of the system or weapon being diagnosed to reach a terminal state, F13, F15, F16, F19, F20 or F23, is deemed to describe the diagnostic performance appropriately. 1500 Monte Carlo experiments are implemented with the policies and transitions given in Figs. 8 and 9. As a result, the average terminal states occupancy of 3 different policies are shown in Fig. 10. And every experiment is executed for 8 steps and the initial failure state is the ambiguous failure set F1.

Average occupancy of terminal states under differentpolicies.
From this result, we can clearly find that the diagnostic capability of policy based on Q-learning is better for its average occupancy is 70%, which is 10% more than greedy policy and 31% more than the random policy, in addition the occupancy of initial state F1 is 12.5% as a constant in this simulation. Also the curve of policy based on Q-learning converges fastest, which means better performance and adaptive for complex diagnostic environment.
The average occupancies of terminal state F13, F15, F16, F19, F20 and F23 with these 3 different policies are shown in Fig. 11 respectively. All of the terminal states can be achieved at steady-state with the Q-learning, in high or low probabilities. It means that all the corresponding failure site or location can be determined for the purpose of fault diagnosis as expected. Moreover, the occupancy to be 0 means that its corresponding state can’t be reached and the corresponding failure can’t be isolated. And it’s not hard to find out that F15, F13 can’t be visited under greedy policy and F16, F23 under random policy, which means that the failure f3, f4 can’t be detected or isolated under greedy policy, the same as failure f4, f1 to random policy.

Average occupancies of terminal state unde different policies.
From all the above results, the policy based on Q-learning has better diagnostic performance both in capability of isolating all the failures and stability for speed of convergence. The sample of this case is small, or the advantages would be much moreobvious.
In this paper, we have presented a new method based on Q-learning to generate the optimal diagnostic policy by considering the fault diagnosis process with imperfect tests as a RL problem, as the history data of transition probability is hard to acquire completely in the real world. The effectiveness of the Q-learning based method is illustrated to learn the best actions in the diagnosis environment through simulation experiment. The comparison results also demonstrate it has better diagnostic performance in the rapidity and stability of fault diagnosis and capability of isolating all the failures. As there may be two or more failures occurred in real-world weapon system under uncertain information, the diagnostic policy building problem under this condition is worthy of future studies.
