Improved Genetic Algorithm with Gene Recombination for Bus Crew-Scheduling Problem

1MOE Key Laboratory for Urban Transportation Complex Systems Theory and Technology, School of Traffic and Transportation, Beijing Jiaotong University, 3 Shang Yuan Cun, Haidian District, Beijing 100044, China 2Institute of Systems Engineering and Control, School of Traffic and Transportation, Beijing Jiaotong University, 3 Shang Yuan Cun, Haidian District, Beijing 100044, China 3Department of Civil and Environmental Engineering, Transportation Research Centre, The University of Auckland, 20 Symonds Street, Auckland 1142, New Zealand


Introduction
It has been known for more than 50 years [1] that the crew-scheduling problem for bus drivers (CSP-BD) is one of the most important operational-planning problems in a bus company, because, from the transit agencies' perspective, the largest cost of providing service is generated by drivers' wages and fringe benefits [2].The CSP-BD is aimed at assigning vehicle trips to crews in such a way that each trip is covered by a shift, while guaranteeing that all other duty functions are feasible and the total cost of all duties is minimized [2][3][4][5][6].
CSP-BD has attracted the interest of many researchers since the 1960s, and research in this area has become very active since the 1990s.Most of the methods in the existing studies are based on mathematical programming or on hybrid approaches, which are combination of heuristics and Integer Linear Programming (ILP) [7][8][9][10]; the success and limitations of these methods have been discussed in Kwan et al. [11,12] and Li and Kwan [13].In the mathematical programmingbased approach, CSP-BD is formulated as covering/partition problems that aimed at generating a subset of shifts to cover all pieces of trips, with the objective of minimizing total costs or total number of shifts [13].In recent years, metaheuristics have been widely used for searching practical near-optimal solutions to NP-hard problems.Metaheuristics offer three main advantages: (a) they are usually very efficient in searching through very large solution space; (b) they can result in a feasible solution; (c) each class of metaheuristics has its own methodical and strategic structure.Until now, much effort has been made in exploring metaheuristics, such as tabu searches (TS) [9,14,15], ant system [16][17][18], and simulated annealing [19].
Genetic algorithms (GAs), one of the most important metaheuristics, form another major class for crew scheduling.In general, structure of GA for CSP-BD could be divided into two classes: one is the shift-based chromosome structure and the other is called the piece-based chromosome structure.In the shift-based structure, the chromosome length is not fixed.By changing the gene in chromosomes repeatedly through genetic operators, a feasible solution can be obtained [20,21].
In the piece-based chromosome structure [22], a gene usually represents each piece.If a gene is chosen during the genetic operation, the corresponding shift covering the chosen gene will also be selected.Therefore, the simple crossover operation may be infeasible based on the units of shifts, let alone mutation.Furthermore, once a shift unit existed in a chromosome, no new shift units were produced except for exchanging the parent chromosomes.Thus, the efficiency of algorithm largely depends on initial parent chromosomes.
Most of researches mentioned above were based on a pregenerated set of potential fixed shifts.Through adding or removing shift units during genetic operations, an optimum solution with the least shifts is obtained.Different from the above generated method, this work introduces a new method without using the potential shift set; instead, satisfied shifts generated from process of gene recombination in genetic algorithm are employed.A different piece-based structure is taken into account and the optimal solution is generated by repeated recombination process.
The rest of paper is organized as follows.Section 2 introduces the crew-scheduling problem for bus drivers (CSP-BD) in general terms and elaborates the construction of the objective function and model.Section 3 describes the proposed genetic algorithm with gene recombination (GAGR) approach involving representation of chromosomes followed by gene recombination method.The genetic process of this section contains initialization of population, crossover, and mutation operators.In the last part of this section, an overall framework summarizes the whole process of GAGR.Section 4 provides the experiments with different parameters based on GAGR.Finally, Section 5 gives conclusion remarks and suggestions for future research.

