Вы находитесь на странице: 1из 6

Genetic Algorithms

The survival of the fittest

Israel Lpez Vallejo


Escuela Superior de Tecnologa y Ciencias Experimentales
Universitat Jaume I
12071 - Castelln de la Plana, Spain
israel.lopez@uji.es

AbstractThis paper is a short report of the research done This is the main reason why genetic algorithms are
about genetic algorithms and evolutionary computing. Genetic sometimes the only way to solve problems in several areas, even
algorithms are adaptive methods that can be used to solve that is not guaranteed the solution is the optimum, it will be an
searching and optimization problems. They are based on the acceptable solution in a smaller amount of processing time in
genetic process of organic being, where only the fittest will succeed comparison with the other algorithms.
in surviving.
A. Simple Genetic Algorithm
In this research the fittest survivors will give the best results in The basic steps of a genetic algorithm are [1]:
the problems that will be studied: travelling salesman best route
and Crawling Behavior for a Humanoid Robot. Evaluate the score of each of chromosomes generated.

KeywordsEvolutionary computing; Crawling behavior; Allow reproduction of the chromosomes, the fittest units
Crossover; Chromosome Modification; Fittest; Genetic algorithms; will have more probability to reproduce.
Mutation; Population; Robot Nao; Traveling salesman route. With a certain probability of mutation, the mutation will
happen to a gene of the new generation.

I. INTRODUCTION Arrange the new population.


In nature, the organic beings of a population compete with Fig. 1 shows a diagram of the steps, which will be repeated
each other in the obtaining of resources such as water and food; until a condition of termination is reached. It can be set to a
and a partner. Those who are successful in surviving and finding maximum number of iterations before finalizing the genetic
a partner have more probabilities in obtaining offspring. On the algorithm or until no more changes occur in the population
other hand, those who were not able to succeed will have a (convergence of the solution). The latter option is usually the
smaller amount of offspring. This means that the genes of the most common stopping criteria.
fittest beings will spread to the next generation. The combination
This is the pseudo-code of a generic genetic algorithm:
of the good qualities from those parents, could create an
extraordinary descendent, who will have superior capability to Generate initial population;
adapt to the environment, thus the species evolve and adapt
better to the environment where they live. Evaluate population;

Genetic algorithm are based on a similar analogy to the While (!stopCondition) do:
natural behavior. The way they work is simple, there is a Select best fit individual for reproduction;
population of units, where each of these units represents a
Breed new individuals through crossover and mutation;
solution to solve a given problem. Each of these units has some
qualities like a punctuation related to the solution of the problem, Evaluate fitness of the new individuals;
the equivalent in nature to this is the effectiveness of the organic Replace least-fit population with new individual;
being able to compete successfully for resources. The more fit
the being, the more probabilities to reproduce. This way there is Return solution; [2]
a new population of solutions that will replace the latest
solutions, this means that if the algorithm has been well
programmed. With an small amount of generations the
algorithm will converge to the best solution for the problem in
relation to the amount of generations that are produced. The
more generations there are, the more accurate the result will be
(this isn't always is true, but most of the times is it).
other neurons. The hidden layer has five neurons that processes
and transforms the data into information. Finally, the output
layer has one output neuron which returns the information.
2) Operators: the role of operators is to create new
individuals from the old generations. This means that new
solutions are created. In order to generate new individuals, the
following operators are available:
Mutation: a unary1 variation operator, it is applied to
one genotype randomly and produces a new individual
modified, a mutant. The mutation rate is between
1 1
and . The Fig. 2 shows an example of

mutation in a binary string.
Recombination: also called crossover, this operator
merges information from two parent genotypes into one
or two offspring genotypes. The Fig. 3 shows an
example of crossover in two binary strings and its
offspring.
Selection: Once each chromosome is evaluated and
obtained, the score of a new population has to be
created considering that the good traits of the best are
transmitted to the next generation. The selection can be
done with the Roulette wheel2 mechanism. The Fig. 3
shows an example of simple selection in the population
through generations.
B. Advantages and disadvantages
The reason why genetic algorithm succeed and still an
interesting field of investigation are [3]:
Simple concept: the idea its easy to understand.
Multi-objective optimization: allows to obtain an
Figure 1: Diagram of genetic algorithm (GA) optimal decision that takes in presence more than one
objective.
Answer guaranteed: the more time an answer is
1) Parameters: The behavior of the algorithm can be
processed, the better it will be.
manipulated depending on the use of the following parameters:
Knowledge memory: the acquired knowledge speeds
Population: the amount of chromosomes in the
up and improves the algorithm.
population in one generation.
On the other hand there are disadvantages, which are:
Crossover: the probability for the crossover to be
performed. If there is no crossover, offspring is an exact Implementation issues: basic aspects of
copy of parents. If there is a crossover, offspring are implementation are difficult to set, such like choosing
made from parts of parents chromosome. the right representation, population size, mutation rate,
accept and reject policies, etc.
Mutation: probability of parts of the chromosome being
mutated. If there is no mutation, offspring are taken after Termination criteria: its difficult to tell when to stop.
crossover without any change (thus theres no
improvement in the generated solution). If mutation is Performance: even that algorithm gains experience, the
performed, part of chromosome is changed. performance stills a complex matter to improve.

