What is heuristic algorithm - annealing algorithm, ant colony algorithm, genetic algorithm

First, the annealing algorithm

The simulated annealing algorithm is derived from the principle of solid annealing. The solid is heated to a sufficiently high level, and then slowly cooled. During heating, the particles inside the solid become disordered as the temperature rises, and the internal energy increases. It tends to be ordered, reaches the equilibrium state at each temperature, and finally reaches the ground state at normal temperature, and the internal energy is reduced to a minimum.

The generation and acceptance of new solutions of the simulated annealing algorithm can be divided into the following four steps:

The first step is to generate a new solution in the solution space from the current solution by a generating function; in order to facilitate subsequent calculation and acceptance, and reduce the time-consuming of the algorithm, a method that can generate a new solution by simply transforming the current new solution is usually selected. , such as permuting or exchanging all or part of the elements constituting the new solution, it is noted that the transformation method that generates the new solution determines the neighborhood structure of the current new solution, and thus has a certain influence on the selection of the cooling schedule.

The second step is to calculate the objective function difference corresponding to the new solution. Since the objective function difference is only produced by the transform part, the calculation of the objective function difference is preferably done incrementally. It turns out that, for most applications, this is the fastest way to compute the objective function difference.

The third step is to judge whether the new solution is accepted. The judgment is based on an acceptance criterion. The most commonly used acceptance criterion is the Metropolis acceptance criterion: if Δt'<0, accept S' as the new current solution S, otherwise, use the probability exp( -Δt'/T) accepts S' as the new current solution S.

The fourth step is to replace the current solution with the new solution when the new solution is confirmed to be accepted. This only needs to realize the transformation part of the current solution corresponding to the time when the new solution is generated, and at the same time correct the value of the objective function. At this point, the current solution achieves one iteration. On this basis, the next round of trials can be started. When the new solution is judged to be discarded, the next round of testing is continued on the basis of the original current solution.

CSDN article about annealing algorithm: Simulated Annealing Algorithm - ACdreamer - Blog Channel - CSDN.NET

2. Genetic Algorithms

Genetic algorithm (Genetic Algorithm) is a computational model of the biological evolution process that simulates the natural selection and genetic mechanism of Darwin's theory of biological evolution. It is a method to search for optimal solutions by simulating the natural evolution process. A genetic algorithm starts with a population that represents a set of possible potential solutions to a problem, and a population consists of a certain number of individuals encoded by genes. Each individual is actually a chromosome (chromosome) entity with characteristics. Chromosomes are the main carrier of genetic material, that is, a collection of multiple genes. Its internal expression (ie genotype) is a certain combination of genes, which determines the external expression of the individual's shape. For example, the characteristics of black hair are controlled by chromosomes. A trait is determined by a certain combination of genes. Therefore, the mapping from phenotype to genotype, ie coding, needs to be achieved in the beginning. Since the work of imitating gene coding is very complicated, we often simplify it, such as binary coding. After the first generation of population is generated, according to the principle of survival of the fittest and survival of the fittest, generation by generation (generation) evolves to produce better and better approximate solutions. In the first generation, individuals are selected according to their fitness in the problem domain, and crossover and mutation are combined with the help of genetic operators of natural genetics to generate representative new The population of the solution set. This process will lead to the population of the descendant population, like the natural evolution, which is more adapted to the environment than the previous generation. The optimal individual in the last generation population can be decoded and can be used as an approximate optimal solution to the problem.

Genetic algorithms are based on biology and are not too difficult to understand or program. The following is the general algorithm of the genetic algorithm:

  1. Building the initial state The initial population is randomly selected from the solutions, and these solutions are likened to chromosomes or genes, and the population is called the first generation, which is different from the case of symbolic artificial intelligence systems, where the initial state of the problem has been given.
  2. Evaluating fitness assigns a fitness value to each solution (chromosome), based on how close the problem is to actually being solved (in order to approximate the solution to the problem). Don't confuse these "solutions" with the "answer" to the problem, think of it as those properties that the system might need to take advantage of to get the answer.
  3. Reproduction (including progeny mutation) Those chromosomes with higher fitness values ​​are more likely to produce offspring (which will also mutate when progeny are produced). Offspring are the product of their parents, and they are made by combining genes from their parents in a process called "crossbreeding."
  4. Next Generation If the new generation contains a solution that produces an output that is sufficiently close to or equal to the desired answer, then the problem is solved. If this is not the case, the new generation will repeat the reproduction process carried out by their parents, evolving from generation to generation until the desired solution is reached.
  5. Parallel Computing It is very easy to use Genetic Algorithms in parallel computing and cluster environments. One approach is to directly treat each node as a parallel population. Organisms then migrate from one node to another according to different reproduction methods. Another approach is a "farmer/labor" architecture, designating one node as the "farmer" node responsible for selecting organisms and assigning fitness values, and the other nodes as "labor" nodes responsible for recombination, mutation, and adaptation Evaluation of the degree function.

3. Ant Colony Algorithm

Individual ants start looking for food without first telling them where the food is. When a dog finds food, it will release a volatile secretion pheromone (called pheromone, which will gradually evaporate and disappear over time, and the concentration of pheromone indicates the distance of the path) to the environment. , attract other ants to come over, so that more and more ants will find food. Some ants do not always repeat the same path like other ants, they will find another way, if the other way is shorter than the original one, then, gradually, more ants will be attracted to this shorter path . Finally, after a period of operation, there may be a shortest path repeated by most ants.

Here are some descriptions of the algorithm:

  1. The range observed by the range ant is a square world, and the ant has a parameter of speed radius (usually 3), then the range it can observe is 3*3 square worlds, and the distance it can move is also in this range within.
  2. The environment where the ants are located is a virtual world, in which there are obstacles, other ants, and pheromones. There are two kinds of pheromones, one is the food pheromone sprinkled by the ants who find the food, and the other is to find the food. The pheromone of the nest sprinkled by the ants of the nest. Each ant can only perceive environmental information within its range. The environment makes the pheromone disappear at a certain rate.
  3. The foraging rule searches for food within the range that each ant can perceive, and if there is food, it goes directly there. Otherwise, see if there is pheromone, and compare which point has the most pheromone within the range of perception. In this way, it will go to the place with more pheromone, and each ant will make mistakes with a small probability, so it is not to the information. The point with the most pixels moves. The rules for an ant to find a nest are the same as above, except that it responds to the pheromone of the nest, but not to the food pheromone.
  4. Movement rules Each ant moves in the direction with the most pheromone, and when there is no pheromone guide around, the ant will move inertially in the direction of its original movement, and there is a random small movement in the direction of movement. perturbation. In order to prevent the ant from turning around in place, it will remember which points it has just passed, and if it finds that the next point to go has already passed before, it will try to avoid it.
  5. Obstacle Avoidance Rule If the ant's moving direction is blocked by an obstacle, it will randomly choose another direction, and if it is guided by a pheromone, it will behave according to the foraging rules.
  6. Pheromone Rule Each ant scatters the most pheromone when it first finds food or a nest, and as it travels farther, it scatters less and less pheromone.

According to these rules, there is no direct relationship between ants, but each ant interacts with the environment, and through the link of pheromone, the ants are actually connected. For example, when an ant finds food, it does not directly tell other ants that there is food, but spreads pheromones to the environment. When other ants pass by it, they will feel the existence of pheromones, and then according to Pheromone guides to find food.

The above are some theoretical knowledge cited in the algorithm learning process. For the application, please refer to the specific application section.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324782848&siteId=291194637