Crew-Scheduling Problem for Bus Drivers
A vehicle block may be considered as a unit of work, which starts and ends at a relief opportunity (RO) that means a time and place at which a change of drivers is possible, for a vehicle in the course of one day.A driver's shift (or duty) is a set of pieces of work that can be assigned from the driver's signing on until his/her signing off at the depot.A piece of work denotes a shorter work between two consecutive ROs completed by the same vehicle.There are often some constraints on shifts, such as labor-agreement rules that limit work hours or the time of a break at the relief points.Several successive units (called spells) of a block form a portion of a shift.The concepts of block, RO, shift, spell, and piece of work are illustrated in Figure 1.In it, the process of generating two shifts on four blocks corresponding to four vehicles is illustrated.A shift typically starts from the crew signing on depot to a signing off depot.For shift 1, two spells combining a part of Block 1 and Block 2 are involved.For shift 2 three spells are used.There is a spell that contains only a piece of work in Block 3.
The crew-scheduling problem for bus drivers (CSP-BD) aims at finding a set of feasible shifts or duties that can cover all trips or vehicle blocks in a particular scheduling horizon.Each trip is a scheduled activity with specific starting and ending times and locations.The feasibility of a solution mainly depends on many constraints, for example, if there is enough time to enable the connection of two successive trips.Generally speaking, CSP-BD involves both a vehiclescheduling problem and a bus driver-scheduling problem.

Objective Function of CSP-BD
Let Ω be the set of  feasible shifts, represented by Ω = { 1 ,  2 , . . .,   } obtained from  pieces.Pieces set  can be formulated as  = { 1 ,  2 , . . .,   }; that is,  = ∑  =1   .Let binary variable   equal 1 if shift  is selected and equal 0 otherwise.Let  Basic  be the basic minimum payment for a shift , including the fixed salary, routine maintenance, and petrol cost.Note that bus purchase cost is not considered in this research.Let binary variable   be 1 if shift  covers piece  and 0 otherwise.Let   denote the total driving time for shift .Let  max driving shift be the maximum driving time stipulated by bus group.Let   denote the driving time for one way.Let   idle be the idle time between pieces  and  + 1 in shift , ranging between the stipulated minimum idle time  min idle and maximum idle time  max idle .Let  limit shift denote the working time limit, say 8 h, according to the labor-agreement rules for a shift.It includes the total driving time, the total idle time, and another time  for having a meal and signing on or signing off. is a large constant to penalize the number of shifts in a final schedule.In addition, each bus must start and end its workday at the same depot.The crew-scheduling problem is usually formulated as the following ILP set partitioning model: Objective ( 1) is to minimize the total number of shifts so as to reduce a bus company's total costs while maintaining almost the same service levels.All the constraints (2)-( 8) strictly limit the range of solution.Constraint (2) ensures that each piece is served once; constraint (3) guarantees that the total driving time has to be satisfied in a proper range; constraint (5) imposes upper and lower bounds on the idle time between two successive pieces.
To depict CSP-BD more clearly, we construct it on a graph.ROs are expressed as nodes and the connecting edges are according to the constraints between two consecutive driving pieces.Table 1 gives the example of a part of the Beijing Bus Group's #26 bus timetable and also shows the feasible connecting-node set with constraints of  min idle = 3,  max idle = 50, and  max shift ≤ 400.

GAGR Approach
Genetic algorithm (GA) is a global search algorithm based on the evolutionary ideas of natural selection and evolution.Except for the classical procedures crossover, selection, and mutation in GAs, the main design for GAGR is presented in this section.Piece-based chromosome representation is firstly defined.Secondly, recombination method with or without deadheads in each chromosome is illustrated in detail.Then the initial population is obtained by greedy algorithm.Next, the genetic operators of selection, crossover, and mutation are devised to generate new offspring chromosomes for the next iteration.In the end, the framework of GAGR method is presented.
4.1.Chromosome Representation.This section adopts the idea of Wren [22] that constructs a chromosome considering the pieces as genes.As displayed in Figure 2, 1, 2, . . ., 3, . . .are genes (pieces for short in schedule) and shifts are identified as 1, 2, 3, 4, . ... The whole chromosome represents a solution and the quality of this solution is evaluated by the number of shifts or cost.The number below represents each gene position (locus) and the number underlined is the last position for each shift.It may be noted that the genes are not in chronological order here as each shift is independent of the other.For example, shift 1 and shift 2 may exchange their positions and have no effect on the final solution in an iteration.

