Abstract
Crew scheduling is one of the crucial processes in railroad operation planning. Based on current regulations and working and break time requirements, as well as the operational rules, this process aims to find a duty arrangement with minimal cost that covers all trips. Most past studies considered this subject for railroad systems as an optimization problem and solved it with mathematical programming-based methods or heuristic algorithms, despite numerous logical constraints embedded in this problem. Few studies have applied constraint programming (CP) approaches to tackle the railroad crew scheduling problem. This paper proposes a hybrid approach to solve the problem with a CP model for duty generation, and an integer programming model for duty optimization. These models have been applied to the Kaohsiung depot of Taiwan Railways Administration, the largest railroad operator in Taiwan. The encouraging results show that the proposed approach is more efficient than the manual process and can achieve 30% savings of driver cost. Moreover, the approach is robust and provides flexibility to easily accommodate related operational concerns such as minimizing the number of overnight duties. Thus, this hybrid two-phase approach seems to have the potential for applications to the railroad crew scheduling problems outside Taiwan.
Crew management is an important issue for public transportation systems. It is concerned with building the schedules and rosters of crews needed to cover a planned timetable while satisfying operational and regulation rules. In practice, this complex and challenging problem is decomposed into two subjects: crew scheduling and crew rostering ( 1 ). Crew scheduling aims to find a set of duties (or called “pairings”) with a minimal cost to cover all trips (or called “tasks or legs”) defined by a given timetable without violating any scheduling rules. At this level, the duties are not assigned to individual crews. Crew rostering then assigns the duties resulting from crew scheduling to construct a roster that spans a given period of time according to rostering rules. Crew scheduling thus plays a critical role in assisting a transportation agency or company in minimizing its labor costs ( 2 ).
Crew scheduling is a well-known problem in operations research (OR) and has been applied to different transportation fields including airlines, bus transit, and the railroad industry ( 1 , 3 , 4 ). This paper addresses the crew scheduling problem for railroad systems. Railroad crew scheduling has been discussed in the literature since the 1990s ( 1 , 5 ). Most current solution approaches rely on column generation with set covering problem (SCP) or set partitioning problem (SPP) formulations (6–9). The solution procedure comprises duty generation and duty optimization. For duty generation, it starts from an initial setup and subsequently generates new duties to get a set of feasible (or partially feasible) duties—that is, columns—and to set up the master problem in SCP or SPP form. For duty optimization, it implements a dynamic column generation algorithm to search the optimal combination of duties. The algorithm repeats itself to solve the restricted master problem with linear programming relaxation, check if the dual values yield negative reduced costs, generate new columns, add them to the restricted master problem, and then resolve it for improvement until the optimum is found.
For real-world applications, it may be found that regulations and operational rules are too complicated to be fully covered in the duty generation phase for solving the problem. In such a case, it can be helpful to properly treat some rules as additional constraints and add them to the master problem in the duty optimization phase ( 8 , 9 ). Based on this modified column-generation procedure and a variable fixing technique, crew scheduling software and decision support tools have been developed and implemented at DB Schenker in Germany ( 8 ).
Other than column generation, network flow-based approaches are applied to solve the railroad crew scheduling problem as well. The problem is formulated as a minimum-cost flow problem with a space-time network, which is constructed in such a way that all regulations and rules are enforced. This formulated integer programming (IP) problem is then solved with decomposition and relaxation techniques. This approach has been applied to solve the crew scheduling problem in the context of North American railroads with encouraging results ( 10 , 11 ). A similar approach has been applied to the Turkish State Railways ( 12 ). Moreover, because of the NP-hard property of the problem, heuristics and meta-heuristics are also adopted in the applications to some light rail and mass rapid transit (MRT) systems. For example, tabu search is applied to solve the problem for the Lisbon Underground as well as the Singapore MRT, and also is the evolutionary algorithm for the Santiago Metro (13–15).
As described above, current studies on the crew scheduling problem for railroad systems mainly consider the problem solely as an optimization problem and solve it with mathematical programming (MP)-based methods or heuristic algorithms. Instead of these conventional approaches, this paper proposes a hybrid approach using both constraint programming (CP) and IP to solve the problem. The roots of CP can be traced back to the work in the field of artificial intelligence on solving constraint satisfaction problems (CSPs) in the 1970s ( 16 ). In fact, the duty generation part of the problem is a CSP itself, and can be tackled by CP more appropriately than by MP. The underlying theory of CP and applications of CSP are discussed by Apt and Brailsford et al., respectively ( 17 , 18 ). Although CP is different from MP, it provides a complementary technology to MP for solving many combinatorial problems including the crew scheduling problem ( 19 ). Schemes of how to incorporate OR to CP are discussed by Hooker ( 20 ).
To the best of the authors’ knowledge, the hybrid CP/IP approach has not been applied to the railroad crew scheduling problem for real-world applications. Nevertheless, this hybrid approach has been proved to be successful in the applications in some related fields, for example, bus driver scheduling, MRT crew scheduling, and maintenance crew scheduling (21–23). Therefore, this paper reports the first application of using CP and IP to solve the railroad crew scheduling problem with a case from the Kaohsiung depot of the Taiwan Railways Administration (TRA). Although passenger trains are taken for the case study, the proposed approach is also applicable to the crew scheduling problems for scheduled freight-train services.
The remainder of this paper is organized as follows. First, the crew scheduling problem for railroad systems is defined. Then, a hybrid approach with a CP model is proposed for duty generation, and an IP model is proposed for duty optimization to tackle the problem. The formulations of the two models are described in detail. A real crew scheduling problem of TRA Kaohsiung Depot is then solved by the proposed models to test their efficiency and effectiveness. Finally, conclusions and recommendations for future studies are presented.
Problem Definition and Solution Framework
Given a timetable, railroad crew scheduling generates a minimum set of duties to cover all trips while satisfying all restrictions imposed by governmental regulation and company policies. In general, a train journey derived from a published timetable can be divided into a sequence of trips. Each scheduled trip is characterized by a train, a departure time, an arrival time, an origin station, and a destination station. These origin and destination stations are called relief points (RPs), where train drivers could hand over duties, rest, and even stay overnight. Train drivers check in and check out their duties at the same home depot (HD), which is also one of the RPs. Moreover, “deadhead” trips are those inevitable trips resulting from regulatory rules in which train drivers are transported as passengers to another RP station. The sequence of activities to be carried out by one train driver is called a duty, and it may last to the next day. Figure 1 depicts an example of a duty performed from 08:00 to 17:00 which starts and ends at the HD. It consists of three trips, three breaks, and one deadhead trip. As shown in the figure, the changeover between two adjacent trips is required to be at a same RP. For each trip in the duty, there are some pre-trip and post-trip works for preparing and facilitating the associated trips, which are called auxiliary works.