The Fig. 1 shows a classic neural network model with input, Evaluation function dependence: if the function is not
hidden and output layer. The input layer has four data inputs, the the right one, the whole result will not be correct.
neurons that receive the data and the connections (weights) to

1 2
An operator is unary if it applies to one subject as input. We spin the wheel and when it stops we select the
corresponding chromosome. Obviously, the best individuals
get higher chance.
II. PROBLEM RESOLUTION
In the research two problems have been studied, one for the
classical travelling salesman best route and Crawling Behavior
for a Humanoid Robot. Now, the process and the algorithm used
to reach a solution will be explained.
A. The Traveling Salesman Problem
This problem consists in a salesman who has to travel around
a given amount of cities with minimum cost, visiting each city
only once and finishing in the same city where he started. In this
problem a list of 48 cities is given.
Figure 2: The before and after in a binary string when a The chromosomes are coded like an array of cities, where
mutation takes place each city will be visited by the agent, it can not contain a
repeatition of a city.

City 1 City 2 City 3 City 48

Parameters information:
Population size: 80 individuals
Number of generations: 10000
Mutation rate: 2%
Crossover rate: 100%
With this configuration, the algorithm is executed and the
results are exported in a database, which will be used to plot the
results. The Fig. 5 shows the results of the evolution process:
Figure 3: The process of the crossover between two parents
and the resulting offspring

Raw score: error bars Fitness score: error bars

Raw score: Max/min/avg/std Fitness score: Max/min/avg/std


Figure 4: The selection process guarantees a new generation
formed by the fittest individuals

1) Applications: some of the uses genetic algorithm have


are related to the optimization and automation of processes [4]:
Automation: design of mechatronic systems, industrial
equipment, trading systems.
Bioinformatics: multiple sequence alignment, structure
prediction, chemistry.
Engineering: mechanical design, electronic designs,
security systems. Figure 5: Raw and fitness result graphs
The final best individual gives the following route shown in Fig. 7 shows the schema of Naos left arm with its joints
the Fig. 6 as the optimum way to visit all cities with less cost: represented as oscillators, these are the oscillators that is
necessary to give values (always between a fixed maximum and
a minimum) so Nao can simulate the crawling of a baby.

Figure 6: Optimum solution to visit all cities with less cost


Result analysis:
Good results have been obtained. The difference between the
best and worst fitness is small, whereas the evolution increases
the difference is minimal reaching to stabilize in latest
generations. As the number of generation increases, the average
adaptation is bigger and closer to the best individual.
Comparing these results with other solutions from the
internet, confirms that even though it is impossible to obtain the
exact solution, the ones that are generated by the algorithm are
approximate enough to be considered as the accurate. In order to
improve the results, other parameters have been used as a trial
and error test, but like its been said in the advantages and
disadvantages section, its difficult to find the right parameters Figure 7: Naos left arm joints
without doing some tests first to confirm that generated results Applying these oscillations to each joint, a crawling gait
are correct. can be developed and tested with the simulated humanoid NAO
Google has developed a solution to solve the problem using [6].
Google Directions API [5]. The idea to solve the problem is to prepare a function that
transforms the given values into the range on degrees for the
joints of the robot, so the combination of all these oscillations
B. Crawling Behavior for a Humanoid Robot generated by the algorithm mimics the crawling of a baby.
The task to do is make the Nao robot crawl like a baby would The values of the joints array are not normalized, so its
do using genetic algorithm. The crawling action can be necessary to do it, so the values that the evaluation function3 will
decomposed into a sum of oscillators. This sum can be use are between 0 and 1. The normalization function is:
represented by the following expression:

= ( ) +
2
() = + sin ( + ) , Where:

=1 : element from genome list
Where N is the number of frequencies, C is the offset, : the max value for each joint
An=1..N are amplitudes, T is the period and n=1..N are : the min value for each joint
phases. Applying these oscillators to each joint, a crawling gait
can be developed and tested with the simulated humanoid NAO There are some useful tips to include in the evaluation
[6]. function, e.g. adding a conditional to check the actual pose of

3
A procedure that uses domain knowledge to determine a
perceived value of a situation during a search process.
Nao, if it is not in Belly pose then its necessary to make the Also the raw scores are not accurate as the fitness ones, there
robot stand up and start crawling again. is too mucho difference between the max and the min for each
generation.
Parameters information:
It is necessary to mention that between the 20th generation
A 1D list chromosome and the 37th theres a drop of the max score reached but then,
Population of 10 chromosomes initialized randomly from the 38th theres a rise until peak score is reached. A possible
reason to explain why this drop of score happened could be
Real range method for mutation, with 0.5 probability
because at that point Nao wasnt in the belly position, so the
Uniform method for crossover robot had to stand up and restart all the process of crawling
Fraction of the population created with 0.8 crossover again.

