# Demonstration of Smart Railway Level Crossing Design and Validation Using Data from Metro Rail, South Africa

Authors: D.C. Tshaai; A.K. Mishra; Jan. Pidanic
Journal: Journal of Advanced Transportation
 (2022)

---

## Abstract

Long waiting time at railway level crossings poses a risk on the safety and affects capacity of rail and road traffic. However, in most cases, the long closing time can be prevented by reducing the time lost at a railway level crossing. The emphasis of this study is to present a numerical optimisation algorithm to reduce the time lost per train trip at a railway level crossing. Thus, attributes with the highest impact on the railway level crossing closing time were extracted from the data analysis of rail-road level crossings on the southern corridor of the Western Cape metro rail. Powell’s optimisation algorithm was formulated on the minimisation of the time lost at the railway level crossing per trip. Thus, time lost is constrained by the technical and train’s traction constraints. The upper and lower bounds of Powell’s algorithm were defined by the threshold closing time in addition to the actual and expected probability density functions. The algorithm was implemented in Matlab. Furthermore, the algorithm was trained on 8000 data sets and tested on 2000 data sets. The developed algorithm proved to be effective and robust in comparison to the current state of railway level crossings under study. Thus, the algorithm was validated to reduce the time lost at the railway level crossing by at least 50%.


---

## Body

## 1. Introduction

A railway level crossing marks a point of shared responsibility between rail and road transport. Both modes of transports have different operational characteristics, but first preference is given to the railway because of its operational complexities. There is a growing concern of unsafe human behaviour at the railway level crossings due to the long closing time of gates on the passage of the train [1]. In addition, the presence of railway level crossings increases the train’s travel time in the network, thus constraining traffic capacity. This is often attributed to the imposed speed restrictions as well as train’s scheduled stops. Moreover, long waiting time is inevitable in the case of increased railway traffic heterogeneity and volume. Furthermore, a train travelling at the speed significantly lower than the maximum permissible speed results in activation being triggered at the same point as when the train is travelling at the maximum permissible speed. Therefore, a train with slower speed increases the closure duration [2, 3]. Thus, triggering of the railway level crossing from far tends to result in the slower train spending more time over the entire crossing section. As a result, long waiting time poses safety and capacity risks at the railway level crossings [1].Railway level crossings are both safety critical and sociotechnical. Therefore, the problem with such a system tends to be cross dimensional with a large number of underlying uncertainties. Thus, machine learning has demonstrated superior performance in transit problems and is drawing significant attention in data analysis and optimisation of the railway level crossing parameters [4]. Extensive literature exists in the application of machine learning in the safety and capacity of the railway level crossings in area of safety improvement. For instance, a data consolidation model was developed to determine which railway level crossings can be closed in the United States as part of the effective safety program [5]. This involved the application of an eXtreme Gradient Boosting (XGBoost) algorithm in determining the railway level crossing closing decision based on the 14 features derived from safety, engineering, economic, environmental, and social aspects. The model was able to achieve an expert judgement with an accuracy of 0.991. On the other hand, an Analytic Hierarchy Process based on the compromise ranking method was applied in railway route planning and design [6]. The results demonstrated that the explicit complex decision-making process can be achieved in railway applications using multicriteria optimisation methods.Binary programming was applied in the prioritisation of the railway level crossing project, based on the average probability of havingm crashes from the n railway level crossings within the corridor [7]. Thus, the average probability obtained from the binary programming was able to select the optimal set of safety improvement actions, which could yield the maximum railway level crossing reliability and mobility. Conversely, the Random Forest algorithm proved effective in the ranking and analysis of the railway level crossing attributes in the selection of the suitable protection type [8]. The algorithm was able to identify the key safety factors with highest influence on the safety improvement and collision prediction at the railway level crossings in Canada. In addition, a full Bayesian analysis has been applied in the selection of the best estimate of the accident modification factors, based on the combination of the likelihood and prior knowledge of countermeasures [9]. The framework was able to discern the anticipated safety benefit of countermeasures in the face of uncertainty across the accident modification factor credible interval.However, Liang et al. proposed a similar framework on the railway level crossing risk assessment. A probabilistic risk assessment and improved decision was achieved based on the application of Bayesian framework on datasets collected from several railway level crossings in France [10]. Thus, the model indicated that about 81% of the rail and road vehicle accidents resulted in zero fatalities, whilst 19% of accidents were likely to result in fatalities [10]. A combination of Local Estimated Scatterplot Smoothing (LOESS) and Generalized Additive Model (GAM) performed effectively in evaluating the in-vehicle railway level crossing warning system based on a taxi’s speed, acceleration, and jerk data [11]. The model revealed that taxi drivers showed improved behaviour with an in-vehicle warning system. Yet speed, acceleration, and jerk difference per multiple transit indicated that the model showed a lack of empirical generalizations of the taxi drivers who used the service.Machine learning has also been applied in traffic control at the railway level crossings. A multiagent system was proposed in modelling urban traffic control to improve capacity at the railway level crossings [12]. An intersection agent (ISA) was used for the railway level crossing since it marks the intersection of the rail and road. Therefore, fusion of the intelligent ISA control cooperation and genetic reinforcement learning algorithm was proposed to ensure effective cooperation among the rail and road agents. Thus, the ISA control strategy would modify the signal cycle of every intersection with the help of the reinforcement learning in actualizing the local traffic optimisation. The study reported that the intelligent cooperation control is most effective for higher traffic volume; however reinforcement learning allowed the evaluating index to increase when the traffic flow increases and surpasses saturation [12].An object detection railway level crossing protection system is another field that has seen an increasing application of machine learning. Hence, object parametrisation and localisation usually involve the application of classification learning algorithms and Kalman filtering for object tracking [13, 14]. However, the challenge with these algorithms is evident in video processing because they cannot detect every pixel of the object [13]. Furthermore, machine learning application confirmed that the three best measures for managing railway level crossing accidents can be achieved by the in-vehicle warning system, obstacle detection, and constant warning time [9, 11]. However, constant warning time without optimal railway level crossing closing tends to perpetuate unsafe human behaviour [1, 15]. The impact of long railway level crossing closing time on the railway planning and operation is often significant and, if not monitored, may result in adverse consequences [3, 16]. Moreover, the inability to predict and reinforce minimal railway level crossing closing time is likely to disintegrate the traffic management system [17].Nikolajevs et al. proposed prediction of the railway level crossing closure duration, based on the train speed measurement by either additional sensors or evaluation of the track circuit’s impedance [2]. However, prediction of the closure time does not reinforce adherence to minimal railway level crossing closing time. Alternatively, Work et al. proposed the use of a support vector machine in the prediction of the train arrival time at the railway level crossing. Comparative analysis of the various machine learning algorithms indicated that the Random Forest algorithm provides the best estimation within an appropriate timeframe compared to linear regression and neural network [18]. Likewise, the multitask deep neural network has proven effective in estimating short-term transit delays [4]. Nogushi et al. proposed the reduction of the railway level crossing closing time using an optimal rail-road schedule. The optimal schedule was calculated from a genetic algorithm using time delay for each train at each station as a gene value and the closing time as the fitness value. Thus, the study confirmed the reduction of the railway level crossing blocking time with the changing combinations of the departure time [19]. Moreover, the study concluded that the rail-road waiting time can be reduced through the application of the genetic algorithm on the calculation of the schedule, taking into account the train’s location and speed [20]. Thus far, there is limited literature on the application of machine learning or data-centric methods in the optimisation of the railway level crossing closing time.The present study proposes reducing the time lost at railway level crossing per train trip. Thus, this study contributes to the existing literature in the application of machine learning in the railway level crossing safety and capacity analysis. Moreover, the study demonstrates the significance of data-centric models on rail-road level crossing operations. In this study, railway level crossings found the southern corridors of the Western Cape metro rail are used to formulate the optimisation of the railway level crossing closing time. Thus, the criterion used by Powell’s method [21] is based on the minimisation of the area bounded by the threshold closing time as well as the actual and expected density functions. The proposed method is compared to the current status quo of the railway level crossings in the Western Cape, South Africa. The method showed satisfactory results thus proving its effectiveness.The structure of the paper takes the following form. Section2 discusses preliminaries of the railway level crossing closing time and the application of numerical optimisation. The adopted methodological process is outlined in Section 3. Lastly, results and discussions are presented in Sections 4 and 5, respectively.


