Optimization Algorithm-Genetic Algorithm

1. Concept

Genetic algorithm GA: Genetic algorithm is based on Darwin's theory of evolution, which simulates natural selection, natural selection, and survival of the fittest. Through N generations of inheritance, mutation, crossover, and replication, the optimal solution to the problem is evolved.

Crossover, mutation, and then selective admission

2. Encoding

Abstracting the feasible solution to the problem into a form that can be used by the genetic algorithm requires different abstraction choices based on different problems.

The commonly used method is: binary encoding: using a binary string to represent a decimal value

eg: Given a numerical solution range of [1,10] , assign a unique binary string to each value, but the string will have accuracy problems (accuracy refers to the interval between two real number solutions)

If you want to assign a unique string to each value, then the number of values ​​that the string can represent needs to be greater than or equal to the number of numerical solutions.

If we have a string of length n, it can represent 2**n numbers

3. Decoding

4. Copying - a way to generate new solutions - there are many ways - the roulette method is commonly used 

The idea of ​​​​roulette: the higher the fitness, the solution should be copied with a high probability, and the number of copies should be more

 

5. Crossover, commonly used 1 and 2, 3 and 4 are crossed with a certain probability, and a segment is randomly selected for crossover

6. Mutation - Generally, only the second half of the body with poor fitness is mutated, and a certain probability is used to determine whether the individual mutates. If it mutates, a site is randomly selected for mutation, that is, bitwise inversion.

The basic idea of ​​the heuristic algorithm: firstly, it is analyzed based on the last result, and secondly, the basic idea is to evolve according to the best. The good ones will be better according to a certain strategy, and the bad ones will develop in a good direction according to a certain strategy. If something happens If the new solution is not good, then it will not be updated. At least there is a guarantee. When using the optimal algorithm, it is necessary to ensure a certain space search capability to ensure that it does not fall into a local optimal problem.

The basic idea can be summarized as follows: randomly select an initial solution, and generate a new solution in each cycle. If the new solution is good, update it, and if it is not good, keep the old solution.

The most important method is: the way to generate new solutions

Reference: b station BV14a411C7s8 up owner: Qingqing Prairie Big Wolf 

Guess you like

Origin blog.csdn.net/weixin_68479946/article/details/129025994