Gene Recombination.
Gene recombination method starts using such generated chromosome mentioned above.In this process, several old shifts are merged into a new shift; thus, the number of shifts reduces effectively.Gene recombination could be decomposed into two main methods.In one method, no deadhead is permitted in the middle of the generated shifts; in the other method, one or two deadheads could be added to the new shift if regulations and recombination conditions meet.We set start or end points to be the joinable points.More details are depicted in Figure 3.
(1) No Deadhead in Recombination.In Figure 3(a), shift 1 and shift 3 may have no chance to merge into a new shift based on the total working time constraint.Moreover, other constraints like the maximum and minimum idle time limit must be considered.Then the remaining combination is shown as C1, C2, C3, and C4.The first or last node in shift 1 may join with shift 2 and the potential new shifts in the above picture after combination may be 1-2-3 or 3-1-2 as well as 3-4-5-6 or 4-5-6-3 as another two generated new shifts in a schedule.
(2) One Deadhead in Recombination.Obviously, in the process mentioned above, there are no repeated pieces in new solution.Sometimes, it may be proper to add some pieces to construct new shifts and thus reduce shifts efficiently when conditions are satisfied between two shifts after first recombination.In fact, because of the inexistence, those repeated pieces are replaced by deadheads.Figure 3(b) illustrates the recombination procedure.Four pieces , ,   , and   in original piece set prepare to bridge two shifts.If the connectivity between shift 1 and shift 2 is available, it means , ,   , and   must satisfy all the necessary constraints like the total driving time and depot.In addition, the idle time limitations also confine those corresponding pieces: (3) Two Deadheads in Recombination.This procedure performs if two methods mentioned above are even not helpful to decrease the shift count.Two pieces from original piece set are selected to bridge two shifts.The feasible connection between

4.3.
Initialization.An initial population can be easily built by constructing individuals.Each individual is a solution generated by selecting pieces from its initial piece set.Length of an initial individual, , is the same as the number of pieces (genes) in a schedule.And  denotes the population size.The process for initial population construction includes six stages.
(2) Put the start pieces   into tabu list, a pieces set containing used pieces.Set  0 =   , the first node in tabu list.
(3) Find a feasible piece in nontabu list, a point set with unused pieces to connect the last piece in tabu list.
(4) If existing, put the satisfied piece into tabu list and update nontabu list, and then go to step (3).Otherwise, one shift is generated and go to step (5).
(5) If nontabu list is not empty, randomly select one piece from nontabu list and put it into tabu list, and then go to step (3).Otherwise, go to step (6).
(6) Replicate all pieces in tabu list into chromosome Ch(), and then empty tabu list.

