| Main
Results
Tour
Fitness
Download |
Genetic Algorithms
A practical Approach with
the example of the
"Travelling Salesman"
Genetic Algorithms are used where deterministic
ones fail - or just for fun. This practical approach shows the example
of the travelling salesman. Given a set of say 20 cities and the distances
between, what's the fastest tour to reach all destinations? Not simple
with a procedural approach... However, a genetic algorithm solves this
in a few seconds.
The program presented here is written
in C (by R. Cattin) and can be
adapted to other problems. A example set of 20 cities was chosen with random
coordinates in the range of 0..1. The initialization of the program generates
100 random tours through this 20 places. This tours are then improved over
200 generations. The improvement is acheived by crossover, selection and
mutation. Selection is done by a random roulette-wheel function according
to the fitness of the tours. The fitness of a tour corresponds to the distance
to travel, of course.
And: It's not all written here, explore
it!
| Results |
Result tables of a Travelling Salesman
example. |
| Tour |
Shows tour through the 20 cities (random
tour and improved by genetic algorithm). |
|
|
Shows how the distance the salesman has
to travel develops over time (corresponds to the fitness of the population). |
| Download |
Download all you like of this demo. |
Extension of the course "Neuronal
Networks" thought by W. Businger
at the University of Applied Sciences Biel (HTA
Biel). Notice that the example program in C is written and copyrighted
by R. Cattin, Professor at HTA
Biel.
|
|