An example of a duty performed from 08:00 to 17:00 which starts and ends at the home depot (HD).
The objective of railroad crew scheduling is to minimize the overall driver costs which are typically quantified by the number of train drivers. Theoretically, if railroad operators could assign a train driver to each trip, it would be the simplest way to arrange duties without any violation of regulations. However, the human resource is precious and limited. Thus, operators must determine the optimal arrangement of duties to save labor costs.
This paper proposes a hybrid CP/IP approach for solving the railroad crew scheduling problem. Figure 2 presents the solution framework, which consists of two phases: duty generation and duty optimization. In the first phase, the problem of identifying feasible duties that satisfy all the regulations for scheduling is actually a CSP rather than an optimization problem. Thus, based on the input data, a CP model is formulated to solve the CSP for generating all the feasible duties. In the second phase, the duty optimization problem is formulated as a SPP to determine the minimal number of duties that cover all scheduled trips. A successful application of this solution framework to the TRA is described next.

A hybrid constraint programming/integer programming (CP/IP) solution framework for railroad crew scheduling problem.
Case Background and Operational Requirements
TRA is the largest railroad operator in Taiwan. Its network encircles Taiwan and is approximately 1,065 km in length. The average daily ridership was over 630,000 passenger trips in 2020 ( 24 ). The Rolling Stock Department of TRA is responsible for the arrangement of driver duties for every depot depending on the operational and regulatory requirements. Because of the geographic environment of Taiwan and the service characteristic of TRA, a long-distance train journey is divided into several segments according to the locations of associated crew-base HDs. Each segment is viewed as a unique trip and assigned to a proper depot for scheduling. Based on the current practices of TRA, the crew schedule is managed on a depot-by-depot basis such that each train driver is assigned to a specific HD. The crew schedules for all depots must comply with the common regulations set by the TRA. For example, there is a restriction on the maximum length of continuous driving time (CDT) as well as the maximum length of a duty for safety reasons. In addition, each HD may have its specific scheduling rules to meet its own needs because of different classes of trains dispatched. In some situations, a train driver may need to stay overnight at an RP for performing some next-day trips before returning to the HD. Consequently, a duty scheduled on a specific day (late at night) may cover some trips on the next day (in early morning). This cross-day coverage makes the railroad crew scheduling problem more complicated than that confronted in bus transit and MRT systems.
This case study addresses the crew scheduling problem for the Kaohsiung depot, the major depot in southern Taiwan. Figure 3 shows the service region covered by the Kaohsiung depot in TRA’s network. It covers 319 km in length with 71 stations, including nine RP stations. The total driving time and mileages for all trips are 10,539 min and 11,313 km respectively per day.