## 2. Preliminaries

The railway level crossing depends on the activation and deactivation points denoted by A and C in Figure1. A simple illustration of the train trajectory at the railway level crossing is shown in Figure 1; thus a track section is delimited by at least two detection points (A or B or C). The detection of the first train axle over A triggers the railway level crossing protection. Similarly, detection of the last train axle over C will withdraw the railway level crossing protection. Thus, railway level crossing closing time is the time difference between the insertion and withdrawal of the protection. The train is expected to brake on the approach of the railway level crossing’s activation track (t_a). Furthermore, the train enters into coasting driving mode along the railway level crossing inner area bounded by S0 and S0_1. Lastly, the train accelerates on the exit of the deactivation point (C).Figure 1
The railway level crossing layout.Assume that no vehicles or passengers get trapped inside the railway level crossing once the protection is enabled. The objective variablet (level crossing closing time) is the sum of the contribution of the feature vector x at the ith location on the railway level crossing. The objective function is constrained by the technical and traction parameters shown in Figures 1 and 2, respectively. Hence, optimisation of the railway level crossing time can be expressed as follows:(1)minimise∑i,ktixkfori∈ℝ+,k=1,…,3,s.t.xkεXktechnical constraints stated in Table1∑iFi≥p,p∈ℝtraction characteristics stated in Table2.Figure 2
Block diagram of the railway level crossing optimisation solution.The termxk denotes attributes extracted from data collected from the railway level crossings under study. Thus, technical constraints include dwell time, railway level crossing speed restriction, and time delay on the protecting signals. In contrast, traction characteristics include the longitudinal forces and velocity at a location on the railway level crossing. The resultant traction force shown in equation (2) illustrates the relationship between the force acting on the train and the velocity.(2)∑F=Ftv−Rv,r,β−FbvwhereMJ is the train’s inertial mass,Ftv=μtMjdv/dt is the train’s traction force,Rv,r,β=c0+cvv+cav2+MjD/1000r+Mjgcosβ is the sum of resistive forces,Fbv=1/2Mjdv/dt is the train’s braking force,v,r,β is the train’s speed, rail curvature radius, and angle of inclination.The rail curvaturer and angle of inclination β are different for each railway level crossing. Moreover, coefficients c0, cv, and ca represent the axle-rail friction, mechanical resistance of shaft rotation, and aerodynamic resistance; μt is the tractive resistance. Lastly, coefficient D depends on the rail characteristics.


## 3. Methodology