With everything set, the next step is to execute the 3D


environment simulator and spawn the Nao robot. Through the
Jupyter notebook the commands for connection and crawling are
executed in the simulator.
Result analysis:
For this problem, this is one of the infinite possible solutions,
it took around 45 minutes to complete 50 generations.
Generation Max Min Average
0 0.13(0.23) 0.13(0.23) 0.13(0.23)
1 0.13(0.23) 0.13(0.23) 0.13(0.23)
2 0.13(0.23) 0.13(0.23) 0.13(0.23)
3 0.13(0.23) 0.13(0.23) 0.13(0.23)

48 1.66 (11.15) 1.35 (0.17) 1.38 (1.38)
49 1.60 (11.15) 1.30 (0.12) 1.34 (1.34)
50 1.63 (11.15) 1.33 (0.21) 1.36 (1.36)
Time elapsed: 2749.767 seconds

Table 1: Results after 50 generations


The results shown in the Fig. 8 and Fig. 9 show the difference
between raw and fitness scores. The raw score may seem higher Figure 9: Fitness scores
than the fitness but is necessary to take into account that these
results are not normalized in relation to the population which has
In the Fig. 10 is shows a clear vision of the score difference
been used.
between the raw and the fitness results.

Figure 10: Max scores of raw and fitness results

Figure 8: Raw scores


III. CONCLUSION ACKNOWLEDGMENT
Based on the results obtained, I can conclude: genetic This research was supported by lab session technicians. I
algorithms are a good solution to solve problems related to thank our colleagues from class who provided help and advice
optimization and searching. The way I could solve the TSP that assisted the research.
problem amazed me because of the simplicity of the function we
used. Solving this problem with other algorithm wouldnt be an REFERENCES
easy task. Also I have to say that at the beginning the setting of [1] Marijke, M. (2002, May 1). Homepage of Maria (Marijke) Keet.
the parameters got me lost, however, once I realized what each Retrieved April 21, 2017, from http://www.meteck.org/gaover.html.
parameter was, the solving and understanding of the problem [2] M. A., M. A., M. T., & A. S. (2013, September 1). Mixing Energy Models
became easy. in Genetic Algorithms for On-Lattice Protein Structure Prediction.
Retrieved April 22, 2017, from
In the case of the Nao robot I found a bit difficult make https://www.researchgate.net/publication/258505194_Mixing_Energy_
everything work together, the simulator crashed every 5 Models_in_Genetic_Algorithms_for_On-Lattice_Protein_Structure.
minutes, so it was a bit challenging to reach the 50 generations [3] A. E., & J. S. (2003, January 1). Introduction to Evolutionary Computing.
Retrieved April 22, 2017, from
without problems. https://aulavirtual.uji.es/pluginfile.php/3759886/mod_resource/content/2
/Evolutionary%20Computing.pdf.
This last session confirmed that genetic algorithm are more
useful than they can seem at the beginning. In this case I had to [4] List of genetic algorithm applications. (2017, March 14). Retrieved April
22, 2017, from
make Nao crawl like a baby would do, but doing some research https://en.wikipedia.org/wiki/List_of_genetic_algorithm_applications.
on internet I found other interesting application, e.g. the NASA [5] G. D. (2015, January 1). Traveling Salesman Problem | Optimization |
used a generic algorithm to find the shape to build a new X-Band Google Developers. Retrieved April 22, 2017, from
antenna with the best performance [7], also Google developed https://developers.google.com/optimization/routing/tsp/tsp.
an algorithm to play the QWOP game with a record score [8]. [6] Del Pobil Ferre, A. P., & Cervera Mateu, E. (2017, February 1). Robot
Crawling with Genetic Algorithms. Retrieved April 22, 2017, from
At the end of this research other questions appear: https://aulavirtual.uji.es/mod/page/view.php?id=2998248.
How can Nao perform the crawling faster? [7] Hornby, G. S., Lohn, J. D., & Linden, D. S. (2011). Computer-Automated
Evolution of an X-Band Antenna for NASA's Space Technology 5
Which are the parameters that provide better results? Mission. Evolutionary
Doi:10.1162/evco_a_00005.
Computation, 19(1), 1-23.

How good would be the performing and the results if we [8] CSU Sacramento, S. R., CSU Sacramento, V. G., & Google, Inc., L. V.
combine genetic algorithm with neural networks? (2014, July 12). Evolving QWOP Gaits. Retrieved April 23, 2017, from
http://static.googleusercontent.com/media/research.google.com/en/us/pu
Is it possible to find a better way to obtain the bs/archive/42902.pdf.
parameters rather than doing few test?

Вам также может понравиться