A train F-TR lock anti-lifting detection method based on improved BP neural network

. In the railway container yard, there are few mature intelligent lifting prevention solutions available for train flatbed loading and unloading operations due to the poor detection accuracy or speed of traditional detection methods. This paper designs a train Flatbed Twist Rail (F-TR) lock anti-lifting detection method based on an improved BP neural network. The system collects weight and laser distance measurement data from the four locks of the hoist, establishes a flatbed lifting detection model based on the BP neural network, and optimizes the model's performance by incorporating a momentum factor and adaptive learning rate during weight adjustment. In practical tests, this system demonstrates a high detection rate and fast detection speed, offering intelligent safety protection for automated rail mounted gantry in the railway container yard.


Introduction
In the railway container yard, the locking mechanism commonly used on train flatbed wagons is the F-TR lock [1], as shown in Fig. 1.The F-TR lock is a type of locking mechanism with a distinctive eagle-head structure used on flatbed wagons to secure containers or cargo for safe loading.If the container's lock hole is not properly disengaged from the F-TR Lock during the lifting process by a Rail-mounted Container Gantry Crane (RMG), it can lead to a situation where the crane's hoisting equipment lifts both the container and the entire flatbed wagon of the train together.This is typically referred to as a "F-TR locked lifting accident".As shown in Fig. 2, it's quite hard to inspect the safety hazards accurately and quickly for the RMG operator in the remote control room.Once RMG lifts both the container and the train flatbed together, extremely serious safety incidents can occur, such as the F-TR lock being pulled out from the train flatbed, or in more severe situations, the train flatbed can be pulled apart, and there can even be damage to the RMG itself [2].In container terminals, to ensure the safety of intelligent remote control operation and prevent operational accidents and improve operational efficiency, both domestic and international scholars have researched and designed various intelligent lifting prevention systems for container vehicles.For instance, Lv and Du [3] proposed a real-time detection system to detect whether the truck is lifted by using laser radar to scan the displacement information of the container trucks chassis.Similarly, Zhen and others [4] suggested using laser radar to scan the contour information of the target and reconstruct it into a 3D model.By analyzing the geometric shape of the model, the system calculates the dimensions and positions of the target to detect whether the truck is lifted.Using laser radar scan data for detection and recognition offers high accuracy and resistance to environmental and weather interference.However, the drawback is that laser radar equipment can be relatively costly [5].With the advancement of image recognition and measurement technologies, more and more image detection techniques have been applicated in the field of automated port [6].These include container number recognition based on image recognition technology [7], container lock positioning [8], ship identification and tracking using vision-based target tracking technology [9,10], and container trucks tracking [11] etc. In addition to the advantages of lower equipment costs and convenient camera installation, image-based detection technologies offer two key benefits.First, vision-based detection uses Complementary Metal-Oxide-Semiconductor (CMOS) or Charge-Coupled Device (CCD) cameras with high image resolution to acquire image information, enabling higher measurement accuracy through non-contact measurement [12].Second, based on deep learning techniques such as Convolutional Neural Networks (CNN) can recognize complex features [13].For example, Huang et al. [14] employed a feature point matching algorithm to compare feature points in each frame of the video with those in the prelifting frame, calculating the coordinate changes between feature points to determine if the container trucks have been accidentally lifted.Huang et al. [15] designed a container trucks lifting detection system based on CNN and target tracking algorithms to identify and track the displacement of the container truck's hub in real-time to detect accidental lifts.
However, the intelligent lifting prevention systems for container trucks cannot be directly applied to the train flatbeds unloading operations in railway container yards due to the following reasons: (1) Inapplicable Technical Solutions.The intelligent lifting prevention systems for container trucks primarily use either laser, vision, or a combination of both technologies.Laser-based solutions involve real-time detection of container separation from the chassis during unloading by sweeping lasers across the container and truck frame.Laser solutions provide high stability and detection rates, capable of handling situations where individual locks on the flatbed are not unlocked.However, these solutions cannot precisely measure the lifting height.On the other hand, vision-based solutions involve real-time collection and processing of images from multiple cameras during the lifting process to identify and detect movements of specific features on the container trucks.The drawback of vision-based solutions is that they lack high precision, real-time capabilities as laser solutions.Combining laser and vision-based systems can harness the advantages of both methods, offering high detection accuracy and precision.However, the drawback is that such systems tend to be relatively costly.
However, the technical solutions used in intelligent lifting prevention systems for container trucks are not applicable to the detection of F-TR locks on train flatbeds.These lifting prevention systems for container trucks are primarily designed for single-lane.But in railway container yards, there are typically two railway tracks.The technical approaches employed in container trucks lifting prevention solutions are based on one side scanning.These methods are not suitable for railway container yards with two parallel railway tracks because they can be obstructed by the presence of multiple tracks.
(2) Inadequate Accuracy Requirements.Detecting F-TR locks on train flatbeds requires extremely high accuracy and real-time performance.National Railway Administration regulations dictate that once a train flatbed is lifted, any damage to the locks at the bottom of the flatbed results in the flatbed being deemed unusable, causing significant operational accidents.However, in existing container handling vehicle lifting prevention solutions, both laser and vision-based methods require a certain degree of lifting of the flatbed before detection is finished, which makes them unsuitable for detecting F-TR lock lifting prevention in real-time.
As the research on artificial neural networks becomes mature, Artificial neural networks have been widely applicated in various industries.It is able for artificial neural network to approximate complex nonlinear mappings with arbitrary precision [16].This provides an excellent solution for problems with low accuracy in indirect measurements.Chen, Qin, Hao et al. used neural networks to establish load prediction models for vehicle weighing [17][18][19].Vyas and Satishkumar [20], Pany et al. [21] applied artificial neural networks for mechanical fault prediction and river flow prediction.However, the above-mentioned studies were all conducted using traditional BP neural networks, which have long iteration times and limited prediction accuracy.Kosarac et al. [22] presents the development and evaluation of neural network models using a small input-output dataset to predict the thermal behavior of a high-speed motorized spindles.The results indicate that even with small-scale datasets, artificial neural networks can achieve high prediction accuracy.Sun et al. [23] use an improved BP neural network algorithm to diagnose computer communication network failures.Chen and Peng [24] improved BP neural network algorithm by incorporating a momentum factor and adaptive learning rate to predict traffic accidents.Compared to traditional BP neural network algorithms, it demonstrated faster convergence and higher prediction accuracy.
In summary, the technical solutions used in intelligent lifting prevention systems for container trucks cannot be directly applied to the unloading of train flatbeds in railway container yards.This paper proposes a F-TR lock anti-lifting detection method based on improved BP neural network.Unlike traditional intelligent container trucks lifting prevention solutions that rely on laser or vision-based detection, this system uses the weight data and laser ranging data from four locks of the hoist as samples to establish a BP neural network model for detecting train flatbed lifting.The training process incorporates a momentum factor to improve the algorithm.

