Reprint: Popular Understanding Genetic algorithm

Source: Internet
Author: User
Tags shuffle traits

First, the application of genetic algorithm

function optimization (Classical application field of genetic algorithm);
Combinatorial optimization (the practice proves that the genetic algorithm is very effective for NP-complete problems in combinatorial optimization, such as 0-1 knapsack problem, TSP, etc.);
Automatic control

Robot intelligent Control;

Combined image processing and pattern recognition;

Artificial life;

Genetic programming;

Ii. Basic concepts and terminology of genetics

Genotype (genotype): internal manifestations of trait chromosomes;

Phenotype (phenotype): chromosomes determine the external manifestations of traits, or individuals formed according to genotype;

Evolution (Evolution): Gradually adapt to the living environment, quality has been improved. The evolution of organisms is carried out in the form of a population.

Fitness (fitness): Measure the degree to which a species adapts to a living environment.

Selection (selection): Select several individuals from a population at a certain probability. In general, the selection process is a process based on the adaptation of the fittest.

Replication (reproduction): When cells divide, the DNA of the genetic material is transferred to the newly produced cells by copying, and the new cells inherit the old cell's genes.

Cross (crossover): DNA at one of two chromosomes is cut off, and the two strands are crossed together to form two new chromosomes. Also called gene recombination or hybridization;

Mutation (mutation): Replication may (very small probability) produce certain replication errors, mutation produces new chromosomes, showing new traits.

Encoding (coding): The genetic information in DNA is arranged in a certain pattern on a long chain.

Genetic coding can be thought of as mapping from phenotype to genotype.

Decoding (decoding): genotype-to-phenotype mapping.

Individual (individual): refers to the entity with characteristic of chromosome;
Population (population): The set of individuals, the number of individuals in the set is called the size of the population;

Three, the basic idea of genetic algorithm

Before you begin to introduce an instance, it is necessary to understand the roulette selection method, because the basic genetic algorithm is used for this choice strategy.

Roulette Options
Also known as the proportional selection method. The basic idea is that the probability of each individual being chosen is proportional to the size of its fitness.

Here's how:
(1) to calculate the fitness F (i=1,2,...,m) for each individual in the group, and M for the population size;
(2) Calculate the probability of each individual being inherited into the next generation group;

(3) Calculating the cumulative probability of each individual;

(Q[i] is called chromosome x[i] (i=1, 2, ..., n) accumulation probability)

(4) A uniformly distributed pseudo-random number r is produced within the [0,1] interval;
(5) If r<q[1], then select individual 1, otherwise, select the individual K, make: q[k-1]<r≤q[k] established;
(6) Repeat (4), (5) A total of M-times

Simple example of 四、一个

1. Initial population generation

s1= 13 (01101)

S2= 24 (11000)

s3= 8 (01000)

s4= 19 (10011)


2. Calculation of Fitness

Assuming that the degree of fitness is f (s) =s^2, the

F (S1) = f (13) = 13^2 = 169

F (s2) = f (24) = 24^2 = 576

F (S3) = f (8) = 8^2 = 64

F (S4) = f (19) = 19^2 = 361

3. Select

The probability of chromosome selection is:

The cumulative probability of a chromosome is:

According to the above formula, you can get:

For example, a set of 4 random numbers from the interval [0, 1] is generated:

R1 = 0.450126, r2 = 0.110347

R3 = 0.572496, R4 = 0.98503

4. Crossover

The crossover operator in the basic genetic Algorithm (SGA) employs a single-point crossover operator.

Single Point crossover operation

5. Variation

6. To the next generation, fitness calculation → select → cross → variation until the termination condition is met

V. Application of genetic algorithm

Here are the specific application examples: function optimization

    • The question is raised

The unary function asks for the maximum value:

The maximum value of f (x) is obtained by differential method:

Maximum points can be obtained: f (1.85) =3.85

0. Encoding

Presentation type: X
Genotype: Binary encoding (string length depends on solution accuracy)
The relationship between string length and precision:
If the precision is required to solve 6 decimal places, the interval length is 2-(-1) = 3, that is, the interval should be divided into 3/0.000001=3&times;106 equal parts.
So the encoded binary string length should be 22 bits.

1. Initial population generation

The way it is produced: random
Result: binary string of length 22
Quantity produced: The size of a population (scale), as 30,50, ...
1111010011100001011000
1100110011101010101110
1010100011110010000100
1011110010011100111001
0001100101001100000011
0000011010010000000000