Railway level crossing closing time is influenced by many attributes, some generic or specific to each system. Generic parameters are always accounted in the design whilst specific parameters receive no attention [3, 22]. However, it is imperative to assess specific attributes to achieve optimal railway level crossing closing time. Thus, specific attributes of the railway level crossings found on the southern corridor of the Western Cape metro rail were analysed. Attributes with highest influence in the railway level crossing closing time were extracted from the analysis. It was found that dwell time, train speed, and time delay imposed on the protecting signals were the most important features influencing the closing time on the southern corridor [15]. Furthermore, the analysis revealed that the coexistence of at least two of these attributes has a severe effect on the level crossing system’s capacity and safety [15].The diagram in Figure2 illustrates the method adopted, followed by the detailed overview in Sections 3.1, 3.2, and 3.3. Data of events concerning the operation of the railway level crossings on the southern corridor of the Western Cape metro rail were collected. A total of 10000 separate events of the track occupancy and signal routing involved in the railway level crossing operation were recorded. Only, ‘occupied’ and ‘clear’ track occupancy statuses are considered. Thus, track occupation time marks the time at which the first axle of the train is detected on the track section, whilst the track’s vacancy or “clear” time marks the time at which the last axle of the train is counted out of the track section.Railway level crossing closing time is approximated by the time difference between the occupation time of the activation track and clearing time of the deactivation track. In addition, speed of train as it enters the activation track is estimated from the distance, occupation, and release time of the section. Some of the considered railway level crossings have, at most, 15 s time delay on the protecting signals due to lack of braking distance. Thus, total time delay incurred due to the timer on these signals is evaluated from the time the activation track is occupied to the time at which the train exits the track in response to elapsed signal timer.The regression model is derived from the data, as shown in Figure2. The data is passed into the kernel density estimation (KDE) algorithm which is used to determine the probability density function of the time spent per train trip. Numerical optimisation (Powell’s method) is formulated based on the results of the regression model and KDE algorithm. At last, numerical optimisation is applied to reduce the time lost per train trip as a result yielding optimal railway level crossing closing time.


### 3.1. Data Analysis

Regression techniques are used to derive the model of the attributes with the highest influence on the railway level crossing closing time. Hence, regression model of railway level crossing closing timey and feature vector x of n=3 features and m=8000 training sets were built in Matlab. Moreover, the model was tested using 2000 data sets. The feature vector represents dwell time, train entry speed, and time delay on the protecting signals denoted by x1,x2, and x3, respectively. Dwell time exhibits a linear pattern whereas others exhibit nonlinear patterns, as shown in Figures 3, 4, and 5. Thus, feature transformation was applied to the nonlinear features.Figure 3
The best fit of the dwell time against railway level crossing closing time.Figure 4
The best fit for the train’s entry speed against railway level crossing closing time.Figure 5
The best fit for time delay against the railway level crossing closing time.The hypothesishθx of the regression model is given in (2) with q1x,θ and q2x,θ being the parameterised nonlinear function for train entry speed and time delay on the protecting signal, respectively. The quadratic and exponential feature transformation functions were selected for the train entry speed and time delay. The feature transformation has been introduced to allow for application of the gradient descent and least squares. Thus, expressions of the feature transformation function are shown in (3) and (4). Gradient descent is applied to tune the parameters of the model by minimising the regression cost function over θ as given in (5). In addition, Jacobian leverage is applied in estimating the parameters of the nonlinear feature transformation function.(3)hθx=∑i=13hθixiwhere θ1=θ0,θ1T, θ2=θ2,θ3,θ6T, and θ3=θ4,θ5,θ7T; hθ1x1=θ0+θ1x1, hθ2x2=θ2+θ3q1x2,θ6, hθ3x3=θ4+θ5q2x3,θ7.(4)q1x2,θ6=maxx2+1−x21001+θ6x22,q2x3,θ7=expθ7x3,minθJθ=minθ12m∑i=1mhθxi−yi2.θ=θ1,θ2,θ3T;xi=x1i,x2i,x3iT. Here hθxi represents the estimated closing time based on the derived model and yi is the actual closing time.


### 3.2. Density Estimation

The kernel density estimation method is applied to reconstruct an estimate of the time spent at the railway level crossing per train trip. The reason is that kernel density estimation can converge to the true density faster whilst guaranteeing a smooth output in comparison to its counterparts [23, 24]. Thus, the kernel is a smooth function K which determines the shape of the estimator [21, 25, 26]. In addition, the kernel function partitions dataset of railway level crossing closing time into several bins and estimates the density from the bin count [25, 26]. The Gaussian kernel is chosen for this application and the performance of its estimator p^x is assessed using risk R and the mean squared error (MSE), expressed in equations (5) and (8), respectively.(5)R=biasp^x2+varp^x,(6)biasp^x=12δk2h2p′t+Oh4,(7)varp^x=1nhptδ2+O1n,(8)MSEp^x=On−4/5,where p^x=1/n∑j=1n1/hKx−Xj/h is the kernel density estimator, x=x1,x2,x3T, δk2=∫t2Ktdt , δ2=∫K2tdt, and h is the smoothing bandwidth which depends on sampling size n. In addition, it is assumed that the true density function pt is continuous at t and that h⟶0 and nh⟶∞. On that note, the estimator p^t is assumed to convergence in probability to the true density function pt, i.e., p^t⟶Ppt. The notation var is used for variance.Similarly, the Gaussian kernel density estimateg^x of the expected railway level crossing closing time per each train trip is to be populated. The expected closing time is the designed for case, based on the ideal railway level crossing technical parameters and train traction characteristics. Hence, g^x is populated in accordance with the parameters of the technical and train traction constraints defined in Tables 1 and 2, respectively. Furthermore, threshold closing time is the maximal permissible railway level crossing closing time which takes into account the prevailing constraints. This varies for each railway level crossing. As already mentioned, the recovery of the time lost per passage can improve the railway level crossing safety and capacity. Therefore, time lost by trains at the railway level crossing is represented by the surface area bounded by the threshold railway level crossing’s closing time, density function g^x, and density estimator p^x.Table 1
Technical constraints.
ParameterAbbreviationValueDwell timetd10%Speed restrictionvlx30–35 km/hTime delayti2s–4sLine speedvL75 km/hTable 2
Constraints in each train driving mode.
Driving mode∑FvBrakingFtv−Rv,r,β−Fbv≤0v≤vlxCoastingFtv−Rv,r,β−Fbv=0v≤vlxAccelerationFtv−Rv,r,β−Fbv≥0vlx≤v≤vL


