Artificial Intelligence - Genetic Algorithms

Introduction to Genetic Algorithms

  • Genetic Algorithm (GA) was first proposed by John Holland in the United States in the 1970s. This algorithm is designed and proposed according to the evolution law of organisms in nature .
  • Genetic Algorithm is a calculation model of the biological evolution process that simulates Darwin's biological evolution theory of natural selection and genetic mechanism , and is a method of searching for the optimal solution by simulating the natural evolution process .
  • The algorithm converts the problem-solving process into a process similar to the crossover and mutation of chromosome genes in biological evolution by using computer simulation operations in a mathematical way . When solving more complicated combinatorial optimization problems, compared with some conventional optimization algorithms, it can usually obtain better optimization results faster.

coding

Since the genetic algorithm cannot directly deal with the parameters of the problem space, the problem to be solved must be expressed as chromosomes or individuals in the genetic space through coding . This transformation operation is called encoding, which can also be called representation (of the problem).
The following three criteria are often used to evaluate coding strategies:

  • Completeness : All points (candidate solutions) in the problem space can be represented as points (chromosomes) in the GA space.
  • Soundness : Chromosomes in the GA space correspond to all candidate solutions in the problem space.
  • Non-redundancy (nonredundancy) : Chromosomes correspond to candidate solutions one-to-one.

fitness function

  • The fitness in the theory of evolution refers to the ability of an individual to adapt to the environment and also the ability of the individual to reproduce . The fitness function of the genetic algorithm is also called the evaluation function , which is an index used to judge the quality of the individual in the group , and it is evaluated according to the objective function of the problem .
  • The genetic algorithm generally does not need other external information in the process of search evolution, and only uses the evaluation function to evaluate the pros and cons of individuals or solutions, and use it as the basis for future genetic operations. Because in the genetic algorithm, the fitness function needs to be sorted and the selection probability is calculated on this basis, so the value of the fitness function should take a positive value . It can be seen that in many occasions, it is necessary to map the objective function into a fitness function that seeks the maximum value and has a non-negative function value.
  • The design of the fitness function mainly meets the following conditions:
    • Single-valued, continuous, non-negative, maximized.
    • Reasonable and consistent.
    • The amount of calculation is small.
    • Versatile.
  • In specific applications, the design of the fitness function should be combined with the requirements of solving the problem itself. The fitness function design directly affects the performance of the genetic algorithm.

initial group selection

  • Individuals in the initial population in the genetic algorithm are randomly generated. Generally speaking, the following strategies can be adopted for setting the initial group:
    1. According to the inherent knowledge of the problem, try to grasp the distribution range of the space occupied by the optimal solution in the entire problem space, and then set the initial group within this distribution range.
    2. A certain number of individuals are randomly generated first , and then the best individuals are selected and added to the initial group. This process is iterated until the number of individuals in the initial population reaches a predetermined size.

operation process

The basic operation process of the propagation algorithm is as follows:
1. Initialization : set the evolution algebra counter t = 0, set the maximum evolution algebra T, and randomly generate M individuals as the initial population P(0).
2. Individual evaluation : Calculate the fitness of each individual in the group P(t).
3. Selection operation : apply the selection operator to the group. The purpose of selection is to directly inherit the optimized individuals to the next generation or generate new individuals through paired crossover and then inherit them to the next generation. The selection operation is based on the fitness evaluation of the individuals in the population.
4. Crossover operation : apply the crossover operator to the group. The core function of the genetic algorithm is the crossover operator.
5. Mutation operation : apply the mutation operator to the population. That is to change the gene values ​​at some loci of the individual strings in the population. After the group P(t) undergoes selection, crossover and mutation operations, the next generation group P(t+1) is obtained.
6. Termination condition judgment : if t=T, the individual with the maximum fitness obtained during the evolution process is output as the optimal solution, and the calculation is terminated.

  • Genetic operations include the following three basic genetic operators: selection , crossover , and mutation .

choose

The operation of selecting superior individuals from a group and eliminating inferior individuals is called selection. The selection operator is sometimes called the reproduction operator . The purpose of selection is to directly inherit the optimized individual (or solution) to the next generation or generate new individuals through paired crossover and then pass it on to the next generation. The selection operation is based on the fitness evaluation of individuals in the group. Commonly used selection operators include the following: fitness proportional method , random traversal sampling method , and local selection method .

cross

What plays a central role in the process of biological evolution in nature is the recombination (plus variation) of biological genetic genes . Similarly, the core function of the genetic algorithm is the crossover operator of the genetic operation . The so-called crossover refers to the operation of replacing and reorganizing part of the structure of two parent individuals to generate a new individual . Through crossover, the search ability of genetic algorithm can be greatly improved.

Mutations

The basic content of the mutation operator is to change the gene values ​​at some loci of individual strings in the population . According to the different representation methods of individual encoding , the following algorithms can be used:

  • Real-valued variation.
  • Binary mutation.

Generally speaking, the basic steps of mutation operator operation are as follows:

  1. For all individuals in the group, it is judged whether to mutate according to the pre-set mutation probability.
  2. Randomly select mutated bits for mutated individuals to mutate.

There are two purposes for genetic algorithm to introduce mutation : one is to make genetic algorithm have local random search ability . When the genetic algorithm is close to the optimal solution neighborhood through the crossover operator, the local random search ability of the mutation operator can be used to accelerate the convergence to the optimal solution. Obviously, the mutation probability in this case should take a small value, otherwise the building blocks close to the optimal solution will be destroyed by mutation. The second is to enable the genetic algorithm to maintain population diversity to prevent premature convergence . At this time, the convergence probability should take a larger value .

Termination condition

When the fitness of the optimal individual reaches a given threshold , or when the fitness of the optimal individual and the fitness of the group no longer increase, or when the number of iterations reaches a preset number of generations, the algorithm terminates. The preset number of generations is generally set to 100 - 500 generations.

Guess you like

Origin blog.csdn.net/qq_45902301/article/details/125431615