Service region of the Kaohsiung depot in Taiwan Railways Administration (TRA)’s network.
Figure 4 illustrates the traffic load in the number of simultaneous trips—that is, the number of train drivers—required for a daily operation at the Kaohsiung depot. The requirements considered in the TRA-Kaohsiung crew scheduling case problem are summarized in Table 1.

The trip load for a daily operation at Kaohsiung depot of Taiwan Railways Administration (TRA).
Requirements Considered in the Taiwan Railways Administration(TRA) Kaohsiung Case Problem
Formulation of the CP Model for Duty Generation
First, the input data and parameters used for the CP modeling in the case study are introduced. The notations associated are listed in Table 2. Most of the input data for the proposed CP model is related to trips.
Notations of Input Data Sets and Parameters in the Constraint Programming (CP) Model
In the first phase of the CP/IP solution approach, a CP model for duty generation is formulated. Each solution obtained from the CP model represents a feasible duty. The definition of decision variables and the associated constraints of the CP model are described in detail as follows.
Representation of Decision Variables
A feasible duty can be defined as a sequence of trips in a general form as Equation 1:
where
and the domain of
The parameter
There may be a break between two adjacent trips. The variable
To trace the duration of the break between two adjacent trips, the variable
In railroad crew scheduling, a sequence of consecutive trips without breaks makes a huge influence on driver fatigue. Driver fatigue is one of the most common hazards to railroad safety. Therefore, it is necessary to keep track of CDT and mileage for consecutive trips, which are denoted by the variables
Working time is also viewed as a critical performance measure reflecting the efficiency of duty arrangement. The work performed by a driver is composed of driving work and auxiliary work. The auxiliary time
Table 3 summarizes the variables used in the proposed CP model. A part of the regulations can be tackled by setting upper bounds in the domain of associated variables. For example,
Definition of Variables in the Constraint Programming (CP) Model
Representation of Constraints
Feasible duties must satisfy all the regulatory and operational rules. All these rules are formulated as logical constraints in the CP model as described below.
Equations 10 and 11 are used to ensure the appropriate order of the trips. In general, the time between two adjacent trips is greater than 70 min under the regulation as shown in Equation 10. However, the requirement can be exempted in the case that it is the same train in operation, as shown in Equation 11.
In a feasible duty, each succeeding trip must start from the same RP station where the preceding trip ended. This location-fit rule is formulated as Equation 12. In addition, drivers must both start and end their duties at the HD, as shown in Equations 13 to 15.
Taking overnight stays for train drivers into account, the regulation allows a longer break time for such drivers to have an enough rest. For two adjacent trips with a break, if the arrival time of the preceding trip is between 20:00 and 01:00 the next day, the driver is allowed to perform the succeeding trip at most 10 h after the end of the preceding trip. This rule is as defined by Equation 16. For other cases, the time gap between two adjacent trips is limited to 6 h as described in Equations 17 and 18.
In this study, the upper bound of CDT for train drivers is 6 h. However, for late-night trips, the TRA has a more restricted limit, that is, 5 h, for safety considerations. A late-night trip is defined as a trip of which the driving time during the period from 22:00 to 06:00 the next day is longer than or equal to 2 h. For such late-night trips, there is a specific regulation to restrict CDT to 5 h for safety reasons. The illustration of the regulation of CDT related to late-night trips is shown in Figure 5. The duty as show in Figure 5a covers no late-night trips, so its CDT is limited to 6 h. On the other hand, the two duties as shown in Figure 5, b and c, cover two and one late-night trips, respectively, so that, for both of them, CDT is restricted to at most 5 h. For the case shown in Figure 5b, where the continuous driving breaks at a late-night trip, its CDT restriction is defined in Equation 19. On the other hand, for the case shown in Figure 5c, where the last one of the consecutive trips is not a late-night trip, CDT is defined in Equation 20.

