<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Discrete-Event Simulation | Aaron Wu</title><link>https://aawrail.me/tags/discrete-event-simulation/</link><atom:link href="https://aawrail.me/tags/discrete-event-simulation/index.xml" rel="self" type="application/rss+xml"/><description>Discrete-Event Simulation</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Fri, 28 Jul 2023 00:00:00 +0000</lastBuildDate><image><url>https://aawrail.me/media/icon_hu5270673394573577288.png</url><title>Discrete-Event Simulation</title><link>https://aawrail.me/tags/discrete-event-simulation/</link></image><item><title>Railway Timetabling based on Metaheuristic Search Algorithms and Simulation</title><link>https://aawrail.me/project/railway-timetabling/</link><pubDate>Fri, 28 Jul 2023 00:00:00 +0000</pubDate><guid>https://aawrail.me/project/railway-timetabling/</guid><description>&lt;center>
&lt;p>&lt;strong>Aaron Wu&lt;/strong>&lt;/p>
&lt;p>Independent Research Project, 2023&lt;br>
&lt;strong>Third Prize in Computer and Information Science&lt;/strong>&lt;br>
63rd Taiwan National Primary &amp;amp; High School Science Fair&lt;/p>
&lt;p>&lt;a href="https://twsf.ntsec.gov.tw/activity/race-1/63/pdf/NPHSF2023-052508.pdf" target="_blank" rel="noopener">Report (PDF, Chinese)&lt;/a> · &lt;a href="slides_en.pdf">Slides (PDF, English)&lt;/a>&lt;/p>
&lt;/center>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Overview of the proposed railway timetabling framework" srcset="
/project/railway-timetabling/optimization-flow_hu4172309005452753031.webp 400w,
/project/railway-timetabling/optimization-flow_hu17253361829004491468.webp 760w,
/project/railway-timetabling/optimization-flow_hu3890966848461303715.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/optimization-flow_hu4172309005452753031.webp"
width="760"
height="476"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 7 from the report. The optimization algorithm generates candidate timetables, which are decoded and evaluated through train and passenger simulations.&lt;/em>&lt;/p>
&lt;p>&lt;strong>Nangang–Taoyuan case study&lt;/strong> · 11 stations · 20 GA-CR runs&lt;/p>
&lt;ul>
&lt;li>&lt;strong>68.29% simulated trip completion&lt;/strong>, up from 63.44% for the published timetable (&lt;strong>+4.85 percentage points&lt;/strong>).&lt;/li>
&lt;li>&lt;strong>28.1 minutes average simulated journey time&lt;/strong>, down from 29.0 minutes (&lt;strong>−3.1%&lt;/strong>).&lt;/li>
&lt;/ul>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>Railway timetabling is a complex combinatorial optimization problem involving numerous operational constraints and decisions that directly affect passenger service quality. Traditional manual timetabling requires substantial domain expertise and makes it difficult to systematically evaluate schedules against passenger demand.&lt;/p>
&lt;p>In this work, I developed a passenger-oriented railway timetabling framework combining metaheuristic search algorithms with discrete-event simulation. The framework introduces a compact timetable representation and two coupled simulators for resolving train conflicts and evaluating passenger journeys.&lt;/p>
&lt;p>Experiments were conducted using both synthetic passenger demand and historical origin–destination data from Taiwan Railways. On the Nangang–Taoyuan corridor, the proposed genetic algorithm improved simulated passenger trip completion from &lt;strong>63.4% to 68.3%&lt;/strong>, while reducing average journey time from &lt;strong>29.0 to 28.1 minutes&lt;/strong> across 20 optimization runs.&lt;/p>
&lt;h2 id="method">Method&lt;/h2>
&lt;h3 id="problem-formulation">Problem Formulation&lt;/h3>
&lt;p>Given railway infrastructure, train specifications, operational constraints, and historical passenger demand, the objective is to generate a feasible railway timetable that:&lt;/p>
&lt;ul>
&lt;li>Maximizes the proportion of passengers reaching their destinations within their individual time limits.&lt;/li>
&lt;li>Minimizes average journey time, including waiting and in-vehicle travel time, among successful passengers.&lt;/li>
&lt;li>Satisfies modeled railway operating constraints, including minimum headways and track capacity.&lt;/li>
&lt;/ul>
&lt;p>To balance the two optimization objectives, I introduced a passenger success-rate threshold. The search prioritizes improving trip completion until the threshold is reached, after which it prioritizes reducing average journey time. This comparison can be written as a lexicographic objective:&lt;/p>
$$
\max_{\mathrm{lex}} \left(\min(S(x), \theta), -T(x)\right)
$$
&lt;p>Here, $S(x)$ is the share of passengers who reach their destination, $T(x)$ is the average journey time among those passengers, and $\theta$ is the completion-rate threshold.&lt;/p>
&lt;h3 id="timetable-representation">Timetable Representation&lt;/h3>
&lt;p>Directly optimizing the arrival and departure times of every train at every station leads to a large search space.&lt;/p>
&lt;p>I designed a compact timetable representation that encodes each train using:&lt;/p>
&lt;ul>
&lt;li>Service origin and destination&lt;/li>
&lt;li>Train type and travel direction&lt;/li>
&lt;li>Initial entry time&lt;/li>
&lt;li>Station stopping patterns&lt;/li>
&lt;li>Planned overtaking holds&lt;/li>
&lt;/ul>
&lt;p>The encoded timetable is subsequently decoded into a complete schedule through simulation.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Draft timetable encoding showing service data, entry times, and stop patterns" srcset="
/project/railway-timetabling/timetable-encoding_hu8040388988078039395.webp 400w,
/project/railway-timetabling/timetable-encoding_hu6083957517975276788.webp 760w,
/project/railway-timetabling/timetable-encoding_hu18411862977258949573.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/timetable-encoding_hu8040388988078039395.webp"
width="760"
height="159"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 1 from the report. Encoding for a draft timetable.&lt;/em>&lt;/p>
&lt;h3 id="train-simulation">Train Simulation&lt;/h3>
&lt;p>The first simulator uses discrete-event simulation to generate operationally feasible timetables from encoded candidates.&lt;/p>
&lt;p>Train arrivals, departures, and pass-through movements are represented as discrete events and processed chronologically through an event queue.&lt;/p>
&lt;p>When a potential conflict is detected, the simulator adjusts train movements according to modeled operating constraints, including station track availability, minimum headways, and restrictions on overtaking between stations.&lt;/p>
&lt;p>The operating rules were informed by infrastructure data and interviews with Taiwan Railways dispatchers.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Time-distance diagram of a generated railway timetable" srcset="
/project/railway-timetabling/simulated-timetable_hu436431746084713034.webp 400w,
/project/railway-timetabling/simulated-timetable_hu6573572512731763326.webp 760w,
/project/railway-timetabling/simulated-timetable_hu6336971917641351709.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/simulated-timetable_hu436431746084713034.webp"
width="760"
height="484"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 15 from the report. A portion of the timetable generated by the train simulator, visualized as a time–distance diagram.&lt;/em>&lt;/p>
&lt;h3 id="passenger-simulation">Passenger Simulation&lt;/h3>
&lt;p>The second simulator evaluates timetable quality by modeling passenger journeys under time-dependent travel demand.&lt;/p>
&lt;p>Hourly origin–destination (OD) data are converted into passenger arrival events using a Poisson point process.&lt;/p>
&lt;p>Passenger routing is formulated on a directed graph constructed from train arrival and departure events. A Dijkstra-based search finds the earliest reachable arrival within the passenger’s time and transfer limits. Waiting edges connect successive events at the same station with weight 0. Riding edges connect boarding and alighting events with weight 1, so a path’s weight counts the number of trains boarded.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Passenger routing graph with waiting edges in black and riding edges in red" srcset="
/project/railway-timetabling/passenger-routing_hu10029786901874543082.webp 400w,
/project/railway-timetabling/passenger-routing_hu4541094196838866965.webp 760w,
/project/railway-timetabling/passenger-routing_hu7109815964495743413.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/passenger-routing_hu10029786901874543082.webp"
width="760"
height="440"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 12 from the report. Directed graph for passenger routing. Events are ordered by time from left to right.&lt;/em>&lt;/p>
&lt;p>When a train reaches its passenger capacity, affected passengers must search for an alternative route. A journey is considered unsuccessful if no feasible route can reach the destination within the passenger&amp;rsquo;s time limit.&lt;/p>
&lt;p>The resulting passenger success rate and average journey time are returned to the optimization algorithm.&lt;/p>
&lt;h3 id="metaheuristic-optimization">Metaheuristic Optimization&lt;/h3>
&lt;p>I investigated several search strategies for optimizing the encoded timetables:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Multi-Start Hill Climbing:&lt;/strong> Performs local search with randomized restarts to explore different regions of the solution space.&lt;/li>
&lt;li>&lt;strong>Variable Train Count:&lt;/strong> Introduces train addition and removal operations to improve search flexibility.&lt;/li>
&lt;li>&lt;strong>Threshold Accepting:&lt;/strong> Temporarily accepts bounded deteriorations in solution quality to escape local optima.&lt;/li>
&lt;li>&lt;strong>Genetic Algorithm:&lt;/strong> Evolves a population of candidate timetables through mutation, crossover, and selection.&lt;/li>
&lt;/ul>
&lt;p>For the genetic algorithm, I designed multiple crossover operators at both the train-service and stopping-pattern levels.&lt;/p>
&lt;p>I tested nine stopping-pattern crossover operators. They match trains by criteria such as direction, service hour, and Hamming distance between stop patterns, then exchange or combine part of the pattern. Every ten iterations, the algorithm updates the operator selection probabilities based on how often each operator produced offspring that outperformed their parents.&lt;/p>
&lt;p>The complete optimization and simulation framework was implemented in C++.&lt;/p>
&lt;h2 id="experimental-results">Experimental Results&lt;/h2>
&lt;h3 id="timetable-reconstruction">Timetable Reconstruction&lt;/h3>
&lt;p>To assess the train simulator, I reconstructed a published September 2022 Taiwan Railways timetable using only its stopping patterns and initial train entry times.&lt;/p>
&lt;p>The experiment covered 11 stations between Nangang and Taoyuan and used historical weekday passenger demand from September 2019.&lt;/p>
&lt;p>Both the published and reconstructed timetables were evaluated using the same passenger simulation framework.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Timetable&lt;/th>
&lt;th style="text-align: right">Passenger Success Rate&lt;/th>
&lt;th style="text-align: right">Average Journey Time&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">Published TRA Timetable&lt;/td>
&lt;td style="text-align: right">63.44%&lt;/td>
&lt;td style="text-align: right">29.0 min&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Reconstructed Timetable&lt;/td>
&lt;td style="text-align: right">64.88%&lt;/td>
&lt;td style="text-align: right">28.0 min&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The reconstructed timetable achieved passenger service metrics comparable to those of the published timetable while satisfying the modeled operating constraints.&lt;/p>
&lt;h3 id="optimization-using-historical-passenger-demand">Optimization Using Historical Passenger Demand&lt;/h3>
&lt;p>I compared three metaheuristic optimization strategies:&lt;/p>
&lt;ul>
&lt;li>Multi-start hill climbing with threshold accepting (HC-TN-THAC)&lt;/li>
&lt;li>Mutation-only genetic algorithm (GA-MU)&lt;/li>
&lt;li>Genetic algorithm with mutation and crossover (GA-CR)&lt;/li>
&lt;/ul>
&lt;p>Across 20 optimization runs on historical Taiwan Railways demand, GA-CR achieved the best performance among the evaluated methods.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Metric&lt;/th>
&lt;th style="text-align: right">Published TRA Timetable&lt;/th>
&lt;th style="text-align: right">GA-CR&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">Passenger Success Rate&lt;/td>
&lt;td style="text-align: right">63.44%&lt;/td>
&lt;td style="text-align: right">&lt;strong>68.29%&lt;/strong>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Average Journey Time&lt;/td>
&lt;td style="text-align: right">29.0 min&lt;/td>
&lt;td style="text-align: right">&lt;strong>28.1 min&lt;/strong>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Comparison of metaheuristic optimization methods on historical Taiwan Railways passenger demand" srcset="
/project/railway-timetabling/benchmark-results_hu7314129720416339123.webp 400w,
/project/railway-timetabling/benchmark-results_hu3407564297900650489.webp 760w,
/project/railway-timetabling/benchmark-results_hu14807544312240281238.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/benchmark-results_hu7314129720416339123.webp"
width="760"
height="487"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 23 from the report. Distributions of passenger success rate (left) and average journey time (right). Journey time is expressed in 30-second units.&lt;/em>&lt;/p>
&lt;h3 id="analysis-of-search-strategies">Analysis of Search Strategies&lt;/h3>
&lt;p>Experiments on synthetic and historical passenger demand revealed that the effectiveness of different search strategies depends on the structure and complexity of the optimization problem.&lt;/p>
&lt;p>Threshold accepting improved search robustness by allowing the algorithm to escape local optima. Mutation-only genetic algorithms performed competitively on several simpler synthetic instances but showed signs of premature convergence on the historical demand case.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Success rate and journey time across twelve synthetic demand instances" srcset="
/project/railway-timetabling/synthetic-demand-results_hu11053807181040105352.webp 400w,
/project/railway-timetabling/synthetic-demand-results_hu2689435878618107587.webp 760w,
/project/railway-timetabling/synthetic-demand-results_hu5705343410424398621.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/synthetic-demand-results_hu11053807181040105352.webp"
width="760"
height="485"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 22 from the report. Results on synthetic demand. The upper panel shows trip completion and the lower panel shows journey time in 30-second units.&lt;/em>&lt;/p>
&lt;p>On the historical demand case, crossover helped maintain population diversity. Figure 24 compares representative runs and shows how the mutation-only search converged early while the crossover variant continued to improve.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="flex justify-center ">
&lt;div class="w-100" >&lt;img alt="Convergence plots for mutation-only and crossover genetic algorithms" srcset="
/project/railway-timetabling/crossover-convergence_hu17204182664043155809.webp 400w,
/project/railway-timetabling/crossover-convergence_hu7235855576943346529.webp 760w,
/project/railway-timetabling/crossover-convergence_hu13394714813864298238.webp 1200w"
src="https://aawrail.me/project/railway-timetabling/crossover-convergence_hu17204182664043155809.webp"
width="760"
height="378"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p>
&lt;p>&lt;em>Figure 24 from the report. Search traces on historical Taiwan Railways demand for GA-MU (left) and GA-CR (right).&lt;/em>&lt;/p>
&lt;h2 id="limitations">Limitations&lt;/h2>
&lt;p>The proposed framework evaluates railway timetables within a simulated environment and under a defined set of operational constraints.&lt;/p>
&lt;p>Several practical aspects remain outside the scope of the current evaluation, including rolling stock circulation, more complex multi-track infrastructure, and comprehensive validation of overtaking strategies.&lt;/p>
&lt;p>The metaheuristic algorithms also do not provide guarantees of global optimality.&lt;/p>
&lt;p>Future extensions could incorporate additional operational constraints, larger railway networks, and comparisons against mathematical optimization methods.&lt;/p>
&lt;h2 id="acknowledgments">Acknowledgments&lt;/h2>
&lt;p>I would like to thank the Taiwan Railways dispatching staff and the Ministry of Transportation and Communications for their assistance in providing operational insights and historical passenger demand data.&lt;/p></description></item></channel></rss>