System design and control principle
In this system, weight sensors and laser sensors are installed at the four locks of the hoist on RMG to collect information related to container lifting operations, and this design is also adaptable for various container handling equipment.As shown in Fig. 3, the installation on the hoist on the RMG is presented as an example.
The implementation principle of the F-TR lock lifting prevention system(F-TRLLPS) for train flatbeds is shown in Fig. 4. The F-TRLLPS serves as an independent information collection system that communicates with Automatic Crane Control System (ACCS).ACCS is a common control system used on RMGs responsible for managing and controlling RMG operations.
When the RMG is on working, the F-TRLLPS continuously collects real-time data from the four locks of the RMG hoist, including weight data and laser ranging data.These data are then processed by the algorithm module to determine whether there is a connection between the F-TR lock on the train flatbed and the container.If the system detects that the F-TR lock is not unlocked, the algorithm module sends an alarm signal to ACCS, which can immediately stop the movement of the lifting equipment using Programmable Logic Controller (PLC).

F-TR lock lifting detection algorithm
BP neural networks are trained using the backpropagation algorithm and have characteristics such as non-linear mapping, self-organization, and self-learning.The learning process of the BP neural network algorithm consists of two parts: forward propagation and backpropagation [25][26].The model structure of the BP neural network is shown in Fig. 5.

Fig. 5. Schematic diagram of BP neural network
It is a single-layer neural network that takes the weight sensors values and laser sensors values from four positions (left front, left rear, right front, right rear) on the hoist as input.The output layer consists of a single neuron representing the confidence level of whether the train is lifted (0.9999 for lifted and 0. 0001 for not lifted).This results in 8 input layer neurons and 1 output layer neuron.