### 3.3. Optimisation Method

Optimisation of the railway level crossing closing time is critical in improving safety and traffic capacity. Thus, optimal closing time is achieved by minimising the time spent by trains on activation, inner area, and deactivation of the railway level crossing. The time spent at the railway level crossings is constrained by the technical parameters listed in Table1. Dwell time relates to the train’s scheduled stop. Hence, the effect due to dwell time is restricted to 10% of anticipated train stop time at the platform. Furthermore, the line speed and railway level crossing speed restriction are applied in accordance with specifications of the southern corridor of the Western Cape metro rail. Lastly, time delay on the protecting signal is limited to an average reaction rate of the driver of 2 s to 4 s.Additionally, performance constraints are determined by the tractive characteristics on the presiding compartment of the railway level crossing closing time. Thus, resultant force and associated train speed restriction per driving mode are stated in Table2.As mentioned above, the time lost at the railway level crossing is represented by the surface area bounded by the threshold railway level crossing’s closing time, density function, and density estimatorg^x. Then, optimisation of the railway level crossing closing time reduces the denoted minimum surface area. In this case, the time lost at the railway level crossing is obtained by computing numerical or analytical integration, as shown in the following equation:(9)I=∫ab∫cd∫efg^x−p^xdx3dx2dx1,where the integral is evaluated over the 3D bounded region defined by the kernel density estimators g^x and p^x. The points of interest of the region on which the integral is evaluated are denoted by a, b on the ith plane, c, d on the jth plane, and e, f on the kth plane.Letfx=g^x−p^x which can be further composed into fx1,x2,x3; then numerical integration can be approximated to equation (10) by applying the generalized Gaussian quadrature to evaluate the nodes and weights for the product of the polynomial and logarithmic functions [27]. The generalized Gaussian quadrature formula has been proven to give better results for integration over three-dimensional regions particularly in common applications in science and engineering [27].(10)I=∫ab∫cd∫effx1,x2,x3dx3dx2dx1≈∑l=1L3clfx1l,x2l,x3l,where cl=w1iw2jw3kb−ad−cf−e; x1l=b−aξi+a; x2l=d−cηj+c; x2l=f−eζk+e. The term L is the number of selected point set over which the integration is to be evaluated.Here,ξi,ηj, and ζk are the node points, and w1i, w2j, and w3k are the corresponding weights in one dimension. Several assumptions are postulated; features such as dwell time, train entry speed, and time delay on the protecting signal are nonnegative. Furthermore, the constrained set is nonempty and the objective function fx1,x2,x3 is finite. Thus, numerical optimisation can be formulated as follows:(11)minxj∈R+∑l=1L2clfx1l,x2l,x3lforj=1,2,3subject toargminhθ1x1≤td,argmaxhθ2x2≤vlx,argminhθ3x3≤ti,Ftx2−Rx2,r,β−Fbx2≤0.Powell’s optimisation method is applied to minimise the time lost at the railway level crossing per train trip. The Powell method is a single-shot and fast converging method which attempts to find the local fit-statistics minimum nearest to the starting point [28]. The advantage of using the Powell method is its robust direction set. Hence, it will move in one direction until it finds the minimum [28, 29]. Furthermore, it is a gradient-free minimisation algorithm and therefore it does not require the objective function to be smooth [29–31]. In this application there are 3 design variables x1, x2, and x3; thus the Powell algorithm can converge faster than numerical optimisation algorithms. In addition, it has been proven effective for problems with less than 10 design variables [28]. Although the algorithm can find multiple local optima there is no guarantee that it will find the global optimum [29]. Nonetheless, it can produce better results for this application.The new unconstrained optimisation algorithm (NEWUOA) software of the Powell method is implemented in Matlab due to its efficacy in minimising a noisy objective function [30]. NEWUOA uses a truncated conjugated gradient algorithm to find the minimum mk within the trust region [32]. The efficiency of the algorithm is derived from the intermingled trust region iteration and model iteration. Thus, objective of the trust region step is to find the better objective function value whilst the model iteration improves the model [32]. Assume a starting point xs for each design variable with the objective function fxs and initial interpolation set Y containing xs. The initialisation stage assigns k⟵0, Δk and xk⟵argminfyi,yi∈Y. The initial point of the NEWUOA xk is chosen as a point with lowest objective function value. The result of optimisation is that the step sk is added to xk to give the new point; xk+⟵xk+sk. The length of sk can either become the trust region iteration or model iteration. Thus, if the length of sk is the too short, it indicates that the model must be improved; therefore it is referred to as model iteration. Otherwise, the length of sk becomes the trust region iteration.In the trust region step, wherefxk+<fxk, the objective function value is replaced by the new point xk+, whereas in the model iteration, a point xk+ will not be added to the model. Instead, a new point will be calculated and will replace the point furthest from xopt. Moreover, new point is chosen in such a way that it improves minimisation mk. The algorithm uses several parameters such as the trust region radius Δk, which is related to initial current radius ρbeg, lower limit of the radius ρend, and upper limit of the radius ρk. The normal trust region radius Δk is used to limit the step length. In addition, ρbeg is used to keep enough distance between the interpolation points >2n+1+n2,n=3 in the initial model so that it is still accurate in case of presence of errors in the evaluation of f. The following parameters were used for the NEWUOA model.


