Professional Documents
Culture Documents
In the speed profile, four driving phases are needed and the speed of each phase should satisfy the time
and distance constraints. Under this condition, to achieve the speed profile, six decision variables are
needed.
Once the number of decision variables is defined, we should consider mapping the solution space into
the chromosome space to simplify the crossover and mutation operations. In this thesis, the
chromosome is defined as a N*6 dimensional matrix ! with the speed profile for each segment as
! = (!! ; !! ; ; !! ; ; !! )
!! = ! !, 1 , ! !, 2 , ! !, 3 , ! !, 4 , ! !, 5 , ! !, 6 , ! = 1, , !
3.2 Initialization
For each 1 ! !, we first randomly generate the boundary speed !(!, 1) and !(!, 2) satisfying
(2.3.2), then based on the boundary speed !(!, 1), the cruising speed !(!, 3) can be generated to
14
Approaching the genetic algorithm
satisfy the condition (2.3.3). After this, the distance condition (2.3.9) needs to be checked to make sure
As the distance of one segment is fixed, the braking velocity is constrained by the distance constraint
where (!!! !!! ) is known after !(!, 1) and !(!, 2) are generated. The four expressions on the
left side denote the distance the train traversed under the generated speeds and the right side is the
distance of the segment. In this equation, the unknown variables, !!! and !!! are both related to
!(!, 4) and can be represented by !(!, 4), such that the unknown variable in above equation just
!(!, 4).
Recall the integrating with respect to the distance, for the two expressions on the left side that related to
!! !
!! !!!"!!! !
!" = (!!! !!! ) (3.2.3)
!!!! !
!" = (!!!! !!! ) (3.2.4)
!! !!!!"!!! !
where ! = ! + ! sin (!! ) and ! ! = !!"#$% ! + ! sin (!! ), then rewrite them by !!
!!!! ! !! !
!!! = !!!! !" !" (3.2.5)
!! !!!!"!!! ! !! !!!"!!! !
!!!! !
!!! = !!!! !" (3.2.6)
!! !!!!"!!! !
!!!! ! !! !
!!! !! + !!!! !" !" !!! +
!! !!!!"!!! ! !! !!!"!!! !
!!!! ! !!!! ! !! !
!!!! !" (!!!! !" !") +
!! !!!"!!! ! !! !!!!"!!! ! !! !!!"!!! !
!!!! !
!!!! (!!!! !") = !!!! !! (3.2.7)
!! !!!!"!!! !
The unknown variable just the braking velocity !! , which means the switching velocity !(!, 4) from
coasting to braking is determined and needed to calculated from the above equation.
15
Genetic algorithm for the optimization of the train energy consumption
Once !(!, 4) is achieved, !(!, 5) and !(!, 6) can be calculated depending on the following
equation:
also recall the integrating with respect to the travelling time and represents it by the speeds
!! !" !!!! ! !! ! !! !
!! !!!!!"!!! !
+ ((!!!! !" !" ( !" + !! ))/!!
!! !!!!"!!! ! !! !!!"!!! ! !! !!!!!"!!! !
!! !" !!!! !"
+ !! !!!"!!! !
+ = !! !! (3.2.9)
!! !!!!"!!! !
where ! !! = !!"" ! + ! sin (!! ). Due to the continuity, !! is also known as !!!! that already
been calculated at previous segment, the unknown variable just !! and can be calculate from this
equation.
As a result of previous calculations, though we have six decision variables, the unknown just the
!(!, 2) and !(!, 3), the others are either known by previous segment or can be calculated based on
the speeds.
Define pop_size as the size of population. Based on above process, randomly generate pop_size
chromosomes as the initialized population. The initialization procedure can be described as following:
Step 1. Set i = 1.
Step 3. If ! < !"!_!"#$, set i = i+1 then go to step 2, else stop and return the initialized population.
Evaluation is a process that calculates the probability of reproduction of a chromosome that can be
selected to produce next generation and the probability is proportional to its fitness with respect to the
other chromosome in the population. Higher the fitness, more chance for the chromosome to produce
next generation. For each chromosome !! , the fitness is defined as the objective value.
Assume the chromosomes are sorted from good to bad according to their fitness value such that !! is
the fittest chromosome that has the smallest objective value and !!"!_!"#$ is the one has the largest
16
Approaching the genetic algorithm
objective value. Considering a real number ! (0,1), define the rank-based evaluation function as
following:
!!!
!"#$ !! = ! 1 ! , ! = 1,2, , !"!_!"#$. (3.3.1)
Step 3. Arrange these chromosomes from good to bad according to these fitness values.
Step 4. Calculate the evaluation values for all chromosomes according to the evaluation function
(3.3.1).
During the successive generation, only a proportion of existing population can be selected and to
produce a new generation. The selection process is though spinning the roulette wheel to select a
chromosome every time until select pop_size chromosomes. The roulette wheel is proportional to the
fitness of chromosomes, which means fitter chromosomes can have higher chance to be selected. This
Step 1. Initialize ! = 0 and calculate the reproduction probability for each chromosome
!
!! = 0, !! = !!! !"#$ !! , ! = 1,2, , !"!_!"#$ .
As we can see from the procedure that not all the chromosomes can be selected and one chromosome
Crossover operation is one of the mostly used operations to bread next generation. First, a parameter
!! (0,1) is defined to denote the crossover probability. Then for each chromosome generate a
17
Genetic algorithm for the optimization of the train energy consumption
random real number ! from [0,1], and select the chromosome !! if ! > !! . Due to this selection
process, not all chromosomes can be selected, but all the chromosomes have the same opportunity to be
odd number, we can either arbitrarily discard one of them or add an unchosen one. After that divide
!! , !! , !! , !! , , (!!!! , !! )
For the six decision variables, ! !, 1 , ! !, 5 , is defined by previous segment and ! !, 4 , !(!, 6)
are calculated according to the first three decision variables. In the sake of continuity, the crossover can
be just applied on !(!, 2) and !(!, 3), which are leaving speed and cruising speed. However, if we
applied the crossover for !(!, 2) and !(!, 3) at the same time, it is possible that the result is
infeasible with respect to the constraint (2.3.9). As a result of it, we just crossover the !(!, 2) and
Denote the children of parents (!! , !! ) as (!! , !! ). For each segment, generate a random real number
these variables to calculate (!! !, 4 , !! !, 5 , !! (!, 6)) and (!! !, 4 , !! !, 5 , !! (!, 6)) to satisfy
constraint (3.2.7) and (3.2.9). Finally, choose the best two chromosomes according to the objective
Step 1. Choose pair of parent chromosome (!! , !!!! ) and randomly generate a real number
!! (0,1).
Step 2. Generate the children of them that are (!! , !!!! ). For 1 ! !,
!! !, 2 = !! !! !, 2 + (1 !! ) !!!! !, 2
!!!! !, 2 = !! !!!! !, 2 + (1 !! ) !! !, 2
Step 3. Randomly generate !! (!, 3) and !!!! (!, 3) according to condition (2.3.3).
Step 4. Calculate the (!! !, 4 , !! !, 5 , !! (!, 6)) and (!!!! !, 4 , !!!! !, 5 , !!!! (!, 6)) according to
Step 5. Choose the best two chromosomes among (!! , !!!! , !! , !!!! ) as next generation. Set i = i+2.
18
Approaching the genetic algorithm
Figure 3.2. The basic crossover
Suppose !! is the lower speed between two parents and !! is the high speed one of two parents. As
the figure illustrates, the speed of two parents are weighted by coefficient ! and the range of
Under this crossover method, the speeds of children are constrained by their parents, but a better
solution may exist beyond of the speed range by having a lower speed or a higher speed than both
parents. Also, as one of parent may have a good speed profile for some of segments and a bad speed
profile for the remaining segments and the other parent has an opposite situation, a swap between the
pair of parents can be considered. Due to these considerations, we have proposed several improvements
Denote the two parents according to their speed value as !!"#$ , !!"#$ . For the improved crossover, we
consider enlarge the speed range of the parents by replacing the !!"#$ (!, 2) by (!!"#$ !, 2 +
!!"#$ !, 2 !) and !!"#$ (!, 2) by (!!"#$ !, 2 !!"#$ !, 2 !). As a result of it, the generated
19
Genetic algorithm for the optimization of the train energy consumption
Step 1. Choose pair of parent chromosome (!! , !!!! ) and randomly generate a real number
Step 2. For 1 ! !, define the fast parent !!"#$ (!) and the slow parent !!"#$ (!).
!! !, 2 = !! (1 !)!!"#$ !, 2 + (1 !! ) 1 + ! !!"#$ !, 2
Step 4. Randomly generate !! (!, 3) and !!!! (!, 3) according to condition (2.3.3), if the new
generated speed satisfy the condition (2.3.3) go to step 5, else regenerate !! and go to Step 3.
Step 5. Calculate the (!! !, 4 , !! !, 5 , !! (!, 6)) and (!!!! !, 4 , !!!! !, 5 , !!!! (!, 6)) according to
Step 6. Choose the best two chromosomes among (!! , !!!! , !! , !!!! ) and select them as next
As for step 4, we may consider to decrease the new generated !! (!, 2) and !!!! (!, 2) instead of
regenerate !! to reduce the calculation when the new produced speed is infeasible with respect to
condition (2.3.9). Choose a proper coefficient ! will efficiently improve the fitness of produced
chromosome because of increasing the range of search field for the chromosome.
Another way to get though the local optimal induced by the basic crossover method is what we called
mutate-like crossover, which is used more like mutation of chromosome instead of crossover. As the
value of optimal solution may occur around one of the parents, the combination of two parents
somehow may restrict range of the search field such that we consider generate the two children based
on different parent. After we choose a pair of parents, fitter chromosome will be denoted as good
parent and the other that has larger objective value will be denoted as bad parent. Then, a range
coefficient ! (0,1) will be defined to decide the range of field centered on the speed of one parent
that used to generate the child. At last, the next generation will be chosen among the parents and their
children.
20
Approaching the genetic algorithm
Step 2. Choose pair of parent chromosome (!! , !!!! ) and randomly generate a real number !! (0,1).
Step 3. Define the good parent !!""# and bad parent !!"# according to their objective value.
Step 4. Generate the children of them that are (!! , !!!! ). For 1 ! !,
!! !, 2 [ 1 ! !!""# !, 2 , 1 + ! !!""# !, 2 ]
Step 5. Randomly generate !! (!, 3) and !!!! (!, 3) according to condition (2.3.3).
Step 6. Calculate the (!! !, 4 , !! !, 5 , !! (!, 6)) and (!!!! !, 4 , !!!! !, 5 , !!!! (!, 6)) based on the
Step 7. Choose the best two chromosomes among (!! , !!!! , !! , !!!! ) as next generation. Set i = i+2.
Another situation is that the chromosome may have good speed profile for different parts of section
that can be improved by swapping the speed profile between two chromosomes. In order to preserve
the feasibility, the swap needs to be applied when the speed between two chromosomes is the same at
segment !. After the swap, the time shift affected on the segments need to be fixed.
21
Genetic algorithm for the optimization of the train energy consumption
Step 2. Record the segments where the chromosomes have the same velocity into ! such that
! = ! !! !, ! = !!!! !, ! , 2 ! ! 1, ! = 1,2,3}.
!! ! !" 2 ! !
!! =
!!!! ! !" ! < ! ! 1
!!!! ! , !" 2 ! !
!!!! =
!! ! , !" ! < ! ! 1
Step 7. Choose the best two chromosomes among (!! , !!!! , !! , !!!! ) and select them as next
This method can largely decrease the running time for the algorithm due to the preservation of
feasibility, but as the generation increasing, the chromosomes get more and more similar, the efficient
All the crossover methods mentioned before, in principle we can divide them into two kinds. The basic
crossover, improved crossover and mutate-like crossover are focus on crossover within one segment;
on the other hand, the swap method is concentrated on crossover within the whole segments. To
22
Approaching the genetic algorithm
improve both the methods and also decrease the calculation, an adaptive crossover is considered.
The adaptive crossover operator we used takes both the improved crossover method and the swap
crossover method. At beginning, a real integer number will be randomly generated to choose the
crossover operator and then depending on the performance of these two operators, a bias should be
Step 3. Randomly generate a real integer number ! [50,50], then add the bias ! = ! + !"#$.
Step 4. If ! < 0, choose the improved crossover operator, else choose the swap operator. Generate the
As the goal of all the operators is to increase the fitness of chromosomes and achieve an optimal
solution, which will somehow make the chromosomes have more or less the same speed profile. After
the crossover, we may have some duplicate chromosomes and with the increasing of the generation, the
number of duplicate chromosomes will also be increased. More duplicate chromosomes, less efficiency
the crossover operator, so the diversity control operator is applied to keep the diversification among the
chromosomes.
Select the most fitness chromosomes as elitisms and denote the set of elitisms as !!"#$#%& and the
!(!), which defined as the average hamming distance from ! to the elitisms !!"#$#%& .
!
!(!) = !! !!"#$%#$& (!, !! ) (3.6.1)
!!"#$#%&
Then, the evaluation of the chromosome, biased fitness, !"(!) of a chromosome ! is defined as the
sum of rank !"#(!) of ! in the subpopulation with respect to objective value !"#$(!) and its rank
23
Genetic algorithm for the optimization of the train energy consumption
!"(!) related to diversity contribution !(!) and depends upon the actual number of chromosomes
!"#$ in the subpopulation. The ration between the number of elitisms !!"#$ and number of
!"#$%
!" ! = !"# ! + (1 )!"(!) (3.6.2)
!"#$
The population generated before the crossover is denoted as !"# and the population produced after the
crossover is denoted as !"#. The local diversity control is considered the number of elitisms is fixed as
Step 1. Eliminate the duplicate chromosomes in (!"# + !"#) and sort the remaining chromosomes !
Step 3. Calculate the diversity contribution and bias fitness of the chromosomes in the subpopulation
(! !) and sort them by their bias fitness such that the fittest chromosome will be rank first.
Step 4. Select (!!"_!"#$ !) chromosomes in the subpopulation based on their bias fitness rank.
For the global diversity control operator, the elitism is changed whenever a new chromosome is
chosen.
Step 1. Eliminate the duplicate chromosomes in (!"# + !"#) and sort the remaining chromosomes !
Step 3. Calculate the diversity contribution and bias fitness of the chromosomes in the subpopulation
Step 4. Select the fittest chromosome into the elitism and set ! = ! + 1.
24
Approaching the genetic algorithm
Mutation is another important operator used to update the chromosomes. First we need define a
parameter !! (0,1) to denote the probability of mutation, and then choose chromosomes to breed
The new chromosome is obtained by mutated the cruising speed of the old chromosome.
! !, 3 = ! !, 3 + !!"# (3.7.1)
! !, ! = ! !, ! ! = 1,2 (3.7.2)
where !!"# is the mutation value and define the range of the mutation of cruising speed. Then
calculate the ! !, 4 , ! !, 5 , !(!, 6) according to the new speeds. Note that the mutated cruising
speed can be infeasible with respect to the condition (2.3.9) and we should decrease the mutated
and update !! .
In this method, the mutation is applied on one of segments of chromosome. For each selected
chromosome !! , set !! = !! , then randomly generate a segment index ! (1, !). If the segment ! is
station, we randomly regenerate the dwell time !" (!"!"# , !"!"# ) for the station and set
25
Genetic algorithm for the optimization of the train energy consumption
!! !, 6 = !! !, 6 !! !, 6 !! !, 5 !" , !" ! !
(3.7.3)
!! !, 5 = ! !, 5 !! !, 6 !! !, 5 !" , !" ! > !
If the segment ! is a nonzero speed limit segment, we randomly regenerate the cruising speed and
leaving speed for the segment ! and recalculate the !! !, 4 , !! !, 5 , !! (!, 6). Then for the segment
!! !, 6 = !! !, 6 !! !, 6 !! !, 5 !! !, 6 !! !, 5 , !" ! !
(3.7.4)
!! !, 5 = !! !, 5 !! !, 6 !! !, 5 (!! !, 6 !! !, 5 ) , !" ! > !
Step 3. If ! !! , generate a random segment index ! (1, !) and update the chromosome !! .
3.8 Regeneration
Due to the successive generation, the chromosomes will become more and more similar, even though
we have diversity control for every generation, the homogenization still cannot be avoid and difference
between chromosomes keep reducing will leads to the decreasing of efficiency of crossover and
mutation. In order to regain diversity after some certain generations, regeneration operator will be
introduced.
We consider eliminate the duplicate chromosomes then sort the chromosomes according to their fitness
Denote the population after mutation as !"#. The general process for the regeneration can be
described as follows:
26
Approaching the genetic algorithm
As the time constraint is used to constrain the running time between two stations and the other
constraints are just used for one segment, in order to meet the time constraint, all the segments between
two stations are need to be adjusted. As a result of it, instead of to separately consider time constraint at
each segment, we consider it as a constraint for the whole chromosome by consider it after the
Even though the chromosomes are satisfied with all the other constraints, they still can be infeasible
with respect to the time constraint so except for the speed and distance constraints, a local search
method should be used to make them feasible when considering the time constraint.
There are two situations for a chromosome to be infeasible, one is arriving late for the predefined
timetable and the other one is arriving early with respect to the timetable. And the adjustment for the
The general process for the local search can be summarized as follows:
Step 1. Set ! = 1, ! = 2, ! = ! ! 1 + 1.
Step 3. If the arriving time !! (!, 5) still smaller than the predefined timetable !!"#$ or larger than
step 2.
Step 5. If the arriving time !! (!, 5) still smaller than the predefined timetable !!"#$ or larger than
!!"#$ , if !! !, 2 < min (!! , !!!! ), go to step 2, else if ! < !, set ! = ! + 1, go to step 2.
Otherwise go to step 6.
Step 6. If the arriving time !! !, 5 is feasible with respect to the time window [!!"#$ , !!"#$ ] and
27
Genetic algorithm for the optimization of the train energy consumption
Step 7. If the chromosome is feasible with all the arriving times related to each stations, Stop.
As several loops are used to achieve the feasibility, the cost of time is high.
After evaluation, selection, crossover, diversity control and mutation, a new population is generated.
However, the genetic algorithm wont stop until a certain number of iterations have been implemented.
The general procedure for the genetic algorithm can be summarized as follows:
28