1 Introduction

The train timetabling is one of the most challenging and difficult problems in railway transportation planning. The train timetable qualification greatly impacts the service quality and operating cost. The goal of train timetabling models is to determine train arrival and departure times to and from each station with the minimum total delay time while satisfying a set of operational constraints.

Preliminary review on analytical railway optimization models was undertaken by Assad [1]. Similarly, Caprara et al. [2] reported an excellent state-of-the-art review of railway optimization problems. Finding the optimum train timetable while satisfying all constraints increases the complexity of this problem. Therefore, train timetabling problem belongs to the class of computationally difficult NP-hard problems. This implies that it is not expected to find exact algorithm for solving any instance to optimality in polynomial time [3, 4].Therefore, meta-heuristic algorithms have been used to determine optimum solution. Optimization of train timetabling problem has been investigated in different studies [58].

Several attempts have been made to use complex search procedures including look-ahead search [9], backtracking search and meta-heuristics algorithms [10, 11], mixed-integer linear programming, branch and bound, tabu search (TS) [12], an enhanced local search heuristic (LSH), GA, TS, and two hybrid algorithms [13] and GA[1417]. However, these studies have not optimized train traffic flow considering stops for track maintenance and praying.

A number of studies have examined CA methodology to simulate train traffic flow [1831]. However, these studies have not considered stops for track maintenance and praying. Also they have only focused on simulation and not dealt with optimization of train traffic flow.

To the best our knowledge, Ref. [32] is the only refereed publication dealing with train timetabling problem with considering train stops for praying using an integrated simulation model and evolutionary algorithm. However, the authors applied enterprise dynamics simulation with evolutionary path re-linking algorithm to solve the train scheduling problem and only focused on stops for praying and did not consider other operational constraints. The authors suggested further investigations using different simulation models and optimizations algorithms.

In summary, the research to date did not provide adequate scientific evidence to optimize train timetabling problem considering realistic constraints including stops for track maintenance and praying. In the absence of such evidence, current practice has been guided to optimize passenger train timetabling problem on a single-line railway using GA and DDS and evaluate the fitness of each chromosome using CA model under operational constraints.

The remainder of the paper was as follows. In Sects. 2 and 3, the proposed methods and the optimization results are presented and compared. Finally, Sect. 4 states the conclusion and the future works.

2 Proposed methodology

The proposed methods integrate a CA simulation and optimization algorithm to generate near optimal train timetable. The GA and DSS methods have been used to optimize the train timetable problem. The fitness (i.e., total delay of the trains) of each solution has been evaluated by a simulation of train traffic flow known to be CA method. Figure 1 shows the architecture of the proposed methods.

Fig. 1
figure 1

The architecture of the proposed method

This paper integrates a CA simulation and optimization algorithm to generate near optimal train timetable. The assumptions underlying this study included the following statements. (1) The trains move on single line track. (2) Similar train type moves on with the same speed limits. (3) A train service begins from the first station and ends at the last station. (4) The minimum instantaneous distance between two successive trains is constant. (5) The train speed limit at stations is constant. (6) The distance that a train can move after decelerating at a station is constant. (7) The time and position of blocked segments due to maintenance are fixed. (8) The praying times at each station have been given.

The route characteristics (e.g., track and structure), rolling stock attributes (e.g., train), maintenance/inspection schedule, and praying time windows are given as follows:

  • The infrastructure characteristics:

    • The position of stations

    • The minimum stop time at stations

    • The maximum train speed at stations

  • The train characteristics:

    • The initial departure interval with tolerance

    • Safety rules

    • The maximum speed limitation

    • The minimum instantaneous distance between two successive trains

    • The distance that a train can move after decelerating at a station

  • The maintenance schedule characteristics:

    • Track maintenance periods (section unavailability times)

    • The sections/segments that were blocked due maintenance operations

  • The praying time characteristics:

    • The praying times of each station

    • The required time for praying at each station

2.1 Optimization model