## 3.1. Data Analysis

Regression techniques are used to derive the model of the attributes with the highest influence on the railway level crossing closing time. Hence, regression model of railway level crossing closing timey and feature vector x of n=3 features and m=8000 training sets were built in Matlab. Moreover, the model was tested using 2000 data sets. The feature vector represents dwell time, train entry speed, and time delay on the protecting signals denoted by x1,x2, and x3, respectively. Dwell time exhibits a linear pattern whereas others exhibit nonlinear patterns, as shown in Figures 3, 4, and 5. Thus, feature transformation was applied to the nonlinear features.Figure 3
The best fit of the dwell time against railway level crossing closing time.Figure 4
The best fit for the train’s entry speed against railway level crossing closing time.Figure 5
The best fit for time delay against the railway level crossing closing time.The hypothesishθx of the regression model is given in (2) with q1x,θ and q2x,θ being the parameterised nonlinear function for train entry speed and time delay on the protecting signal, respectively. The quadratic and exponential feature transformation functions were selected for the train entry speed and time delay. The feature transformation has been introduced to allow for application of the gradient descent and least squares. Thus, expressions of the feature transformation function are shown in (3) and (4). Gradient descent is applied to tune the parameters of the model by minimising the regression cost function over θ as given in (5). In addition, Jacobian leverage is applied in estimating the parameters of the nonlinear feature transformation function.(3)hθx=∑i=13hθixiwhere θ1=θ0,θ1T, θ2=θ2,θ3,θ6T, and θ3=θ4,θ5,θ7T; hθ1x1=θ0+θ1x1, hθ2x2=θ2+θ3q1x2,θ6, hθ3x3=θ4+θ5q2x3,θ7.(4)q1x2,θ6=maxx2+1−x21001+θ6x22,q2x3,θ7=expθ7x3,minθJθ=minθ12m∑i=1mhθxi−yi2.θ=θ1,θ2,θ3T;xi=x1i,x2i,x3iT. Here hθxi represents the estimated closing time based on the derived model and yi is the actual closing time.


## 3.2. Density Estimation

The kernel density estimation method is applied to reconstruct an estimate of the time spent at the railway level crossing per train trip. The reason is that kernel density estimation can converge to the true density faster whilst guaranteeing a smooth output in comparison to its counterparts [23, 24]. Thus, the kernel is a smooth function K which determines the shape of the estimator [21, 25, 26]. In addition, the kernel function partitions dataset of railway level crossing closing time into several bins and estimates the density from the bin count [25, 26]. The Gaussian kernel is chosen for this application and the performance of its estimator p^x is assessed using risk R and the mean squared error (MSE), expressed in equations (5) and (8), respectively.(5)R=biasp^x2+varp^x,(6)biasp^x=12δk2h2p′t+Oh4,(7)varp^x=1nhptδ2+O1n,(8)MSEp^x=On−4/5,where p^x=1/n∑j=1n1/hKx−Xj/h is the kernel density estimator, x=x1,x2,x3T, δk2=∫t2Ktdt , δ2=∫K2tdt, and h is the smoothing bandwidth which depends on sampling size n. In addition, it is assumed that the true density function pt is continuous at t and that h⟶0 and nh⟶∞. On that note, the estimator p^t is assumed to convergence in probability to the true density function pt, i.e., p^t⟶Ppt. The notation var is used for variance.Similarly, the Gaussian kernel density estimateg^x of the expected railway level crossing closing time per each train trip is to be populated. The expected closing time is the designed for case, based on the ideal railway level crossing technical parameters and train traction characteristics. Hence, g^x is populated in accordance with the parameters of the technical and train traction constraints defined in Tables 1 and 2, respectively. Furthermore, threshold closing time is the maximal permissible railway level crossing closing time which takes into account the prevailing constraints. This varies for each railway level crossing. As already mentioned, the recovery of the time lost per passage can improve the railway level crossing safety and capacity. Therefore, time lost by trains at the railway level crossing is represented by the surface area bounded by the threshold railway level crossing’s closing time, density function g^x, and density estimator p^x.Table 1
Technical constraints.
ParameterAbbreviationValueDwell timetd10%Speed restrictionvlx30–35 km/hTime delayti2s–4sLine speedvL75 km/hTable 2
Constraints in each train driving mode.
Driving mode∑FvBrakingFtv−Rv,r,β−Fbv≤0v≤vlxCoastingFtv−Rv,r,β−Fbv=0v≤vlxAccelerationFtv−Rv,r,β−Fbv≥0vlx≤v≤vL


## 3.3. Optimisation Method