Data acquisition and preprocessing
In the railway container yard, there are typically four operational conditions: 20-foot empty containers, 20-foot loaded containers, 40-foot empty containers, and 40-foot loaded containers.Depending on the engagement status of the F-TR lock and the container, these conditions can be further categorized into normal lifting, 1 lock engaged, 2 locks engaged, 3 locks engaged, and 4 locks engaged.Data was collected for each of these conditions through weight sensors and laser ranging sensors, resulting in 20 rounds of data collection.Each round included 10 data sets, with 5 sets used for training and 5 sets for testing.
Due to the strict requirements of flatbed unloading operations, the lifting process requires incremental movements.During these incremental movements, the collected weight data exhibit a step-like pattern.The fluctuations in weight data and laser ranging data generated by the RMG operator's incremental lifting, as shown in Fig. 6 and Fig. 7, which can affect the detection of whether the train flatbed has been lifted or not.Therefore, noisy data at the initial phase of lifting (when the hoisting wire rope is not yet fully tensioned) should be filtered out.Data preprocessing is performed to extract the data during the period from when the hoist securely locks the container until the container detaches from the F-TR locks is extracted based on the following conditions: (1) The weight data from individual lock must be above a threshold.
(2) The sum of the weight data from all four locks in the current frame must be greater than the sum in the previous frame.
(3) The sum of the weight data from all four locks in the current frame must be greater than the maximum sum in historical data.
(4) The difference between the sum of the weight data from all four locks in the current frame and the sum in the previous frame must be above a threshold.
(5) The laser ranging data from individual lock must be above a threshold.Furthermore, it is necessary to normalize the collected sample data to prevent neuron saturation and improve the training efficiency of the neural network.This is achieved by using transformation Eq. ( 1) to scale the data to the range of [-1, 1]: where  represents the -th data point of a particular feature parameter;  is the minimum value of this feature parameter within a set of data;  is the maximum value of this feature parameter within a set of data;  is the normalized value of the -th data point of this feature parameter.
The processed sample data is then used as the database for training and testing the BP neural network.To avoid the issue of one class of samples dominating the training and causing the network to bias towards it, while neglecting the other class when it's input, different rounds of test data are cross-input to reconstruct the training sample set.

Building network structure
The performance of the BP neural network model greatly depends on the number of neurons in the hidden layer.An empirical Eq. ( 2) is used to determine the range of values for the number of hidden layer neurons [27].By comparing the mean square error values of different neural networks with varying numbers of hidden layer neurons, the optimal number of hidden layer neurons is determined: where,  represents the number of hidden layer neurons;  and  represent the number of input layer and output layer neurons respectively;  is a variable constant.By setting  to 8,  to 1, and varying the value of  within the range [1,10], and subsequently substituting these values into Eq.( 2), the range of the number of hidden layer neurons is determined to be [4,13].Training is conducted for 500 iterations using training samples for networks with different numbers of hidden layer neurons.The relationship curve between the number of hidden layer neurons and network output error is shown in Fig. 8.As observed, within the range of hidden layer neuron values, the network's output error initially shows an upward trend followed by a decrease, with the minimum error occurring when the number of hidden layer neurons is 11.However, as the number of hidden layer neurons continues to increase beyond this point.And the last there is a slight fluctuation.Therefore, this paper adopts 11 hidden layer neurons for the F-TR lock lifting detection model.

Improvement learning algorithm
The algorithmic operation of the BP neural network includes two processes: forward propagation and backpropagation modification.The training process of the BP neural network is as shown in Fig. 9.In the forward propagation process, input sample data is weighted and transmitted to the hidden layer to calculate the output error; in the backpropagation modification process, the weights of each layer are continuously adjusted through backpropagation to ensure that the actual output meets the accuracy requirements of the expected value.
Traditional BP neural network algorithms face issues such as slow convergence and susceptibility to local minima due to the large number of input parameters [28].Therefore, in this paper, improvements are made to the traditional BP neural network algorithm by introducing a momentum factor and adaptive learning rate during the weight adjustment in backpropagation.
Assuming in the -th iteration of neural network training, with input variables  () ( = 1,2, … 8), we can derive: where,  ( = 1,2, … 11) represents the output variables of the hidden layer;  is the activation function;  represents the connection weight from the input layer to the hidden layer;  is the bias of the hidden layer.After undergoing activation function computation in the hidden layer, it is transmitted to the output layer, and the transmission relationship is as follows: where, () represents the output of the neural network,  is the activation function;  represents the connection weight from the hidden layer to the output layer;  is the bias of the output layer.
The mean squared error of the actual output of the neural network and the expected output  (), which can be calculated through Eq. ( 5), is the objective function for neural network training: The adjustment of weights  from the hidden layer to the output layer and weights  from the input layer to the hidden layer is calculated using the negative gradient descent algorithm.Additionally, the adjustments from the previous iteration are incorporated, as shown in Eq. (6-7): where,  represents the momentum factor, which is empirically set to 0.7 in this paper; () is the learning rate at the -th iteration, with an initial value of 0.1.

