Research of NCS Random Time Delay Prediction Based on FNN-PSO

Networked control systems have been attracting considerable attention during the last decades, not only because of their theoretical value, but also of their widespread practical applications. In practice, networked control systems are inevitably affected by the random time delays. Aiming at the problem of system performance degradation caused by random time delay in networked control systems, a method of combining particle swarm optimization with fuzzy neural network is used to establish a networked control system time delay prediction model and predicts the future time delay. According to the simulation, we verify the effectiveness and feasibility of the proposed method. The results of simulation show that the fuzzy neural network optimized by particle swarm optimization has a high prediction accuracy for random time delay and is suitable for practical applications.


Introduction
The networked control system (NCS) refers to a closed-loop feedback control system formed by actuators, sensors and controllers in the control system to exchange information through the network. The addition of the network in the control loop makes the analysis of NCS complicated, especially the induced time delay in the network has an important impact on the performance of the system [1]. Therefore, accurate prediction of the network time delay is helpful to improve the performance of the NCS.
In recent years, a lot of research results have been reported on the network time delay prediction problem. In [2], a time-delay estimate algorithm for NCS based on least-square support vector machines is proposed. The authors in [3] use Auto-Regressive and Moving Average model to make forward time delay prediction and compare it with the prediction effect of Radial Basis Function neural network. In [4], a particle swarm optimization least square support vector machine method is used to establish an NCS time-delay prediction model and predict the future time-delay. For [5], the authors propose a novel method of NCS stochastic delay prediction based on the Autoregressive Intergrated Moving Average. By using this method, high prediction accuracy can be achieved.
Aiming at the random time delay in NCS, this paper uses the FNN [6][7][8] optimized by PSO to predict the time delay, which makes up for the shortcomings of the conventional BP algorithm, such as slow convergence speed and easy to fall into local extreme points, and ensures the accuracy of prediction.

Fuzzy neural network model
Fuzzy neural network is a combination of fuzzy set theory and neural network. It not only has the large-scale parallel processing ability, self-learning ability and self-adaptive ability of neural network, but also can process fuzzy information and complete fuzzy reasoning function with superior performance.
The prediction model is a four-layer network model with multiple inputs and single output, as shown in Figure 1. The four layers are the input layer, the fuzzification layer, the fuzzy inference layer, and the output layer.  The first layer is the input layer, the number of neurons in the input layer is the same as the number of input variables, and the input vector is = ( 1 , 2 , ⋯ , ) . y is the output layer variable. Since the output variable is the predicted value of future time delay and has only one, there is only one neuron in the output layer. The jth fuzzy rule of the system can be expressed as where is the result of the jth rule, j depends on the number of neurons in the fuzzy inference layer; is the fuzzy subset corresponding to the input variable, and = 1,2, ⋯ , , j depends on the number of fuzzy subsets of each input variable.
The second layer is the fuzzification layer. In this layer, the membership degree of each input variable is calculated. The normal distribution function is used as the membership function, and the formula for calculating the ith input variable satisfying the fuzzy subset is as follows where is the expectation of normal distribution function, is the standard deviation, and the membership degree of input variables is completely determined by parameters and . The third layer is the fuzzy inference layer. This paper defines the connection weights of the fuzzification layer and the fuzzy inference layer according to the fuzzy theory.
where ( ) is the membership of the input variable to the fuzzy subset . The FNN performs the fuzzy decision function from the third to the fourth layer. Assuming that there are m rules in the system, this paper uses the weighted average method to defuzzify and obtains the output as where is the connection weight between the fuzzy inference layer and the output layer. To train the FNN, the expectation and standard deviation of the normal distribution function and the connection weight need to be determined. Gradient descent method is commonly used in neural networks. The algorithm has slow convergence speed and is easy to fall into local optimization problems, so it is difficult to get the global optimal solution. In order to solve this problem, the PSO algorithm with global optimization performance is used to optimize the parameters of the FNN.