Optimisation of the railway level crossing closing time is critical in improving safety and traffic capacity. Thus, optimal closing time is achieved by minimising the time spent by trains on activation, inner area, and deactivation of the railway level crossing. The time spent at the railway level crossings is constrained by the technical parameters listed in Table1. Dwell time relates to the train’s scheduled stop. Hence, the effect due to dwell time is restricted to 10% of anticipated train stop time at the platform. Furthermore, the line speed and railway level crossing speed restriction are applied in accordance with specifications of the southern corridor of the Western Cape metro rail. Lastly, time delay on the protecting signal is limited to an average reaction rate of the driver of 2 s to 4 s.Additionally, performance constraints are determined by the tractive characteristics on the presiding compartment of the railway level crossing closing time. Thus, resultant force and associated train speed restriction per driving mode are stated in Table2.As mentioned above, the time lost at the railway level crossing is represented by the surface area bounded by the threshold railway level crossing’s closing time, density function, and density estimatorg^x. Then, optimisation of the railway level crossing closing time reduces the denoted minimum surface area. In this case, the time lost at the railway level crossing is obtained by computing numerical or analytical integration, as shown in the following equation:(9)I=∫ab∫cd∫efg^x−p^xdx3dx2dx1,where the integral is evaluated over the 3D bounded region defined by the kernel density estimators g^x and p^x. The points of interest of the region on which the integral is evaluated are denoted by a, b on the ith plane, c, d on the jth plane, and e, f on the kth plane.Letfx=g^x−p^x which can be further composed into fx1,x2,x3; then numerical integration can be approximated to equation (10) by applying the generalized Gaussian quadrature to evaluate the nodes and weights for the product of the polynomial and logarithmic functions [27]. The generalized Gaussian quadrature formula has been proven to give better results for integration over three-dimensional regions particularly in common applications in science and engineering [27].(10)I=∫ab∫cd∫effx1,x2,x3dx3dx2dx1≈∑l=1L3clfx1l,x2l,x3l,where cl=w1iw2jw3kb−ad−cf−e; x1l=b−aξi+a; x2l=d−cηj+c; x2l=f−eζk+e. The term L is the number of selected point set over which the integration is to be evaluated.Here,ξi,ηj, and ζk are the node points, and w1i, w2j, and w3k are the corresponding weights in one dimension. Several assumptions are postulated; features such as dwell time, train entry speed, and time delay on the protecting signal are nonnegative. Furthermore, the constrained set is nonempty and the objective function fx1,x2,x3 is finite. Thus, numerical optimisation can be formulated as follows:(11)minxj∈R+∑l=1L2clfx1l,x2l,x3lforj=1,2,3subject toargminhθ1x1≤td,argmaxhθ2x2≤vlx,argminhθ3x3≤ti,Ftx2−Rx2,r,β−Fbx2≤0.Powell’s optimisation method is applied to minimise the time lost at the railway level crossing per train trip. The Powell method is a single-shot and fast converging method which attempts to find the local fit-statistics minimum nearest to the starting point [28]. The advantage of using the Powell method is its robust direction set. Hence, it will move in one direction until it finds the minimum [28, 29]. Furthermore, it is a gradient-free minimisation algorithm and therefore it does not require the objective function to be smooth [29–31]. In this application there are 3 design variables x1, x2, and x3; thus the Powell algorithm can converge faster than numerical optimisation algorithms. In addition, it has been proven effective for problems with less than 10 design variables [28]. Although the algorithm can find multiple local optima there is no guarantee that it will find the global optimum [29]. Nonetheless, it can produce better results for this application.The new unconstrained optimisation algorithm (NEWUOA) software of the Powell method is implemented in Matlab due to its efficacy in minimising a noisy objective function [30]. NEWUOA uses a truncated conjugated gradient algorithm to find the minimum mk within the trust region [32]. The efficiency of the algorithm is derived from the intermingled trust region iteration and model iteration. Thus, objective of the trust region step is to find the better objective function value whilst the model iteration improves the model [32]. Assume a starting point xs for each design variable with the objective function fxs and initial interpolation set Y containing xs. The initialisation stage assigns k⟵0, Δk and xk⟵argminfyi,yi∈Y. The initial point of the NEWUOA xk is chosen as a point with lowest objective function value. The result of optimisation is that the step sk is added to xk to give the new point; xk+⟵xk+sk. The length of sk can either become the trust region iteration or model iteration. Thus, if the length of sk is the too short, it indicates that the model must be improved; therefore it is referred to as model iteration. Otherwise, the length of sk becomes the trust region iteration.In the trust region step, wherefxk+<fxk, the objective function value is replaced by the new point xk+, whereas in the model iteration, a point xk+ will not be added to the model. Instead, a new point will be calculated and will replace the point furthest from xopt. Moreover, new point is chosen in such a way that it improves minimisation mk. The algorithm uses several parameters such as the trust region radius Δk, which is related to initial current radius ρbeg, lower limit of the radius ρend, and upper limit of the radius ρk. The normal trust region radius Δk is used to limit the step length. In addition, ρbeg is used to keep enough distance between the interpolation points >2n+1+n2,n=3 in the initial model so that it is still accurate in case of presence of errors in the evaluation of f. The following parameters were used for the NEWUOA model.


## 4. Results

The results of the study are presented as follows. Section4.1 entails the results of the data analysis followed by the kernel density estimation and optimisation results in Sections 4.2 and 4.3, respectively. Validation of the proposed method is presented in Section 4.4. Throughout, the study training dataset of 8000 samples and test dataset of 2000 samples have been used.


### 4.1. Data Analysis

The gradient descent algorithm has been applied to estimate the parameters of the model listed in Tables3 and 4. Similarly, the learning curve shown in Figure 6 indicates that the regression algorithm converges to the local or global minima. The deviation in the training and test cost functions after convergence is not vast; thus there is no indication of overfitting or underfitting. However, the learning curve does not give an indication of the impact of the residuals. Hence, error analysis in Table 5 indicates that outliers, due to feature transformation, have been heavily penalised. Yet, the model achieves accuracy of 78.2 % which is relatively good given the data.Table 3
NEWUOA parameters.
DescriptionTermValueInitial radiusρbeg0.01Lower limit of the radiusρend0.01Upper limit of the radiusρk0.3Trust region radiusΔ0.05Table 4
Parameters of the trained regression model.
θ0θ1θ2θ3θ4θ5θ6θ7Model0.051.2711.280.70118.069.934−1.23−0.15Figure 6
Learning curve for the regression model.Table 5
Error analysis.
IterationsErrorAccuracyTrain errorTest error500105.23100.770.5820100091.0890.1820.6530300078.9769.610.714400078.3468.970.734500078.0568.390.782