2. Calculation of Fitness

Different problems have different degree of adaptability calculation method
This example: using objective function directly as fitness function
① converts an individual to a real number in a [ -1,2] interval:
s=<1000101110110101000111>→x=0.637197
② calculates the function value of x (fitness):
F (x) =xsin (10πx) +2.0=2.586345

(0000000000000000000000) →-1
(1111111111111111111111) →2

The above ① is actually the conversion between binary and decimal:
The first step is to convert a binary string (b21b20...b0) into a 10 binary number:

In the second step, the real numbers in the interval [ -1,2] corresponding to X ':

3. Genetic manipulation

Choice: Roulette Choice method;
Crossover: Single point crossover;
Mutation: small probability variation

    • Simulation results

Set the parameters:
Population size 50; crossover probability 0.75; mutation probability 0.05; maximum algebra 200.
The best individuals to get:
smax=<1111001100111011111100>;
xmax=1.8506;
F (xmax) = 3.8503;

    • Run results

Vi. Summary

Coding Principles
Completeness (completeness): All the solutions of the problem space can be expressed as the genotype of the design;
Soundness (soundness): Any genotype corresponds to a possible solution;
Non-redundancy (non-redundancy): The problem space and expression space one by one correspond.

The importance of fitness function
The selection of fitness function directly influences the convergence speed of genetic algorithm and can find the optimal solution.
In general, the fitness function is transformed by the objective function, and a mapping transformation of the target function range is called the scale transformation of fitness (fitness scaling).

Improper design of fitness function may present spoofing problems:
(1) In the early stage of evolution, individual extraordinary individuals control the selection process;
(2) At the end of evolution, individual differences are too small to fall into local extrema.

Examples of deception problems:

Imagine that the Earth, like the disaster movie "The Day After Tomorrow," there is a poisonous haze, Himalaya under the 100 Monkeys (population size), only climbed the top of Mount Everest monkeys to survive,

Because Himalaya has a lot of peaks, we use height as fitness, case (1): If the monkey in the Everest is taller than the monkey on the hillside, because the size of the population is unchanged, the monkey in Everest may be eliminated;

Case (2): 100 monkeys are not in Everest;

1. The role of selection: Survival of the fittest, the fittest;

2. The role of crossover: to ensure the stability of the population, toward the direction of the optimal solution evolution;

3. The role of mutation: to ensure the diversity of the population, to avoid cross-possible local convergence;

It shows the essence of genetic algorithm well.

Characteristics of genetic algorithms

    • Self-organization, self-adaptation and self-study habits
      After the coding scheme, the fitness function and the genetic operator are determined, the algorithm will use the information obtained in the evolutionary process to organize the search itself.

    • Intrinsic parallelism
      Intrinsic parallelism and embedded parallelism

    • No need to guide
      Only objective function and fitness function

    • Probability conversion rules
      Emphasis on probability conversion rules, rather than deterministic conversion rules

Vii. Supplementary

Because each operation of the genetic algorithm has its merits and demerits in the different strategies of the application, the specific situation, the specific analysis, is attached here:

1. Select

Calculation of Fitness:
Proportional fitness function (proportional fitness assignment)
Ranking-based fitness calculation (rank-based fitness Assignment)

Selection algorithm:
Roulette Options (Roulette wheel selection)

Random traversal sampling (stochastic universal selection)
Local selection (local selection)
Truncate selection (truncation selection)
Tournament Selection (tournament selection)

2. Crossover

Because the coding is binary and floating-point encoding, so there are two kinds of crossover and mutation;

Real value reorganization (real valued recombination):

Discrete recombination (discrete recombination)

Intermediate recombination (intermediate recombination)

Linear recombination (linear recombination)

Extended linear reassembly (extended linear recombination)

Binary crossover (binary valued crossover):

Single point crossover (Single-point crossover)

Multipoint crossover (Multiple-point crossover)

Uniform crossover (uniform crossover)

Shuffle crossover (Shuffle crossover)

Narrowing Agent crossover (crossover with reduced surrogate)

3. Variation

Real value variation
Binary variants

In addition, the theoretical support-pattern theorem behind the genetic algorithm can be further studied and optimized in the study of genetic algorithms.

Reprint: Popular Understanding Genetic algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.