Today, genetic algorithms, genetic algorithms have many applications, such as pathfinding, eight digital problems, prisoner dilemma, motion control, TSP problem, production
scheduling problem, in a polygon to find a circle contained within the polygon, the function to find the most value problem, and so on. Previously, the simulated annealing algorithm was used
To solve the optimization problem, the link is:http://blog.csdn.net/acdreamers/article/details/10019849 analog fallback
The fire algorithm is summed up in a sentence: The greedy process introduces a random factor, with a certain probability to accept a worse than the current solution, and this probability with the time
Gradually reduced over time. Today's genetic algorithm is a biological evolutionary process simulating the natural selection of organisms, by maintaining a potential solution
The group performs a multi-directional search and supports information composition and exchange in these directions. A search in the face, more than a point unit of search, more able to send
The present global optimal solution.
Contents
1. Introduction to Genetic algorithms
2. Gene encoding method
3. Fitness scoring and selection function
4. Gene recombination and gene mutation
5. Introduction of Galib
6. Introduction to Other GA tools
1. Introduction to Genetic algorithms
When it comes to genetic algorithms, I have to say a more pertinent metaphor on the web. Once there was a group of kangaroos that were scattered and abandoned in Himalaya, so
Began to live hard there, and the low altitude of the place is filled with a poisonous gas, so the lower the elevation of individuals die first, while the Kangaroo will also be born
After a few years, the surviving kangaroo will eventually climb upwards and may gather on many mountain peaks, child-rearing women. And once again, if
In the dry years, it may be that the Kangaroos on the lower peaks are dead, and the kangaroo that eventually sits on Mt. Everest survives, thus seeking
Got the most value.
Above is the core idea of genetic algorithm, then there are a few problems to solve.
(1) Before genetic algorithm search, we need to produce a population, how is this population produced?
(2) After the population is produced, how to simulate the evolution of organisms to get good individuals, and how to evaluate good individuals?
For the problem (1), in the genetic algorithm, can not directly deal with the problem space, need to map the problem space to the genetic space, the individual expressed as
Chromosomes, which are made up of genes according to a certain structure, are called chromosome codes . Each individual chromosome is encoded to produce a
Group. For the problem (2), genetic manipulation imposes certain actions on the individual population according to its adaptability to the environment, thus realizing the fittest
Evolutionary processes, genetic manipulation involves selection, crossover, and mutation. In the genetic space, the migration of individuals is determined by crossover and mutation, and cross-manipulation acts as
GA provides a coarse-grained, large-step search method. Mutation belongs to the auxiliary operation of GA, whose main purpose is to maintain the multiplicity of the solution space. Wildcard
After crossing and mutation, the new individuals are created, and then the choice is made to eliminate the inferior individuals.
2. Gene encoding method
The first step in genetic algorithms is to map the space of the problem to the genetic space, a step called chromosome coding. Common coding methods are binary
code and floating-point numbers .
(1) binary encoding
A certain precision binary code can only represent a certain number of precision floating point numbers, such as we require accurate to 6 decimal places, and the interval is [-1, 2],
To ensure accuracy, the interval should at least be divided into equal portions, as
So the encoded binary string requires a number of bits, converting a binary string into a real number in the interval [-1, 2] by the following method
First, the binary number is converted to decimal number, such as the resulting decimal number, then the final corresponding [-1, 2] range of floating-point numbers are
This corresponds to a binary string to a floating-point number, which in turn can map a floating-point number to a binary string.
(2) floating-point code
In order to improve the complexity of genetic algorithm and improve the speed of computation, floating-point coding is proposed.
3. Fitness scoring and selection function
The adaptive scoring function is used to measure which individual should be eliminated, in general, the lower the value of the individual should be eliminated. Adaptive scoring function
It's a matter of choice . And the selection function is natural selection , from the nature, the more adapt to the environment of the individual more likely to reproduce offspring, but can not say the more adapt
The more offspring the environment is, the more likely it is. So how do we build this probabilistic relationship? A common method is the wheel
Game Selection Method . Assuming the population number is, the fitness of an individual is, then the probability of an individual being selected is
So the natural selection process in genetic algorithm is to use the adaptive scoring function to calculate the adaptive scoring value of each individual, and then use roulette to choose
The choice method calculates the selection probability of each individual, the greater the probability, the greater the chance of being selected. The core code is as follows
The above code is the selection of individuals who need to be eliminated, reflecting the natural selection process of the biological population.
4. Gene recombination and gene mutation
In a genetic algorithm, each individual is represented by a single chromosome, and the chromosomes may cross, and a single chromosome may occur.
Gene mutation. The purpose of recombination and mutation is to make the offspring different from the father, of course, the offspring is not necessarily superior to the parent, only after the choice
The odds are greater than the parent. Both binary and floating-point encoding can be genetically reconstructed,
A gene mutation is a gene that changes a locus in a chromosome, which causes a gene to become its allele, often causing a certain
Phenotype changes. The code is roughly as follows
5. Introduction of Galib
The above basically tells the principle of the genetic algorithm, the next step is to learn how the genetic algorithm to solve some common application problems. Mainly introduces a
Genetic algorithm Library---galib. Galib is a genetic algorithm class library developed by C + +, Massachusetts Institute of MIT Matthew Wall, designed
Very reasonable, powerful and easy to scale.
galib provides three basic genetic algorithms: standard, steady-state and incremental. The difference is that the new individuals who have evolved to replace the parent group
The way. Galib's download site is:http://lancet.mit.edu/ga/dist/ specific usage can refer to example example.
This C + + library is powerful, and later try to use this to implement genetic algorithms. And here's a C + + genetic algorithm library.
Links:https://github.com/kataklinger/Genetic-Algorithms-Library
6. Introduction to Other GA tools
The genetic algorithm of R language implementation
R Language Genetic algorithm package is very much, specific can refer to:Http://www.tuicool.com/articles/aaQB7nQ
For example, to install a MCGA package, for example, first install
Check, as
MCGA is mainly used to find the maximum value problem of multivariate functions (minimum value). Examples are as follows
Julia implements genetic algorithm
In Julia there is a library of genetic algorithms called geneticalgorithms. The source code is as follows
Source: HTTPS://GITHUB.COM/FORIO/GENETICALGORITHMS.JL
Install first, as follows
The use of geneticalgorithms can be referred to as examples.
Introduction to Genetic algorithms