### 4.2. Kernel Density Estimation

The bias-variance kernel density estimator trade-off is used to determine the amount of smoothing required. The optimal amount of smoothing minimises the risk and consequently reduces the mean square error. The smoothing bandwidth is chosen to be a multiple of the sampling rate. The iterations of smoothing bandwidths are run to determine the bandwidth that minimises the risk and mean square error by visually observing the estimator output. The summary of results is shown in Table6. It can be observed that the appropriate smoothing bandwidth for this application is 0.08 since the spurious effect of the data is not masked. Furthermore, density estimators of the features with significant impact on the railway level crossing time per train trip are shown in Figure 7. The culmination of the estimators would result in the 3D output; however for this analysis they are separated. The contribution of the dwell time is less significant on the first lobe in comparison to the entry velocity and time delay.Table 6
Performance analysis of kernel density estimates.
Smoothing bandwidthObservation0.001Undersmoothed0.008Undersmoothed0.01Undersmoothed0.08Just right0.1Oversmoothed0.8Oversmoothed1OversmoothedFigure 7
Gaussian kernel density estimator of the features with highest impact on the railway level crossing closing time.


### 4.3. NEWUOA Method

The NEWUOA software which is a Powell new unconstrained optimisation algorithm was used to minimise the area of a region between the density estimates of the features with highest influence on the railway level crossing time. The NEWUOA algorithm developed by Powell is run on Fortran and is interfaced to Matlab [29, 30]. The sensitivity analysis of the algorithm is shown in Table 7. Herein, the time consumption and number of iterations required for convergence at chosen initial points x1,y,x2,y,x3,y are also presented.Table 7
Sensitivity analysis of the Powell optimisation using NEWUOA software.
Initial conditionTime (s)Iterations(0,30),(8.5,30),(2,30)13.43010000(15,40),(7.1,40),(4,40)8.0057060(30,50),(5,50),(10,50)6.2335002(35,60),(9,60),(14,60)2.5111890(35,70),(4,70),(12,70)2.0841055(30,80),(4.2,80),(10,80)1.5521010(40,90),(5.2,90),(14,90)2.1261580(35,100),(6,100),(10,100)2.9052806(45,120),(4.3,120),(10,120)3.0573500The sensitivity analysis of the optimisation solution indicates that the a priori information can significantly reduce the computation time and the number of iterations required. Moreover, choosing the initial point in between the far extremes reduces the computation time and number of iterations. The minimum required number of iterations2n+1+n2 has been kept, to increase chances of obtaining the global optima.


### 4.4. Validation

The efficacy of the solution is validated on the dataset of 2000 samples from the eight railway level crossings under study. The actual and optimal time lost at the railway level crossings are shown in Table8. Thus, results indicate that the optimisation algorithm can achieve, at most, 40% reduction of the time lost at the railway level crossing. However, the effectiveness of the optimisation algorithm is not the same for each railway level crossing.Table 8
Validation of the recovered time lost at the railway level crossing.
Level crossingLineActualOptimalAlbertyn rd10.31670.12192Albertyn rd20.36780.14381Austell rd10.41560.16694Austell rd20.31670.12669Beach rd-0.40010.15163Kalkbay rd10.42240.14872Kalkbay rd20.57740.20951Military rd10.63670.23717Military rd20.57860.21839Uxbridge rd10.28520.11460Uxbridge rd20.61310.24483White rd10.53640.20917White rd20.61230.24495York rd10.40350.16183York rd20.40440.16092


## 4.1. Data Analysis

The gradient descent algorithm has been applied to estimate the parameters of the model listed in Tables3 and 4. Similarly, the learning curve shown in Figure 6 indicates that the regression algorithm converges to the local or global minima. The deviation in the training and test cost functions after convergence is not vast; thus there is no indication of overfitting or underfitting. However, the learning curve does not give an indication of the impact of the residuals. Hence, error analysis in Table 5 indicates that outliers, due to feature transformation, have been heavily penalised. Yet, the model achieves accuracy of 78.2 % which is relatively good given the data.Table 3
NEWUOA parameters.
DescriptionTermValueInitial radiusρbeg0.01Lower limit of the radiusρend0.01Upper limit of the radiusρk0.3Trust region radiusΔ0.05Table 4
Parameters of the trained regression model.
θ0θ1θ2θ3θ4θ5θ6θ7Model0.051.2711.280.70118.069.934−1.23−0.15Figure 6
Learning curve for the regression model.Table 5
Error analysis.
IterationsErrorAccuracyTrain errorTest error500105.23100.770.5820100091.0890.1820.6530300078.9769.610.714400078.3468.970.734500078.0568.390.782


## 4.2. Kernel Density Estimation

The bias-variance kernel density estimator trade-off is used to determine the amount of smoothing required. The optimal amount of smoothing minimises the risk and consequently reduces the mean square error. The smoothing bandwidth is chosen to be a multiple of the sampling rate. The iterations of smoothing bandwidths are run to determine the bandwidth that minimises the risk and mean square error by visually observing the estimator output. The summary of results is shown in Table6. It can be observed that the appropriate smoothing bandwidth for this application is 0.08 since the spurious effect of the data is not masked. Furthermore, density estimators of the features with significant impact on the railway level crossing time per train trip are shown in Figure 7. The culmination of the estimators would result in the 3D output; however for this analysis they are separated. The contribution of the dwell time is less significant on the first lobe in comparison to the entry velocity and time delay.Table 6
Performance analysis of kernel density estimates.
Smoothing bandwidthObservation0.001Undersmoothed0.008Undersmoothed0.01Undersmoothed0.08Just right0.1Oversmoothed0.8Oversmoothed1OversmoothedFigure 7
Gaussian kernel density estimator of the features with highest impact on the railway level crossing closing time.