Fig. 9. Training process of BP neural network
The adjustment of the learning rate () is based on the total network error, typically measured by using mean squared error.The adjustment is made as follows: If the error at the -th iteration, () > ( + 1), then the learning rate for the ( + 1)-th iteration is increased to accelerate convergence; If 1.04 * () < ( + 1), it suggests that the step size is too large.In this case, the learning rate for the ( + 1)-th iteration should be decreased to ensure convergence [29]: Subsequently, following the algorithm's process, the sample data is re-inputted to adjust the neural network's weights.The neural network then computes the output error, and it is checked whether this error meets the precision requirements.If it doesn't meet the precision requirements, the weights are adjusted again using backpropagation.By continuously adjusting the weights and iterating the computations until the error accuracy meets the requirements.Analyzing the mean square error performance curves of the traditional BP neural network algorithm and the improved BP neural network algorithm, it can be concluded that the improved BP neural network algorithm can bring the best error closest to the expected error, and the error curve shows a smooth descent, significantly enhancing the algorithm's convergence speed.

Experiment and analysis
The final output of the model after training is the confidence level for F-TR lock lifting detection.A confidence level  is set to determine whether the train flatbed is lifted.If  = 0.8 is chosen, then:  ≥ 0.8, The train flatcar is lifted,  < 0.8, The train flatcar is not lifted.
Compare the model's predicted results with the actual test results, and calculate the detection rate of this algorithm by using Eq.(10): The F-TR lock anti-lifting detection method test was carried out at a railway container yard.To simulate the train flatbed being lifted, the F-TR locks and the container lock holes were tied with iron chains, as shown in Fig. 11.The weight data and laser ranging data collected in real-time during actual operations are shown in Fig. 12.
The experiments were conducted under 20 different conditions, including 20-foot empty container, 20-foot loaded container, 40-foot empty container, and 40-foot loaded container, each tested for normal lifting, single F-TR lock engagement, double F-TR locks engagement, triple F-TR locks engagement, and quadruple F-TR locks engagement.The experimental results are presented in Table 1.
Similarly, the traditional BP neural network algorithm was tested by using the same dataset to predict its outputs.The comparison of the testing performance between the two learning algorithms is shown in Table 2.According to Table 2, compared to the traditional BP neural network algorithm, the improved BP neural network algorithm, which incorporates a momentum factor and adaptive learning rate, exhibits higher detection rates (The detection rate has been increased by 8 %) and faster network convergence (The average detection time has been reduced by 73 %).

Conclusions
Railway container yard requires an intelligent lifting prevention system to prevent accidents where containers and train flatbeds are lifted together.This paper presents a train F-TR lock anti-lifting detection method based on improved BP neural network.It utilizes a BP neural network to construct a model for detecting train flatbeds lifted and improves the algorithm to enhance detection accuracy and convergence speed.The following conclusions can be drawn: 1) Compared to the traditional BP neural network algorithm, improving the algorithm's performance by introducing a momentum factor and adaptive learning rate in weight adjustments can significantly enhance the model's detection accuracy and reduce the detection time.Through experimental testing, in comparison to the traditional BP neural network, the train F-TR anti-lifting detection method based on the improved BP neural network demonstrates higher detection accuracy (96 %) and shorter detection time (131 ms).
2) The train F-TR anti-lifting detection method based on the improved BP neural network proposed in this paper demonstrates that the detection accuracy and speed can meet the requirements for preventing lifting incidents during train flatbed operations in railway container yards.Additionally, due to the lower hardware equipment costs and more convenient installation, it is more suitable for railway container yard train flatbed anti-lifting detection than traditional laser radar or visual solutions.
In the future, the train F-TR lock anti-lifting detection method proposed in this paper has the potential to further improve the detection rate by replacing the laser ranging sensor with higher measurement accuracy equipment, such as laser radar.This anti-lifting detection method has been applied in an intelligent railway container yard in China, assisting the intelligent remote control system in automating train loading and unloading operations.

2 .
a) Normal lifting b) F-TR locked lifting accident Fig.Normal lifting and F-TR locked lifting accident while unloading operation

Fig. 6 .Fig. 7 .
Fig. 6.Weight data waveform from the four locks of the hoist during jogging operation

3. 4 .
Model training Developing a program to implement the improved BP Neural Network algorithm, and use training sample sets to train both the traditional BP neural network algorithm and the improved BP neural network algorithm.Set the error target value to 0.0001, with 500 iterations.Both algorithm's mean squared error curves are shown in Fig. 10.In each figure, the solid line represents mean square error, the dashed line represents the best mean square error during training, and the dotted line represents the expected mean square error.a) Traditional BP neural network algorithm b) Improved BP neural network algorithm Fig. 10.Mean square error performance curves

Fig. 12 .
Fig. 12. Schematic diagram of experimental weight data and laser ranging data waveform

Table 1 .
Experimental results of the train Lifting prevention detection method based on improved BP neural network

Table 2 .
Comparison of detection rate and average detection time between improved and traditional BP neural network algorithm Fig. 11.Simulate the train flatbed being lifted