A sample of a good understanding of Genetic Algorithms

Source: Internet
Author: User
Tags example of manual

Example of manual simulation of Genetic Algorithm

In order to better understand the operation process of the genetic algorithm, the following manual computation is used to simulate
Main Operation steps.

For example, calculate the maximum value of the following binary functions:

(1) individual code
The computing object of the genetic algorithm is a symbol string that represents an individual. Therefore, the X1 and X2 variables must be encoded as one type.
Symbol string. In this question, it is represented by an unsigned binary integer.
Because x1, x2 is 0 ~ So they are represented by three Unsigned binary integers.
The six-bit Unsigned binary numbers that are connected together form the individual genotype, indicating
Line solution.
For example, the phenotype corresponding to the genotype x = 101110 is: x = [5, 6].
Individual phenotype X and genotype X can be converted to each other through encoding and decoding procedures.

(2) initial group generation
Genetic algorithm is an evolutionary operation on a population. It needs to provide it with some initial information that indicates the starting search point.
Group data.
In this example, the group size is 4, that is, the Group is composed of four individuals, each individual can
Method generation.
For example: 011101,101011, 011100,111001

(3) fitness juice Calculation
In the genetic algorithm, the individual fitness is used to assess the individual's merits and demerits, thus determining its genetic
Opportunity size.
In this example, the objective function is always set to a non-negative value, and the maximum value of the function is used as the optimization goal.
Use the target function value as the individual's fitness.

(4) Select Operation
Select operations (or replication operations) inherit the individuals with higher fitness in the current population to the next generation according to certain rules or models. Individuals with high fitness requirements generally have many other opportunities to inherit from the next generation.
Group.
In this example, we use the probability that each individual is copied to the next generation.
. The detailed operation process is:
• Calculate the total fitness of all individuals in the group first? FI (I = 1.2 ,..., M );
• Calculate the relative fitness of each individual /? Fi, which is inherited by each individual
Probability in the next generation,
• Each probability value constitutes a region, and the sum of all probability values is 1;
• Finally, a random number between 0 and 1 is generated. Based on the random number, which of the above probability zones is generated?
Domain to determine the number of times each individual is selected.

(5) crossover
Crossover is the main operation process for new individuals in genetic algorithms. It exchanges a probability with each other.
The part of the chromosome between two individuals.
In this example, the procedure of using the single-point crossover method is as follows:
• Randomly pairing groups;
• Set the intersection position randomly;
• Finally, some genes are exchanged between paired chromosomes.

(6) mutation operation
The mutation operation is based on a small probability for the genetic values of one or more individual gene sites.
It is also an operation method to generate new individuals.
In this example, we use the basic bitwise Mutation Method to perform the mutation operation. The detailed operation process is as follows:
• Determine the mutation location of each individual. The following table shows the random mutation location,
The number indicates that the mutation point is set at this position;
• Then, the original genetic values of the mutations are reversed based on a probability.

After a round of selection, crossover, and mutation operations on group p (t), a new generation of group P (t + 1) can be obtained ).

As can be seen from the table above, after the evolution of a group, the maximum and average values of its fitness are all
Significant improvements have been made. In fact, we have found the best individual "111111 ".
[Note]
Note that data in some columns of the table is randomly generated. To better illustrate the problem,
We specially selected some good values to get better results, but in the actual operation process
A certain number of cycles may be required to achieve this optimal result.

A sample of a good understanding of Genetic Algorithms

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.