Illustration of three duties related to late-night trips.
In general, the total working time is limited to at most 14 h, which is defined as the upper-bound value of its domain. However, when the duration of any break occurring in a duty does not exceed 4 h, it must be limited within 12 h, as defined in Equation 21. Moreover, the length of duty time, that is, the sum of total working time and the total break time, has a maximal value of
Formulation of the SPP Model for Duty Optimization
Given all the feasible duties generated from the CP model in the first phase, the next phase of the solution framework is to determine the minimum number of duties that satisfy all TRA scheduling rules. This duty optimization problem is formulated as a SPP in the IP model. The advantage of the SPP formulation is that, unlike the SCP formulation, it will not yield optimal duties with repeated trips.
The input data for the SPP model include the following: the set of trips,
Min
Subject to
As shown in Equation 23, the model minimizes the total cost of duties. The cost for each duty (i.e.,
Case Study
The current study employs C# programing language compiled on the .Net framework. A desktop PC (Intel Core i7-6700K CPU, 3.40 GHz with 16GB RAM) is used to execute the proposed solution approach in a Windows 10 environment. An open-source solver, Google OR-Tools, is utilized to formulate the proposed CP and SPP models for solving the crew scheduling problem confronted by the Kaohsiung depot of TRA ( 25 ).
As mentioned earlier in the case background, it is inevitable to assign cross-day duties with overnight stays to some train drivers. It is because there are not enough midnight trips to take all the train drivers back to the HD in time without violating work-time constraints. This situation implies that a daily schedule at the TRA Kaohsiung depot would include both single-day duties, which start and end on a same day, and cross-day duties, which start on one day but end on the next day. To incorporate this cross-day coverage into a single-day crew schedule problem, this study has developed a novel scheme to carry out the proposed CP/IP solution methods. This scheme proceeds as the following: 1) to use an extended input with next-day trips for duty generation in the CP model; 2) to modify the cross-day duties generated from the CP model; and 3) to apply the modified duties to the SPP model for duty optimization in day one.
Suppose that the scheduling problem for a particular day, say day one, is being dealt with. First, an extended (cross-day) input that includes all day-one trips and some day-two trips is used for duty generation. All these trips are derived from the timetable published by TRA. The time distribution of these trips over time is illustrated in Figure 6, where a black bar and a gray bar represent a day-one trip and a day-two trip, respectively. Note that it is not necessary to consider all day-two trips for the duty generation in day one. Instead, it is only necessary to consider those day-two trips within a time span, which is called “cross-day range.” In the base case, as shown in the figure, the cross-day range is 21 h, which extends from 24:00 to 45:00, that is, from the end of day one to the 21:00 of day two. It is because the last trip scheduled on day one is at 23:00, the pre-trip preparation requires 30 min so that the last trip actually starts from 22:30. Moreover, the TRA rules demands that the maximum length of a duty be limited to 22.5 h. Accordingly, the maximal time range of day-two trips that can be covered by day-one duties is 21 h.