In the train timetabling problem, the optimization objective is minimization of total delay time which includes the predefined time the train must stop in the stations, the time to stop the trains due to maintenance operations, and the time to stop the trains due to pray (Eqs. 17).

$${\text{Minimize DelayTime}} = \sum\limits_{i = 1}^{{n_{\text{train}} }} {\left( {{\text{DelayTime}}_{\text{Predefined DwellTime}}^{i} + \, {\text{DelayTime}}_{\text{Maintenance}}^{i} + {\text{DelayTime}}_{\text{Praying}}^{i} } \right)} ,$$
(1)
$${\text{DelayTime}}_{{{\text{Predefined}}{\text{Dwell}}{\text{Time}}}}^{i} = \sum\limits_{j = 1}^{{n_{\text{station}} }} {(X_{\text{Predefined DwellTime}}^{ij} \times 2\,\hbox{min} )} ,$$
(2)
$$X_{{{\text{Predefined Dwell}}\,{\text{Time}}}}^{ij} = \left\{ {\begin{array}{*{20}l} {1,} \quad {{\text{if }}i{\text{th train travels on }}j{\text{th station}}} \\ {0,} \quad {\text{otherwise}} \\ \end{array} } \right.,$$
(3)
$${\text{DelayTime}}_{\text{Maintenance}}^{i} = \sum\nolimits_{k = 1}^{{n_{\text{Maintenance}} }} {(Y_{\text{Maintenance}}^{ik} \times t_{\text{Maintenance}}^{ik} )} ,$$
(4)
$$Y_{\text{Maintenance}}^{ik} = \left\{ {\begin{array}{*{20}l} {1,}\quad {{\text{if }}i{\text{th train stops for }}k{\text{th maintainance}}} \\ {0,} \quad {\text{otherwise}} \\ \end{array} ,} \right.$$
(5)
$${\text{DelayTime}}_{\text{Praying}}^{i} = \sum\limits_{l = 1}^{3} {\left( {Z_{\text{Praying}}^{il} \times 20\,\hbox{min} } \right)} ,$$
(6)
$$\begin{aligned} \hfill \\ Z_{\text{Praying}}^{ik} = \left\{ {\begin{array}{*{20}l} {1,} \quad {{\text{if }}i{\text{th train stops for }}l{\text{th maintainance}}} \\ {0,} \quad {\text{otherwise}} \\ \end{array} } \right., \hfill \\ \end{aligned}$$
(7)

where \({\text{DelayTime}}\) is the total delay time, \({\text{DelayTime}}_{{{\text{Predefined }}\,{\text{DwellTime}}}}^{i}\) is the predefined time the ith train must stop in the stations, \({\text{DelayTime}}_{\text{Maintenance}}^{i}\) is the time the ith train stop due to maintenance operations, and \({\text{DelayTime}}_{\text{Praying}}^{i}\) is the time the ith train stop due to pray. \(X_{{{\text{Predefined}}\,{\text{DwellTime}}}}^{ij}\), \(Y_{\text{Maintenance}}^{ik}\), and \(Z_{\text{Praying}}^{il}\) are binary indicator variables. \(t_{\text{Maintenance}}^{ik}\) is the required time that ith train stops to carry out the kth maintenance operation. This paper has used GA and DSS to optimize the train timetable problem.

2.1.1 Genetic algorithm

As train timetabling problem is known to be NP-hard [5, 7, 15, 33], a meta-heuristic algorithms have been applied to solve it. It has been shown that GA has high potential in finding the global optimum in a large, poorly defined search space even in the presence of difficulties such as high dimensionality, multi-modality, discontinuity, and noise [15]. GA has been successfully applied to combinatorial problems and is able to handle huge search spaces as those arising in scheduling problems [33]. Therefore, in this paper, GA has been used to optimize train timetable.

GA implemented optimization strategies based on simulation of the natural evolution of a species. Through repetitive application of selection, crossover, and mutation, a population of candidate solutions is evolved to generate better solution. More details on the GA process can be found in [34]. In this paper, the genetic parameters are listed in Table 1.

Table 1 GA parameters

In this paper, the population size is 20. Each chromosome included 18 genes, which equals to the total number of trains. It consists of train departure times from origin station, during a 24 h period. Each train has a departure time interval which could be set by user. The default length of initial interval time is 2 h. It means that if the user set the assumed time of departure to 7, system can select any time between 5 and 9 for departure.

The first population was created randomly within maximum half an hour difference from the predefined timetable for each train. After generating the first population, evaluation of each chromosome was carried out using simulation. For calculating the fitness of each chromosome, a simulation model was used, and total delay of the trains was recorded as the value of fitness. Following the evaluation, the process of creating new generation is started.

In this paper, after calculating fitness of all chromosomes (i.e., total delay time), the first and second best timetables (elites) are copied over to the next GA generation. GA functions are designed on the basis of the rank selection method. GA sorts the chromosomes in ascending order (better chromosome placed first). Selection opportunity of each chromosome is increased by its rank through GA operations.

In each generation, with a probability of 0.9 (crossover rate = 0.9), a pair of parent chromosome was selected for breeding and two children chromosomes were produced using one-point crossover operator. This meant that a single crossover point on both parents’ chromosome was selected and all train departure time beyond that point in either parent was swapped between the two parents. Then, there were some chromosomes with some of their genes changed within maximum 1-h period by mutation. The mutation rate is set to 0.05. This process has been repeated until reaching a termination condition (predefined number of iteration). Experiments showed that around 400 generations had to be passed to achieve the result.

2.1.2 Dynamically dimensioned search algorithm

The train timetabling problem is an optimization problem. It has been shown that DSS has high potential in finding the global optimum without any algorithm parameter tuning in less iteration. DSS has been successfully applied to automatic calibration of watershed simulation models [3538]. Therefore, in this paper, DSS has been used to optimize train timetable.

The DDS algorithm is a simple, stochastic, single-solution-based, heuristic, global search algorithm that was developed for the purpose of finding a good globally optimal solution within a specified maximum number of function evaluation limit [3538]. The algorithm initially searches globally and becomes increasingly local when the number of iterations approaches the maximum number of iterations. The transition from global to local search involves dynamically and probabilistically reducing the number of dimensions in the neighborhood. Candidate solutions are created by perturbing the current solution values in the randomly selected dimensions only. The DDS algorithm pseudo code for minimization is as follows (Eqs. 8–17).

  • Step 1. Define DDS inputs:

    Neighborhood perturbation size parameter, r (0.2 is default)

    Maximum number of iterations, m

    Vector of lower, x min, and upper, x max, bounds for all decision variables (departure time of each train)

    Initial solution (predefined train timetable), x 1 = [x 1,…,x D]

  • Step 2. Set initial solution as the best solution and initialize i with 1:

    $$F^{\text{best}} = F\left( {x^{i} } \right),{\text{ and }}x^{\text{best}} = x^{i} .$$
    (8)
  • Step 3. Select a subset of decision variables for perturbation:

  • Step 4. Generate a candidate solution:

  • Step 5. Evaluate the candidate solution x new, and update current best solution if necessary:

  • Step 6. Check stopping criterion:

The only algorithm parameter to set in the DDS algorithm is the scalar neighborhood size perturbation parameter (r) that defines the random perturbation size standard deviation as a fraction of the decision variable range. In this paper, the value of the r parameter is set to 0.2.

2.2 Simulation model

In this paper, the fitness (total delay of the trains) evaluation of each chromosome is carried out using a simulation method. The simulation methods can be categorized as synchronous simulation and asynchronous simulation [15]. Synchronous simulation models processed the movements of all trains at the same time, but asynchronous modeled rank trains according to their priorities and inserted trains into simulation procedure sequentially based on the ranks. In this paper, the synchronous simulation approach was applied for the scheduling trains.

Train traffic flow models can be divided into two major categories: macroscopic and microscopic [39]. In macroscopic models, the aggregate behavior of traffic was described and the characteristics of traffic flow like average velocity, density, flow, and mean speed of a traffic stream were studied. A main limitation of macroscopic models was their aggregate nature [39]. A primary advantage of microscopic models was the ability to study individual train motion position and velocity of the trains.

The CA model is one of the most popular microscopic modeling approaches. CA has been used to study complicated non-linear systems such as train traffic flow. The CA method proposed by Cremer and Ludwing [40] can be used to study complicated non-linear systems such as traffic flow simulation in railway transportation. Preliminary work on CA application in transportation traffic flow was undertaken in Ref. [41]. NaSch model is a one-dimensional probabilistic cellular automata model which models traffic flow on a single-lane. Space, time, and the state of NaSch model are discrete. It is a minimal model that reproduces the basic features of real traffic. In comparison with other continuous models, it has very fast calculations. In NaSch model, the railway is divided into L cells (i = 1, 2,…,L), and the time is discrete. Each site can be either empty or occupied by a train with an integer speed v i  = 0, 1,…,v max, where v max is the maximum speed. According to four successive steps, all sites are simultaneously updated (Eqs. 1822):

  • Step 1. Acceleration

    $$v_{\text{i}} \left( {t + 1} \right) = { \hbox{min} }\left( {v_{\text{i}} \left( t \right) + 1, \, v_{ \hbox{max} } } \right).$$
    (18)
  • Step 2. Slowing down

    $$v_{i} \left( {t + 1} \right) = { \hbox{min} }\left( {v_{i} \left( t \right),{\text{ gap}}_{i} \left( t \right)} \right).$$
    (19)
    $${\text{gap}}_{i} \left( t \right) = {\text{x}}_{i + 1} \left( t \right) - {\text{x}}_{i} \left( t \right){-} 1 ,$$
    (20)

    where gap i (t) expresses the gap between ith train and (i + 1)th train at time t and x i (t) is the position where ith train is at time t.

  • Step 3. Randomization

    $$v_{i} \left( {t + 1} \right) = { \hbox{max} }\left( {v_{i} \left( t \right) - 1, \, 0} \right).$$
    (21)

    In this step, v i (t) is decreased by 1 with randomization probability q if v i (t) > 0.

  • Step 4. Movement

    $$x_{i} \left( {t + 1} \right) = x_{i} \left( t \right) + v_{i} \left( {t + 1} \right).$$
    (22)

CA has been used to study train traffic flow. In this method, the dynamic system was divided to discrete cells in space and time, each in one of a finite number of states (empty or occupied by a train). For each cell, a set of rules is defined as its neighborhood. In initial state, a state is assigned to each cell. Using the current state of the cell, the states of the cells in its neighborhood, and a transition rule, the new state of each cell was determined. Using very simple rules, this model can reproduce the basic phenomena encountered in real traffic. By modification of the simple rules, more complex situations (such as the multi-lane traffic, bidirectional traffic, and the traffic with different types of trains) can be described. In this paper, a CA method has been used to simulate train traffic flow and calculate the total delay time of a train timetable. In addition, according to the IRIR needs, two constraints (stops for track maintenance and praying) were considered. The proposed model simulated the complex railway traffic using some simple transition rules as follows:

2.2.1 Case 1

When the (n − 1)th train was in front of the nth train at the tth time step, to avoid the collision between two successive trains, the distance between these trains must be larger than or equal to the minimum instantaneous distance. The velocity of the nth train varied by comparing the headway distance (Δx n ) and the minimum instantaneous distance (d n ) to determine whether accelerating or decelerating (Eqs. 23–24).

  • Step 1: Acceleration

  • Step 2: Movement

    $$x_{n} = x_{n} + v_{n} .$$
    (24)

2.2.2 Case 2

When the nth train was near the station:

  • If the station has been occupied by the train that was in front of the nth train, the safety distance must be maintained between the nth train and its leading train. The update rules were as same as the update rules of the case 1.

  • If the station was empty, the nth train was allowed to travel into the station and stop at the station. Then it needed to wait for a time, and then left the station (Eqs. 2530).

    • Step 1: Acceleration

      $$\begin{aligned} &{\text{if d}}x_{n} > d_{b} , \, v_{n} = { \hbox{min} }\left( {v_{n} + a, \, v_{ \hbox{max} } } \right) \hfill \\& {\text{else if d}}x_{n} < d_{b} , \, v_{n} = { \hbox{max} }\left( {v_{n} - b, \, 0} \right) \hfill \\ &{\text{else }}v_{n} = v_{n} \hfill \\ & {\text{end}} \hfill \\ \end{aligned}$$
      (25)

      where dx n is the distance from the nth train to the station in front of the nth train, and d b is the distance that the train n can arrive at the station by decelerating.

    • Step 2: Slowing down

      $$v_{n} = { \hbox{min} }\left( {v_{n} , \, \Delta x_{n} } \right).$$
      (26)
    • Step 3: Movement

      $$x_{n} = x_{n} + v_{n} .$$
      (27)
    • Step 4: Acceleration

      If the actual dwell time of the nth train (t dwell) was more than the planned dwell time (T d )

      $$v_{n} = { \hbox{min} }\left( {v_{n} + a,v_{ \hbox{max} } } \right), \, t_{\text{dwell}} = 0.$$
      (28)

      If the actual dwell time of the nth train was less than the planned dwell time

      $$v_{n} = 0.$$
      (29)
    • Step 5: Movement

      $$x_{n} { = }x_{n} { + }v_{n} .$$
      (30)

2.2.3 Case 3

In order to improve the safety of the railway, inspection and routine maintenance of track and structures are necessary. Based on predefined schedules of maintenance works, the (starting and ending) locations that carried out the maintenance works, the starting maintenance time and its duration (3 h) were determined. It is required to block the line so the crew can get to the site.

2.2.4 Case 4

Based on religious obligations, during predefined time periods (local praying time window), train must stop to perform praying services. Therefore, after starting praying time, each train stopped 20 min in the first next station in praying time windows. Passengers got off the train and prayed in the station mosque. It should be considered that each station had a different local praying time windows (starting and ending praying times).

In the proposed CA method, the parameters included the minimum instantaneous distance (d n), the distance that the train can arrive at the station by decelerating (d b), the planned dwell time (T d), and predefined schedules of maintenance works. The IRIR data have been used to set them. The results of the proposed CA method were analyzed and compare with other methods in [31].

3 Case study

In this section, the proposed methodology is applied to a rail corridor that connects Tehran to Mashhad with 926 km of track and 50 stations while nine of them (Tehran, Varamin, Garmsar, Semnan, Damghan, Shahrood, Neghab, Neyshabur, and Mashhad) are considered as the main stations where train stops for getting on/off. The merits of a new simulation-based optimization model lies in its ability to achieve minimum total delay time with considering stops for routine track maintenance and praying. In this application, 10 trains traverse on a single-line rail corridor. It is assumed that the trains should dispatch within 2 h before or after their predetermined departure time. According to the predefined schedules of maintenance works, Garmsar–Semnan, Damghan–Shahrood, and Neyshabur–Mashhad section were blocked in 19–22, 13–16, and 4–7, respectively.

In the first proposed approach, an integration of a CA simulation and GA optimization algorithm was applied. The best objective value in different iterations for GA has been achieved after convergence for solving the problem. In this paper, four genetic algorithm parameters are investigated, namely, population size, number of best timetables that are copied over to the next generation, crossover rate, and mutation rate with rang values shown in Table 2. The range values of investigated genetic algorithms parameters are examined, and the best value of each parameter is determined based on their fitness values (Table 2).

Table 2 The range and the best value of investigated genetic algorithm parameters

Using the best value of the parameters, the fitness at each GA iteration is shown in Fig. 2. Considering departure time constraint, GA found best fitness value (447 min) in the 241 iteration and stayed in this value up to the 400th iteration, while the fitness value of the initial predefined schedules of train was 496 min. Therefore, the result revealed a potential for 9 % total delay time reduction over the currently used timetable. If there was no departure time constraint, the best fitness value is 383 min (in the 218 iteration) and total delay time reduced 23 % over the currently used timetable.

Fig. 2
figure 2

The fitness of two proposed methods at each iteration

In the second proposed approach, an integration of a CA simulation and DSS optimization algorithm was applied. The scalar neighborhood size perturbation parameter (r) is set to 0.2. It considers departure time constraint. The total delay time at each DDS iteration is shown in Fig. 2. The DDS found best fitness value (456 min) in the 211 iteration and stayed in this value up to the 400th iteration. Therefore, the result revealed a potential for 8 % total delay time reduction over the currently used timetable.

Table 3 shows the predefined train schedule, the result of the GA optimization phase without or with departure time constraint (the trains dispatch within 2 h before or after their predetermined departure time) and the result of the DDS optimization phase with departure time constraint.

Table 3 The predefined and optimum train schedule (with or without departure time constraint)

Fig. 3 shows the trajectory of the trains in optimum train schedule by the space–time diagram for the single-line railway using GA without or with considering departure time constraint and DDS with considering departure time constraint. As can be seen, the railway was blocked in the time of track maintenance and each train stop at a station three times a day for praying. The proposed method minimizes the total delay time due to predefined train stop in the station, train stop due to maintenance operations and praying. In this example, the GA tried to reduce total delay time due to maintenance operations by having the trains departed later or sooner from its origin. If there was no constraint on departure time, the trains departed later or sooner to have no delay time due to maintenance operations. If there was departure time constraint, the delay time due to maintenance is as little as possible. Reducing travel delay due maintenance operations led to reduce the travel time and the need to stop for praying.

Fig. 3
figure 3

Space–time diagram of the (a) predefined train schedule (b) optimum train schedule using GA optimization algorithm without considering any constraint on the departure time of the train (c) optimum train schedule using GA optimization algorithm with considering departure time of the trains is within 2 h before or after their predetermined departure time (d) optimum train schedule using DDS optimization algorithm with considering departure time of the trains is within 2 h before or after their predetermined departure time

Train timetable deals with uncertainties and disturbances in their operations. Small-scale disturbances, often caused by minor delays, do not require a significant change of the schedules. Robust train timetable is necessary to absorb the small-scale disturbances. In this paper, to measure the resilience of a timetable to minor disruptions in dwell time and evaluate the robustness of the proposed approaches’ results, uncertainty in dwell time is considered. An 8 min disturbance in one station, dwell time is simulated and its effect on the timetables of two constraint methods (integration of CA and GA, and integration of CA and DDS) are evaluated. The results show 0 and 9 extra total delay time in their train timetables, respectively. Therefore, integration of CA and GA is more robust rather than integration of CA and DDS.

4 Conclusion and future works

This paper integrates simulation and optimization algorithm to generate near optimal train timetable. The GA (in the first proposed method) and DDS (in the second proposed method) have been used to optimize train timetabling problem, while a CA simulation approach has been used to model the train traffic flow and evaluate the fitness of each solution (i.e., the total delay time generated during the optimization). In the proposed update rules, four cases were considered: a train was in front of another train, the train was near the station, the railway was blocked for maintenance, and the train must stop in a station three times a day for praying. The results reveal GA is more efficient than DDS.

Specific recommendations for future research directions include developing the proposed method in more complex situations such as the multi-lane and bidirectional railway traffic, and considering different types of trains. The next step in the process of train timetabling optimization is to obtain a train timetable that minimizes the total delay time and maximizes the capacity of rail network simultaneously. Other meta-heuristic methods can be used to optimize train timetable. Also, optimization of maximum speed, dwell time, maintenance time, and rail station for praying can be considered.