## 4.3. NEWUOA Method

The NEWUOA software which is a Powell new unconstrained optimisation algorithm was used to minimise the area of a region between the density estimates of the features with highest influence on the railway level crossing time. The NEWUOA algorithm developed by Powell is run on Fortran and is interfaced to Matlab [29, 30]. The sensitivity analysis of the algorithm is shown in Table 7. Herein, the time consumption and number of iterations required for convergence at chosen initial points x1,y,x2,y,x3,y are also presented.Table 7
Sensitivity analysis of the Powell optimisation using NEWUOA software.
Initial conditionTime (s)Iterations(0,30),(8.5,30),(2,30)13.43010000(15,40),(7.1,40),(4,40)8.0057060(30,50),(5,50),(10,50)6.2335002(35,60),(9,60),(14,60)2.5111890(35,70),(4,70),(12,70)2.0841055(30,80),(4.2,80),(10,80)1.5521010(40,90),(5.2,90),(14,90)2.1261580(35,100),(6,100),(10,100)2.9052806(45,120),(4.3,120),(10,120)3.0573500The sensitivity analysis of the optimisation solution indicates that the a priori information can significantly reduce the computation time and the number of iterations required. Moreover, choosing the initial point in between the far extremes reduces the computation time and number of iterations. The minimum required number of iterations2n+1+n2 has been kept, to increase chances of obtaining the global optima.


## 4.4. Validation

The efficacy of the solution is validated on the dataset of 2000 samples from the eight railway level crossings under study. The actual and optimal time lost at the railway level crossings are shown in Table8. Thus, results indicate that the optimisation algorithm can achieve, at most, 40% reduction of the time lost at the railway level crossing. However, the effectiveness of the optimisation algorithm is not the same for each railway level crossing.Table 8
Validation of the recovered time lost at the railway level crossing.
Level crossingLineActualOptimalAlbertyn rd10.31670.12192Albertyn rd20.36780.14381Austell rd10.41560.16694Austell rd20.31670.12669Beach rd-0.40010.15163Kalkbay rd10.42240.14872Kalkbay rd20.57740.20951Military rd10.63670.23717Military rd20.57860.21839Uxbridge rd10.28520.11460Uxbridge rd20.61310.24483White rd10.53640.20917White rd20.61230.24495York rd10.40350.16183York rd20.40440.16092


## 5. Discussion

In this study, it has shown that long closing time at the railway level crossings is attributed to three features. The features identified to have highest impact are dwell time, time delay on the protection signals, and train entry speed. The regression model confirmed the relationship of these features and the railway level crossing closing time. The model has shown that dwell time is directly proportional to the railway level crossing closing time. Since it is inevitable to remove the platform at activation of some railway level crossings, the algorithm imposed a delay on the triggering of the protection system, such that the impact is well mitigated. Similarly, train entry speed plays a significant role in the railway level crossing system. The model indicated that the railway level crossing closing time decreases with an increase in train speed following a hyperbolic trend. Train travelling over the railway level crossing at speed lower than the permissible speed results in longer closing time. Lastly, time delay imposed on the protecting signal tends to introduce a delayed train driver response and consequently increases the closing time.The model has shown that the railway level crossing closing time increases with time delay on the protecting signal in an exponential manner particularly where automatic routing is applied. The presented railway level crossing optimisation incorporated regression models of the identified attributes. In addition, the optimisation algorithm makes use of the density functions of the features to define the time lost at the railway level crossing per train trip. The threshold closing time, as well as the actual and expected closing time density function, defines the lower and upper boundaries of the Powell algorithm. Thus, recovery of the time lost at the railway level crossing is posed as the minimisation of the area bounded by the threshold railway level crossing closing time, actual, and expected density functions.The optimisation of the railway level crossing closing time is subjected to train speed (at least minimal permissible speed), dwell time (at most 10% of the anticipate dwell time value), and time delay of at least the average driver reaction time. Furthermore, train traction characteristics constrained the objective function. The developed optimisation algorithm was trained on 8000 data samples. The algorithm exhibited high performance for the number of training datasets. However, performance can still be improved by increasing the number of training datasets, as well as introducing additional attributes. Validation of the algorithm proved that the features identified have a significant impact on long level crossing closing time. Moreover, the optimisation algorithm achieved at least 50% decrease in the time lost at the railway level crossings on 2000 test datasets.Overall, the algorithm has proven to improve safety and capacity at the railway level crossings by reducing the time lost per train trip. Hence, optimal railway level crossing closing time is feasible if the technical and train tractive constraints are adhered to. However, the inconsistency of the optimiser on respective railway level crossings suggests that there may be unique features other than those considered. Therefore, increasing the number of features may improve the generality of the algorithm. In addition, the solution does not take into account mechanical failures of the train at the railway level crossing.


## 6. Conclusion

The present study developed an optimisation method to reduce the time lost at the railway level crossing per train trip. As a result, optimal railway level crossing closing time can be achieved. The algorithm used minimisation of the area bounded by the threshold closing time, as well as the actual and expected density function of the railway level crossing closing time per train trip, as the criterion. Powell’s optimisation algorithm was trained on 8000 datasets and has shown to converge to the optimal solution. Furthermore, the algorithm was validated. The reduction in the time lost at the rail-road level crossing is at least 50% on 2000 test datasets. The proposed solution is critical in ensuring improved safety and capacity at the railway level crossings. However, the algorithm is still selective in the optimisation of some of the railway level crossing closing times, thus suggesting that improvement can be made to achieve consistent results.



---

*Source: 6614242-2022-02-25.xml*