Time distribution of cross-day input with day-one and day-two trips.
As explained above, the extended cross-day input of the case study includes 130 day-one trips and 98 day-two trips. The related parameter values used in the CP model are summarized in Table 4. The computation time and the resulting number of feasible duties of the CP model for duty generation are summarized in the left side of Table 5.
Parameter Values in the Taiwan Railways Administration(TRA) Kaohsiung Case Study
Results of the Base Case
As mentioned earlier, the second key step of the implementation scheme is the modification of the feasible duties generated from the CP model. Specifically, those repeated trips at the same time on both days are relabelled with a same trip identification number for all generated feasible duties. The final step is to apply this modified set of feasible duties to the SPP model for duty optimization in day one, in which the same unity cost (i.e.,
Table 5 summarizes the results of the base case application. In TRA, the crew schedule is generated manually by an experienced employee. The manual results provided by the Kaohsiung depot of TRA required 37 duties for a daily operation. This approach generated a solution of 26 duties, which represents approximately 30% savings in labor costs in relation to the number of drivers. It is found that the optimal solution obtained from the proposed model has a higher average duty length and a smaller standard deviation when compared with the manual solution. In the base case, the average duty length increases from around 12 h (in the manual result) to about 17.5 h (in the optimal solution), while the standard deviation of duty length decreases from 276 min to 217 min. It implies that the optimal duties are arranged more efficiently and evenly without violating scheduling rules.
The computer implementation of this solution is very efficient. The manual process usually takes several weeks, whereas this approach takes only 49 min to get the optimal solution. As railroad crew scheduling is an offline planning process, the computational efficiency of the proposed models should be adequate for real-world applications.
Figure 7 depicts the detailed composition for each of the 26 optimal duties in relation to trips, auxiliary works, breaks, and overnight stays. Specifically, these 26 optimal duties include 7 single-day duties and 19 cross-day duties, of which 13 are with overnight stays.

Composition of the optimal duties in the base case.
Impact of Overnight-Stay Cost
Extra costs are incurred from the arrangement of overnight stays for train drivers in their cross-day duties. Such costs include not only providing dormitories for drivers, but also the allowances paid for the duties overtime, the extra administration cost, and other risk management cost for overnight stays. To take these costs into account, a weighted cost in the objective function of the SPP model with a penalty cost factor α is adopted. Specifically, the cost of duty

Impact of the overnight-stay cost.
As shown in the figure, the number of overnight-stay duties decreases quickly and significantly from 13 to 9 as α goes from 0 to 0.5. For α > 0.5, further increase of the overnight-stay cost seems to have no impact on the resulting number of overnight-stay duties. Meanwhile, the total number of duties required for a daily operation seems insensitive to the overnight-stay cost; it remains the same as 26 for all values of α tested from 0 to 10. Note that, for α ≥ 0.5, the overnight-stay ratio of all train drivers drops from 50% to 35%, that is, from 13/26 to 9/26. This indicates a significant improvement in both the operation cost for the TRA, and the overnight-stay workload assigned to train drivers. A detailed composition of the 26 optimal duties with 9 overnight-stay duties for α = 1 is shown in Figure 9.

Composition of the optimal duties for α = 1.
Solution Efficiency Enhancement
In railroad crew scheduling, the problem size increases considerably with the increase in the number of trips included, which significantly affects the solution quality and efficiency. As described earlier, in the base case scenario where the cross-day range is 21 h, there are 98 next-day trips on top of 130 same-day trips in the CP model. The idea here is trying to improve the solution efficiency by properly reducing the number of next-day trips. Thus, testing the base-case instance is repeated with different values of the cross-day range between 12 h and 21 h. The results are shown in Table 6.
Sensitivity Analysis for the Cross-Day Range
Note that the elapsed time of the computer implementation for duty generation declines as the cross-day range decreases. Specifically, the CP model implementation took 2,888 s to generate all 349,540 feasible duties when the range is 21 h. As the range decreases to 14 h, it only took 1,949 s to generate all 273,985 feasible duties. The elapsed time reduces significantly from 2,888 s to as low as 1,949 s, while the optimal duties keep the same at 26. The computational efficiency for duty generation is improved by 33%. However, when the cross-day range is less than 14 h, the number of required duties increases to 27. In this case, the cross-day range is too small to generate enough numbers of feasible duties to yield the optimal solution. On the whole, the results imply that railroad operators can enhance the solution efficiency with properly designed input of the CP model without sacrificing the solution quality.
Conclusions
This paper proposes a hybrid CP/IP approach to solve the crew scheduling problem for railroad operators. Existing studies on this topic consider the process as primarily an optimization problem and solve it with heuristic or meta-heuristic methods. Because of the complexity of the problem, they usually involve approximations and adjustments, and even ignoring or relaxing features that are difficult to formulate. This paper seems to be one of the first that applies CP techniques to railroad crew scheduling applications while considering the condition of overnight stays for train drivers.
The hybrid approach was applied to tackle the crew scheduling problem for the Kaohsiung depot of TRA and encouraging results were obtained. As compared with the manual results generated by TRA, the proposed models can significantly reduce the number of the required duties from 37 to 26 for a daily operation, which represents 30% savings in labor costs. Moreover, the issues for reducing overnight duties, as well as enhancing solution quality and efficiency, are also discussed. With the same minimum cost of 26 required duties, the ratio of duties with overnight stays further reduces from 50% to 35% in this study. Besides, the computer elapsed time can be reduced by 33% with properly condensing the solution space for the proposed CP model.
Facing the revision of regulations on crew scheduling regularly, TRA must take lots of effort in duty arrangement to satisfy the operational and contractual requirements. The proposed solution approach can easily deal with any adjustment of requirements with the CP model. The results of this paper demonstrate that the proposed hybrid approach is promising and has the potential for applications to crew scheduling problems of railroad systems in countries other than Taiwan, as well as scheduled freight-train services.
Footnotes
Author Contributions
The authors confirm contribution to the paper as follows: study conception and design: G. Chen, J. Jong, A. Han; data collection: G. Chen; analysis and interpretation of results: G. Chen, J. Jong, A. Han; draft manuscript preparation: G. Chen, J. Jong, and A. Han. All authors reviewed the results and approved the final version of the manuscript.
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
