genetic algorithms in solving railway traffic control conflicts
DESCRIPTION
The railway traffic control is a complex problem evenwith the current technical progress. The usage of genetic algorithmsis perfect in dealing with resource conflicts and optimizationof the time resource because they provide the best routes forthe train with every new generation.The first step in developing the algorithm is encoding the resourcessuch as parts of the railway into chromosomes. Theseform the current population. The next populations are obtainedby mutation or crossover. The selection of the individuals for thenext generation is based on a fitness function and on the elitismmethod. After 100 generations the process stops if the solutions fitthe imposed expectation.The results obtained through simulations show the best solutionfor the train routes and the eligibility of the genetic algorithm.TRANSCRIPT
Genetic Algorithms
in solving railway traffic control conflicts
Ioana Vidrasan, Tiberiu Letia supervizor
Technical University of Cluj-Napoca
Automatics Department
Abstract: The railway traffic control is a complex problem even
with the current technical progress. The usage of genetic algo-
rithms is perfect in dealing with resource conflicts and optimiza-
tion of the time resource because they provide the best routes for
the train with every new generation.
The first step in developing the algorithm is encoding the re-
sources such as parts of the railway into chromosomes. These
form the current population. The next populations are obtained
by mutation or crossover. The selection of the individuals for the
next generation is based on a fitness function and on the elitism
method. After 100 generations the process stops if the solutions fit
the imposed expectation.
The results obtained through simulations show the best solution
for the train routes and the eligibility of the genetic algorithm.
I. INTRODUCTION
The railway traffic control remains a problem even with the
progress registered in the train manufacturing technologies.
Therefore the developing of new, better, optimal algorithms is
an important issue.
Genetic algorithms are based on the evolutionist theory and
medical genetics. In the IT field these algorithms are used in
the evolution of programs or in optimizations.
The basic components of a railway track are: lines, sema-
phores, train detectors, switches and station’s platforms. In
order to control the train traffic there must be a fixed train’s
schedule. This schedule is usually made by the train dispatcher
or by trains itself, if they are controlled using collaborative
algorithms. Switches are used to change the line. The portion in
which the switch decision must be made is an interlocking.
The railway structure proposed for solving contains 2 train
stations with 4 platforms each, 12 sensors, 24semaphores. The
stations are connected by 2 lines. The four trains are displayed
like in fig. 1. The resources used by the trains are the lines R1-
R10, platforms from P11-P14 and P21-P24, interlocking I0, I1,
I2, I3, train detectors D1-D10. The control is realized throw the
semaphores S1-S20 and the switches. But still the most im-
portant resource remains time, which will be the factor that will
be determining the validation of a solution. The simulation
time will be 100 time units corresponding to an hour.
Each train has specifications and a task. The specifications
referring to speed are the same for each train. The time needed
by a train to cross a resource is posted in fig.1 on each corre-
sponding resource and there are also train detectors, sema-
phores for both ways of the line, platforms and interlocking.
Figure 1. Railway station structure.
The train tasks are enumerated below:
a) T1 leaves from station1 P11 to station2 P23.
b) T2 leaves from station1 P13 to station2 P22.
c) T3 leaves from station2 P22 to station1 P14.
d) T4 leaves from station2 P23 to station1 P13.
The train specifications are:
a) T1 leaves at 0 time units, arrives at 23.
b) T2 leaves at 23 time units, arrives at 65.
c) T3 leaves at 10 time units, arrives at 40.
d) T4 leaves at 30 time units, arrives at 50.
II. “STATE OF ART”
The problem of generating a safe, effective and optimum so-
lution for controlling a train railway was in the attention of
many researchers.
In the book “Railway Operation and Control”, Joern Pachl
comprehends the basic principles of train traffic control and
railway operations. Also he describes the components of the
railways and their optimum usage, like switches, semaphores,
interlocking and others.
There are plenty articles relating to the optimization of the
railway in the presence of disturbances, like in [6] where the
solution are formed in such a manner in which even if disturb-
ances appear, the overall process remains constant. The optimi-
zation algorithms used by them are Simulated Annealing and
Tabu Search.
P.J. Fleming [2] talks in his studies about the complexity of
genetic algorithms and their usage in combinational problems.
In his work GA are providing a multiple, “Pareto-optimal solu-
tions” for controlling off-line systems.
The problem of finding a suitable route for trains is similar
with the problem of The Travelling Salesman using Genetic
algorithms. This problem is discussed and solved by K. Bryant,
in his article [7] and by Randy L. Haupt, Sue Ellen Haupt in
their book [8]. The salesmen travel into a specific number of
cities and the GA searches for the shortest route in which they
can stop by once in every city.
There are a few routes from which the salesman can choose
from. The optimum solutions seem to be given by applying
genetic algorithms after 300 generation if the number of cities
is 5 so that the chromosome is formed by 5 genes, one for each
city. The information contained in the genes can be in the for-
mat of bites 0 and 1 or the a value which can represent the or-
der in which they go in the cities.
Figure 2. The UML Class Diagram.
III. THE GENETIC ALGHORITHM
In G.A the basic unit is the chromosome. The chromosome
is composed by genes and each gene contains specific infor-
mation about one feature of the individual. The initial popula-
tion contains 40 individuals coded in chromosomes. In each
new population the weakest chromosomes will be left out.
The algorithm is implemented like in fig. 2; it will imple-
ment the railway structure and simulate it by using the future
population class and by having the confirmation from the Fit-
ness class.
The steps of elaborating the algorithm are: encoding of the
chromosome, selection of individuals for generating offspring,
forming the new generations by crossover and mutation, usage
of the fitness function to determine the strength of a population
to form a solution.
A. Encoding
As specified by M. Obitko [5], there are 4 ways in encoding
a chromosome: binary encoding, encoding by permutations,
encoding by value or tree encoding. The most common method
is binary encoding, in which the chromosome is just a string of
bites. But for this problem the information needed for generat-
ing a train route is very difficult to implement in one bit.
Therefore the encoding method used will be value encoding.
The chromosome contains information regarding the route of
all the trains. It will be composed of 0-9 digits which represent
the additional time a train needs to cross a resource, line or
platform. The interlocking will be implemented in the chromo-
some because it will be useful in simulating a train route. The
interlocking introduces a delay of 1 period of time, if used.
TABLE I
EXAMPLE OF A CHROMOSOME Chromosome1 (Ch.1) Parts
Values of the resources P11, .., P24, R1, R2, R3, …, R10, I1,I2,I3,I4
Ch.1 T1 1 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 2 1 2
Ch.1 T2 0 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 1 1 1 2
Ch.1 T3 0 0 0 1 0 1 0 0 0 0 0 1 0 1 1 2 2 2 1 1
Ch.1 T4 0 0 1 0 0 1 0 0 0 5 0 0 1 0 0 0 1 1 2 1
As a result the chromosome will be formed of 4 string val-
ues, each containing the resource allocation for a train. Even if
one train doesn’t use a resource the chromosome will still con-
tain a gene for that resource. They will be like recessive genes,
genes which don’t contain useful information for the current
solution, but after mutation or crossover maybe they will be
forming a solution for the problem.
The delays that compose the chromosome are justified by the
fact that in a real context the train needs to decrease the speed
when they switch resources.
MainClass
+ArrayList Pop;+Simulator S;
+main(String[] args)
Chromosome
+ArrayList Pop
+setCr()+getCr()+getCrTrain()
NextPopulation
+ArrayList popUrm
+setPopUrm()+getPopUrm()+NextPopulation()
Simulator
+ArrayList popUrm;
+run()+showResults()
Semaphore
+state
+getState()
Fitness
+int fit
+Fitness(Chromosome Cr)
TrainGUI
+
+showResults()+initGUI()
Thread
+run()
Structure
Interlocking
+Switch S1;
+getRoute()
Switch
+getPosition()
B. Selection
There a four selection methods: Roulette selection, Rank se-
lection, Steady-State selection and Elitism selection. The Rou-
lette selection picks the chromosomes with the higher Fitness
function and orders the descending so that the first chromo-
some is the one with the higher fit.
The rank selection is somehow similar with the previous
method but now the chromosomes receive a rank. The chromo-
some with the higher fit will be first rank and the second fitted
for the solution will be rank two, and so on.
Steady-State selection is a method in which a part of the
weak chromosomes are replaces by the ones that have the
higher Fitness function.
In the Elitism selection some of the best and fittest chromo-
somes are copied in the next population.
The selection of the chromosomes is important because it
prevents weak chromosomes to be selected for the next genera-
tion. The methods used are Selection by rank and by elitism.
The method used for selecting the best train route will be
Elitism selection combined with rank selection. So the best
solutions won’t be lost in the new generation, they will be cop-
ied as they are. For creating the offspring only the highest rank
chromosomes will be selected for mutation and crossover. So
the resulting population should be better with each new genera-
tion, like in nature only the strongest survive.
Figure 3. The weight of chromosomes after selection by rank. [5]
C. Crossover and Mutation
In genetics there are 2 ways of obtaining new individuals:
crossover and mutation. Mutation appears when an individual
suffers a transformation which alters one of its genes, making
him a new individual with a new genetic inheritance. Crossover
is a process that involves 2 individuals. By mixing their genes
they give birth to new individual with a new genetic inher-
itance. The survival of the new individual depends of the
strength of their characteristics. So the algorithm will try to
simulate the natural behavior of life, creating new and better
solutions for our problem.
1. Mutation
This process requires one individual and the used method
will be “One point mutation”. Only one gene of the chromo-
some will be altered.
The selection of the characteristic that will be changed is
done random. In the random mutation point we increase or
decrease the value of that bit.
But there are a lot of limitations that need to be taken into
account. If the respective gene is corresponding to the inter-
locking then the value isn’t allowed to be outside the interval
[1, 3], because there aren’t other solutions for a train route.
Also if the gene corresponds to a train resource can’t have a
negative value and if the value is bigger than 9 the program
will throw exceptions because by default the maximum value
for a delay shouldn’t be more then 9.
The algorithm has the following steps:
1. get current population as ArrayList;
2. initialize random=Random_Number, mutPt;
3. initialize a new chromosome ch1,newPop;
4. for (i=every chromosome)
5. mutPt=1+random(ch_length);
6. val=mutPt;
7. if (mutPt is interlocking)
8. if(mutPt in [1,3])
9. val-=val;
10 else val+=val;
11. else // point corresponds to a resource
12. if(mutPt in [3,9])
13. val-=val
14. else val+=val;
15. end if;
16. ch1=chromosome[i-1].substring(1,mutPt-1)
+ val + chromosome[i-1].substring(mutPt+1,ch_length);
17. nexPop.add(ch1);
18. end for;
19. return newPopulation
2. Crossover
This process requires 3 individuals from the current popula-
tion. The birth of a new individual is done by combining the
information in 3 consecutive chromosomes. The selection of
the information for the offspring is provided random in 2
crossover points.
Figure 4. Example of two point Crossover.
The conditions that result from the chromosome type refer to
positions of the crossover points. These points need to be dis-
tinct and ordered ascending so that there won’t be any prob-
lems in selecting the part of the chromosome for creating a new
solution.
The algorithm has the following steps:
1. get current population as ArrayList;
2. initialize random=Random_Number, crossPt1, CrossPt2;
3. initialize a new chromosome ch1,nextPop;
4. for (i=every chromosome)
5. crossPt1=1+random(ch_length/3);
6. crossPt1=ch_length/3+random(2*ch_length/3);
7. ch1=chromosome[i-1].substring(1,crossPt1)
+ chromosome[i].substring(crossPt1,crossPt2)
+ chromosome[i-1].substring(crossPt2,ch_length);
8. nexPop.add(ch1);
9 . end for;
10. return nextPopulation
D. Fitness Function
The fitness function is the mechanism used for determine the
strength of a solution based on a mathematical model like in
formula (1). This function will be applied to each new genera-
tion in the selection process in order to separate the weak solu-
tion from the better ones. So the fastest route will be consid-
ered as the best solution.
Each branch of the chromosome contains the cost of using a
resource ( ) There are 4 trains in our system and 20 re-
sources represented in the chromosomes. The cost represents
time in this case. The Fitness function accumulates all these
costs for each train.
Only the Fitness function isn’t enough for determine if an
individual is solution for controlling the trains. By simulating
the route generated by the algorithm it becomes more obvious
if the trains are in collision at a moment of time. If two train
routes are in collision then the value of the Fitness function
will be increased by 100 which represent penalties for a solu-
tion as the collision cost: ( ). If one train doesn’t accomplish its task and specification
there will be more penalties added to the Fitness function. As
an example, if one train arrives 2 time units later then its spe-
cific time then the value of the Fitness function is increased by
2 as in the delay cost ( ). The formula for the Fitness function used in implementation
is:
( ) ∑ ∑ ( ) ( ) ( )
(1)
IV. RESULTS
The results of applying the genetic algorithm are established
by simulating the train behavior. In this purpose the simulator
will determine the train behavior in a time stamp of 1 minute,
in a total simulation time of 50 time units, not 100 as planned
and expected. Each train must respect its specifications and
task. But if there isn’t any solution for the required specifica-
tions then the best fitting solution will be accepted as a solution
for the problem.
After 100 new generations the best result for scheduling the
trains is the individual with the genes:
100001001101010000101000010010000010100101010000101
000000101010101001000100000101011100.
The Fitness function for the solution is 30, there are no de-
lays for any train and there are no routes in conflict. So the
only parameters in the function were the resource delays with
the maximum value of 1. That means that the trains will have
to switch relay fast between lines and platforms, without reduc-
ing to much the speed. The total time that trains need in order
be reach their destination is total 73 and for each train:
a) T1 needs 28 minutes to reach P22
b) T2 needs 25 minutes to reach P23
c) T3 needs 26 minutes to reach P14
d) T4 needs 24 minutes to reach P13
As a result each train respects its specifications and accom-
plishes its task. The resources P12, P21, P24, R3 and R8 are
never used, they are recessive genes. The most used resource is
the line R4.
TABLE 2 THE OCUPATION OF THE RESOUCE WITH THE CURRENT SOLUTION
re-
source
s
/
Trains
P
1
1
P
1
3
P
1
4
P
2
2
P
2
3
R
1
R
2
R
4
R
5
R
6
R
7
R
9
R
1
0
I
0
I
1
I
2
I
3
T1
2 0 0 2 0 3 3 6 0 8 0 0 0 2 0 2 0
T2
0 2 0 0 2 0 0 6 0 8 0 3 0 2 0 2 0
T3
0 0 2 2 0 0 0 0 5 0 7 3 3 0 2 0 2
T4
0 2 0 0 2 0 0 6 0 0 7 0 3 2 2 0 0
The train schedule can be adjusted so that even if the train
has some minor delays due to perturbations, weather forecast
or some unpredictable events that can take place in real life, it
will still reach its destination in time.
Figure 5. The resultant train routes.
As in fig. 4 the each train has one unique route. There are no
collisions between trains, the resultant intersection figured
above represent parallel resources.
V. CONCLUSIONS
Even if the algorithm continues after 100 generations the
probability that the solution fits better the specifications re-
mains constant. The fitness function remains constant.
There are enough 48 time units of time to determine a route
with these specifications. So we can double the time a train
reaches its destination, in order to prevent further delays which
can cause all the other trains to miss their destination or to wait
for a resource to be released.
In some cases there isn’t enough to generate 100 new gener-
ations in in GA, because the processes require more precision.
So the algorithm can continue to generate new individual solu-
tions for infinity, depending on the computational power of the
equipment. It is proven that the probability of a solution with
better fitness function increases insignificant after approxi-
mately 300 generations.
REFERENCES
[1] Joern Pachl, “Railway Operation and Control,” VDT Rail Publishing Mounthlake Terrace USA, Rochester WA, April 2002.
[2] P.J. Fleming, R.C. Purshouse, Genetic algorithms in control systems
engineering, Shefield UK, 2001. [3] A. Haxthausen, J. Peleska, “Formal Development and Verification of a
Distributed Railway Control System”, 2000 IEEE.
[4] R. BORND¨O RFER, THOMAS SCHLECHTE, “Solving Railway Track Allocation Problems”, 2007.
[5] Marek Obitko, “Introduction to Genetic Algorithms”, 1998.
[6] J. Törnquist, J. A. Persson, “Train Traffic Deviation Handling Using Tabu Search and Simulated Annealing”, Hawaii International Conference
on System Science,2005.
[7] K. Bryant, A. Benjamin, “Genetic Algorithms and the Traveling Sales-man Problem”, December 2000, department of Mathematics.
[8] Randy L. Haupt, Sue Ellen Haupt, “Practical Genetic Algorithms, second
edition”, jul 2004