Crossover with Duplicate Gene Removal and Repairing
Strategies.The standard roulette wheel method is adopted to select promising individuals according to the fitness function, an inverse relationship with cost function, from the current population (),  = 1, 2, . . ., , where  represents generation iterations.And each chromosome may be corresponding to each individual.A simple two-point crossover method is employed in GAGR.In view of convergence and integrity for a schedule, the duplicate genes should be removed and the lost genes in a chromosome should be readded to the crossover chromosome.Two chromosomes Ch  = { 1 ,  2 , . . .,   ,  +1 , . . .,   } and Ch  = { 1 ,  2 , . . .,   ,  +1 , . . .,   } are chosen from population and their cross point positions are  and , where 1 <  <  < .Therefore, both chromosomes are divided into three parts: { 1 , .Seek for the duplicate genes in exchanged part and nonexchanged parts, and then pick the duplicate genes and the corresponding shifts out.Delete those genes in nonexchanged parts and move the remaining genes to the end of chromosome.If remaining genes are joinable, then they combine into a new shift.Otherwise, the single gene itself constructs a new shift.The process of gene removal strategy is illustrated in Figure 4(d).

Mutation with Removal and Repairing Strategies.
The mutation procedure is devised as follows: (1) Define some parameters such as mutation rate   (0 <   < 1) and a small constant  (say 2 or 3) denoting the number of positions to be mutated in a chromosome; (2) randomly choose a number  ∈ [0, 1] for each individual; (3) compare mutation rate   and the random number .If  <   , randomly choose  positions.Then the shifts on these positions are selected and split into several segments according to the specific positions.(4) These segments are constructed into new shifts, then previous selected shifts are deleted at the meanwhile.
The final result in each chromosome may contain many piece shifts, that is, only one piece in a shift.Therefore, the recombination method mentioned above plays a significant role in decreasing objection.

Comparison with CPLEX.
To testify the accuracy for the results of GAGR, two simple examples with 36 and 72 pieces of work on single depot are tested on CPLEX, a useful tool on mathematical programming problems.The maximum iteration was set for 100 and the corresponding parameters  were set for   = 0.05,   = 0.2, and  gap = 0.8, respectively.The results are listed in Table 2 and the minimum results in each iteration are also depicted in Figure 5. From Table 2, little difference of the minimum results in both methods is shown, especially when problem size is small.Both of the running times are maintained within an acceptable range.The minimum shift for each iteration is displayed in Figure 5. Though the best result in GAGR for this example fails to reach the correct answer, the whole descending process presents the convergence of GAGR.Besides, the first result close to the correct answer shows the effectiveness for reducing shifts at the beginning of iteration.
In order to test the performance of GAGR, experiments on 10 lines in Beijing have been done.The lines information is showed in Table 3. Manual results are also listed in the table, regarded as the best results.The computational experiments were carried out by programming in MATLAB.We set the population size  to be 100 and iterations to be 20.To simplify the computation difficulty, other experimental parameters were as follows: max driving = 400; Experiments were firstly carried out on the initial chromosomes by the gene recombination.We tried to apply different parameters in order to achieve the best result.Finally, the gene recombination method with one or two deadheads is also applied to the last experiment.

Experiments on the Initial Population with Gene Recombination (GR) Method.
From Table 4, we can see a large gap between results with GR and the ones without.The maximum reducing shifts are more than one hundred shifts on Line #322.An interesting discovery shows that more pieces of work on a line may lead to larger reducing shifts, except for #348 and #34.The reason may be that more pieces of work lead to more chances to choose randomly, thus generating large shifts.This paper also applied the relative percentage deviation (RPD) according to Li and Kwan [23] over the best known schedule to measure the quality of a heuristic schedule shown below.In Table 3, we noted that all the RPD results are positive; thus, it may not achieve ideal results if just using GR method.

Experiments on the GAGR with Different Parameters.
Although GAGR approach presents its advantage on exploring new shifts and thus decreases the number of shifts, different parameters may influence its performance.These parameters consist of two types: one is called the computational parameters; parameter combinations considered in GAGR include (i) crossover rate   (0 <   < 1), (ii) the mutation rate   (0 <   < 1), and (iii) generation gap (0 <  gap < 1); the other one is the objective parameters shown in the objective function, while in this paper, the objective parameter is , a large constant in formula (1).Therefore, we set   from 0.1 to 1.0 stepped by 0.1,   from 0.05 to 0.3 stepped by 0.05, and gap from 0.5 to 0.9 stepped by 0.1 according to the classical GA method.The large constant  is set to be 10, 100, and 1000.Each line with each parameter combination runs for 10 times and each run iterates for 20 times.
(1) Experiments on GAGR with Different   .We set   = 0.05,  gap = 0.9, and  = 100 as default values when 5(a) presents the minimum and average results of experiments for each bus line, and the last row displays their average relative percentage deviation (RPD).We can see that most of the minimum results are better than the manual results (MR), especially #322, for all the results are much lower.It is testified to improve quality of solutions considering the negative values of average RPD.And tables also show something different from the classical GA; that is, a higher value of   ∈ [0.8, 1.0] may not achieve the anticipated results.The reason may be that it is likely to produce more piece shifts after crossover operation if no more short shifts can be linked with others to generate new shifts.  ranging from 0.2 to 0.4 is more favorable to obtain optimum results especially when   = 0.2 for there are 5 optimum results and the lowest average RPD shown in tables.So we may set   = 0.2 in the following tests.
(2) Experiments on GAGR with Different   .From Table 5(b), we obtain that all the average RPD is negative and the deviation in the same line is small.It demonstrates that different   may not change much.The reason is likely to be that the mutation operator can raise the possibility to generate a better solution, but not necessary.When   = 0.05, optimal results for this value take up 70% and the average RPD is obviously lower than other values.Therefore, we determine to set   = 0.05.
(3) Experiments on GAGR with Different   .As described in Table 5(c), average RPD for different  gap values are also close.The minimum results equally distribute in various  gap values, while, as seen from the average RPD of minimum and average results in Table 5(c), the suitable generation gap is set to 0.8 ultimately.
(4) Experiments on GAGR with Different .In this section, we run all the programs again and compare the results in different .From Table 5(d), we can see that almost all the results are better than the manual ones.However, all the best results may not appear in the largest  when shifts are in a large number, for example, #345 and #322.In other words, the large constant constraint may have little effect on largescale problems using GAGR.In addition, we discover that the results on a large  approximate the minimum results.The reason may be the randomness in GAGR and fewer tests in this paper.To test the validity, more experiments will be made in our future work.To keep accuracy, we set  = 1000 in our following experiments.
In the process of seeking for the suitable parameter combinations, we may discover that some optimal values appear in different parameter combinations.For example, in #306, the optimal value 26 is presented in different parameter combinations.In addition, even if the selected excellent parameters are set to experiments, sometimes the optimum results cannot be achieved.We may guess that (a) the composition of optimum shifts may be different from each other; (b) the randomness of GRGA may lead to the same result in different parameter combinations; and (c) as most of the metaheuristic algorithm the chosen parameter combinations only raise the possibility to generate a better solution but may not guarantee the certainty.

Experiments on the Final Population with GRD Method.
Based on the previous experiments on the initial population, this method tends to obtain a better solution based on the final population considering deadhead; that is, after GA the whole population is recombined with one deadhead.20 tests are performed with the selected parameter combinations and the minimum and average results before and after this method are also presented to testify the quality of this method.
As Table 6 shows, the results are improved after the combination method with one deadhead.It is interesting to find that the maximum reducing shifts reach 13; that is, 13 shifts are saved by adding one deadhead.In our tests, results in most lines are much better than the obtained optimal results except for some lines, for example, #348 and #345.Thus, the combination method with one deadhead is quite effective in reducing shifts.

Comparison with Ant Colony Algorithm (ACA).
To further test the performance of GAGR, it is necessary to compare it with other metaheuristics methods.Though different GA methods [21] with shift-based chromosome structure for CSP-BD have been provided, it is difficult to completely restore these methods because of lacking a set of potential shifts in such a huge problem.Therefore, a similar selecting piece method, ant colony method, is proposed to compare the effectiveness and efficiency of the presented GAGR method.The computational testing of GAGR was carried out by applying the code and comparing the results to the ant colony algorithm (ACA) running under the identical experimental conditions.The parameters of the proposed GAGR are set as follows:   = 0.05,   = 0.2, and  gap = 0.8,  = 1000.Meanwhile, the parameters for ant colony algorithm are as follows: (1) exploration threshold  0 = 0.95; (2) the relative importance of pheromone trails versus heuristic function  :  = 1 : 2; (3) trace persistence coefficient 1 −  = 0.9.The process of ACA is illustrated in Figure 6 and its steps are outlined below.
Step 1. Initialize the necessary variables and parameters and define the heuristic function and initial pheromone density.constraints like GAGR for each node is also built.The rule of choosing next node depends on the heuristic function that defines the closeness between two nodes and the pheromone density in each iteration.Besides randomness comparison with exploration threshold is also reflected in the process of choosing node.
Step 4. Put an unselected node for a new shift into tabu list until the tabu list is full.If all ants finish their routes, estimate all solutions by calculating the total cost and store the best one.Otherwise, return to Step 3.
Step 5. Update the pheromone density in the pheromone matrix according to the updating rules.Then continue implementing the algorithm and searching for the obtained best solution.
The criterion used to terminate the iterative search process of GAGR and ACA is that when a maximum number of iterations have been exceeded or when no improvements are observed over a number of iterations (Algorithm 1).Then the algorithm can be considered to have converged.Each line runs for 20 times.
From the comparison results, the minimum results show a large gap between GAGR and ACA and the gap is larger on large pieces number (Table 7).The results on GAGR improve much more than ACA results, since all the ACA results are not better than the manual results seen from the positive RPD values.However, the running time in ACA is obviously shorter than GAGR for its simplicity.

Conclusion
This paper presents a GA-based evolutionary approach with gene recombination about crew-scheduling problem for bus drivers.Unlike existing methods with a potential shift set for crew scheduling, a new piece-based chromosome method associating with decomposition and recombination is proposed.Shifts in parent chromosomes are divided into several piece shifts and offspring shifts are combined into new shifts during the genetic iterative process.The global solution is achieved by the repeated removal and replenished procedures.In view of the effect of different parameters, hundreds of experiments of ten bus lines from Beijing Bus Group were tested to select the optimal parameters.What is more, the gene recombination methods with or without deadhead were also employed into the initial and final populations.First, two simple examples are applied on both GAGR and CPLEX.The performance shows little difference between the correct answers and the obtained results.Compared with the current manual results, the results

Figure 2 :
Figure 2: Representation of a chromosome with gene locus.

Figure 3 :
Figure 3: The process of recombination with different situations (a) with no deadhead, (b) with one deadhead, and (c) with two deadheads.There are three shifts D1, D2, and D3 and six pieces chosen from one schedule containing one depot; the driving time for each piece is 90 minutes and maximum total driving time is 400 minutes for hypothesis.

Figure 4 :
Figure 4: Illustration of a shift at the head of cross point divided into two segments for different situations: (a)    =   −1 and    ̸ =   +1 , (b)    ̸ =   −1 and    =   +1 , (c)    =   −1 and    =   +1 , and (d) gene removal strategy.Exchanged part of Ch  is above the nonexchanged part Ch  and the value of gene  +1 is equal to  +2 .

Figure 5 :
Figure 5: The minimum shifts in each iteration when the number of pieces is 72.

Table 1 :
Part of #26 bus timetable and feasible connecting nodes with constraints.

Table 2 :
The minimum results compared with CPLEX.

Table 3 :
Size of test instances and manual results.

Table 4 :
Results of initial population with GR with no deadhead.

Table 5 :
Comparative minimum results and average results of 10 runs for six lines (a) with different   for   = 0.05,  gap = 0.9, (b) with different   for   = 0.2,  gap = 0.9, (c) with different  gap for   = 0.05,   = 0.2, and (d) with different  for   = 0.2,   = 0.05,  gap = 0.8.(The bold number is the minimum shift number for each bus line.)

Table 6 :
Minimum results of 20 runs for ten lines before and after using GRD method with   = 0.05,   = 0.2, and  gap = 0.8.