Particle swarm optimization algorithm
2.2.1. Mathematical description of particle swarm optimization. If a target is found in a D dimensional space, the population is composed of m particles. Each particle in the population has its own position, and the position of the ith particle is represented by = (x i1 , x i2 , ⋯ , x iD ), i = 1,2, ⋯ , m, and its velocity is also denoted by a D-dimensional vector = (v i1 , v i2 , ⋯ , v iD ). When each particle passes through a new position, it compares with all the positions that have passed before. When the ith particle flies to a certain position, the optimal position it passes is = (p i1 , p i2 , ⋯ , p iD ) . By comparing the optimal positions of all particles in the particle swarm, the optimal positions of all particles are obtained and expressed as = (p g1 , p g2 , ⋯ , p gD ). Each particle changes its position according to the following formula.

2.2.2.
Algorithm flow chart. The particle swarm algorithm flow chart is shown in Figure 2. The position and velocity of the particle are randomly initialized, the particle fitness value is calculated, and the particle position is compared with the optimal position to determine whether the convergence criterion is satisfied. If satisfied, the output particle position is regarded as the optimal position of the particle swarm; if not, the position and velocity of the particle are updated, and the iteration continues.

Fitness function and parameter optimization steps.
The PSO is used to optimize the connection weight and membership function of the FNN. That is to say, the element of the position vector of the PSO is the connection weight of the FNN, the expectation and standard deviation of the membership function. The training of neural networks is mainly to minimize the parameter errors in the network. Therefore, the fitness function can be defined as where is the number of training set samples; is the expected output; is the actual output. The steps of parameter optimization based on particle swarm optimization are as follows: 1) Initialization, randomly initialize the position and velocity of each particle, and determine parameters such as population number, inertia weight and acceleration factor; 2) Calculate the fitness of each initial particle, is the optimal position of the current particle and is the optimal position of the particle swarm. 3) Update the position and velocity of the particles according to formulas (5) and (6) to generate new particles; 4) Return to step 2) until the convergence criterion is satisfied, the iteration stops, and the global extremum is the optimal solution of the training problem.

Prediction model establishment
In this paper, the rolling prediction method is used to predict the network time delay. The first five delay values are taken as input sample 1 and the sixth delay value as output sample 1 to form a sample pair. The second to sixth delay values are taken as input sample 2 and the seventh delay value as output sample 2 to form the second sample pair. By analogy, 300 sample pairs are constructed as data for training neural networks. After that, the 301st to 305th delay values are taken as input samples, and input to the trained FNN as an input vector to obtain the first network delay prediction value. Then, the 302nd to 306th delay values are used as input samples to obtain the second network delay prediction value, and by analogy, 20 network delay prediction values are obtained. The prediction flow chart is shown in Figure 3, and the modeling steps are as follows.
(1) Establish and train fuzzy neural network. The structure of the neural network is determined by clustering algorithm, and the number of fuzzy membership degrees is selected by Kohonen network [9]. It is determined that each input variable is divided into two fuzzy subsets, so the structure of the fuzzy neural network is 5-10-32-1. Then the training data are used to train the fuzzy neural network.
(2) Optimize network parameters. Initialize the particle swarm optimization algorithm, set the population number to 30, the acceleration factor to 1 = 2 =2, the fitness threshold to 0.001, and the maximum allowable number of iterations to 350.
(3) Model prediction. The test data is used to verify the model and the final prediction results are obtained.

Simulation results and discussion
Two kinds of fuzzy neural networks are constructed. One uses gradient descent method to train the neural network parameters (FNN), and the other uses particle swarm optimization (FNN-PSO). The performance comparison of the two types of fuzzy neural networks is shown in Figure 4.  [10] are selected to analyze the error of the predicted data, and the error indexes are shown in Table 1. where is the true value, ̂ is the predicted value, and N is the total number of samples. It can be seen from Table 1 that when predicting the network time delay value, compared with BP algorithm, such error indexes as RMSE, MAPE, and MAE of PSO algorithm are decreased by 22.27, 3.85, and 22.35 percentage points respectively. The error indexes prove the effectiveness of the PSO algorithm, and the prediction accuracy is higher than the conventional BP algorithm. According to Figure 4, it can be seen that the prediction model based on PSO and FNN has better fitting ability to actual data.