"Optimization method" exhaustive vs. Climbing method vs. simulated annealing algorithm vs. genetic algorithm vs. ant colony algorithm-optimization method

Source: Internet
Author: User
Tags new set

I. The method of exhaustive

Enumerate all the possibilities and go on to get the best results. As figure one, you need to go straight from point A to point G to know that F is the highest (best solution). The optimal solution obtained by this algorithm is certainly the best, but it is also the least efficient. Although the best solution can be obtained by exhaustive method, the efficiency is extremely low. In order to improve efficiency, you can not enumerate all the results, only part of the result set, if a solution in this decomposition is optimal, then consider it as the optimal solution. Obviously, this may not get the real optimal solution, but the efficiency is much higher than the exhaustive method.

Two. Mountain climbing algorithm (hill climbing)

The greedy way.

When enumerating all the solutions, when the solution encountered is optimal in the present case, it is considered to be the optimal solution. As shown in figure I, when from point A to point B, the B point is considered to be the optimal solution because B is better than the solution of point A. Obviously, the efficiency is very high, but the optimal solution quality is very poor.

"Climbing Law"

The greedy method is only compared with the previous one, in order to improve the quality of the optimal solution, not only compared to the previous solution, but also to the last solution, if better than the previous and subsequent solutions, then it is considered to be the optimal solution. As shown in figure one, when it comes to point C, it is found to be better than the preceding B and D-points, so it is considered to be the best solution. Mountain climbing algorithm is a simple greedy search algorithm, which selects an optimal solution from the nearest solution space of the current solution as the current solution, until a local optimal solution is reached.

Mountain climbing algorithm is simple to achieve, its main disadvantage is that it will fall into local optimal solution, and not necessarily can search the global optimal solution. As shown in Figure 1: Assuming the C-point is the current solution, the local optimal solution of the hill-climbing algorithm to search for point A will stop the search because no better solution can be obtained at point A, regardless of the small movement in that direction.

Figure 1

Three. Simulated annealing (sa,simulated annealing) thought

Mountain climbing method is completely greedy, every time a short-sighted choice of the current optimal solution, so can only search the local optimal value. Simulated annealing is actually a greedy algorithm, but its search process introduces random factors. The simulated annealing algorithm takes a certain probability to accept a solution that is worse than the current one, so it is possible to jump out of the local optimal solution and reach the global optimal solution. Taking fig. 1 As an example, the simulated annealing algorithm can accept the move of e at a certain probability after searching the local optimal solution A. Perhaps after several times this is not the local optimal movement will reach D point, and then jumped out of the local maximum of a.

"Simulated annealing algorithm (simulated Annealing,sa)" was first applied to combinatorial optimization by Kirkpatrick, which is a stochastic algorithm based on Mente-carlo iterative solution, The starting point is based on the similarity between the annealing process of solid matter in physics and the general combinatorial optimization problem. The simulated annealing algorithm is based on a higher initial temperature, with the decreasing of the temperature parameter, and the probability jump characteristic in the solution space to find the global optimal solution of the objective function randomly, that is, the local optimal solution can jump out of probability and finally tend to the global optimal.

The key of the simulated annealing algorithm is to control the temperature (probability) to reduce the speed of the parameter R, this parameter range is 0<r<1. If the parameter r is too large, the search to the global optimal solution may be higher, but the search process is longer. If R is too small, the search process will be fast, but it may eventually reach a local optimal value.

The simulated annealing algorithm can not guarantee the real optimal solution, but the optimal solution with high quality is obtained under the condition of good efficiency.

Simulated annealing algorithm Description:

If J (Y (i+1)) >= J (Y (i)) (that is, a better solution after moving), the move is always accepted

If J (Y (i+1)) < J (Y (i)) (i.e. the solution is less than the current solution), the move is accepted with a certain probability, and the probability gradually decreases over time (gradually decreasing to tend to stabilize)

The calculation of "certain probability" here refers to the annealing process of metal smelting, which is also the origin of the simulated annealing algorithm name.

According to the thermodynamics principle, when the temperature is T, the probability that the energy difference is de is P (DE), which is expressed as:

P (DE) = exp (de/(KT))

where k is a constant, exp represents the natural exponent, and de<0. The formula is: the higher the temperature, the greater the probability of a decrease in the temperature of the de and the lower the probability of cooling. And because DE is always less than 0 (otherwise it is not called annealing), so de/kt < 0, so the function of P (DE) is the range of values (0,1).

As the temperature T decreases, P (DE) decreases gradually.

We think of the move of a poor solution as a temperature-hopping process, and we accept the move as a probability P (dE).

There is an interesting analogy between the climbing algorithm and the simulated annealing:

"Mountain Climbing Algorithm": the Rabbit in the higher than now jump to the place. It found the highest mountain not far away. But this mountain is not necessarily Mount Everest. This is the mountain climbing algorithm, it can not guarantee that the local optimal value is the global optimal value.

"Simulated annealing": The Rabbit was drunk. It jumped randomly for a long time. During this period, it may move to a higher place, or it may step into the ground. However, it gradually sobered up and jumped in the highest direction. This is simulated annealing.

Pseudo-code representations of simulated annealing are given below.

"Simulated annealing algorithm pseudo code"/*
* J (Y): evaluation function value in state y
* Y (i): Indicates the current state
* Y (i+1): Indicates a new state
* r: Used to control the speed of cooling
* T: System temperature, the system should initially be in a high temperature state
* T_min: The lower temperature, if the temperature T reached T_min, then stop the search
*/
while (T > T_min)
{
DE = J (Y (i+1))-J (Y (i));

if (DE >=0)//expression is moved to a better solution, the move is always accepted
Y (i+1) = y (i); Accept movement from Y (i) to Y (i+1)
Else
{
The value range of function exp (de/t) is (0,1) and the de/t is larger, exp (de/t) is also
if (exp (de/t) > Random (0, 1))
Y (i+1) = y (i); Accept movement from Y (i) to Y (i+1)
}
t = R * t; Cooling annealing, 0<r<1. The larger the R, the slower the cooling; the smaller the R, the faster the cooling.
/*
* If the R is too large, the search to the global optimal solution may be higher, but the search process is longer. If R is too small, the search process will be fast, but it may eventually reach a local optimal value
*/
i + +;
}

"Use simulated annealing algorithm to solve the traveling merchant problem"

Traveling salesman problem (TSP, traveling salesman Problem): There are N cities, ask to start from one of the problems, the only way to traverse all cities, and then return to the city of departure, to find the shortest route.

The traveling salesman problem belongs to the so-called NP complete problem, the accurate solution tsp can only by the poor lift all the path combination, its time complexity is O (n!).

An approximate optimal path of TSP can be obtained quickly by using simulated annealing algorithm. (using genetic algorithm is also possible, I will introduce in the next article) simulated annealing solution tsp idea:

1. Generates a new traversal path P (i+1), calculates the length of the path P (i+1) L (P (i+1))

2. If L (P (i+1)) < L (P (i)), accept P (i+1) as the new path, otherwise accept P (i+1) with the probability of simulated annealing, and then cool down

3. Repeat steps 1,2 until the exit condition is met

There are a number of ways to generate new traversal paths, and here are 3 of them:

1. Randomly select 2 nodes to exchange the order of these 2 nodes in the path.

2. Randomly select 2 nodes to reverse the node order between the 2 nodes in the path.

3. Randomly select 3 nodes m,n,k, and then shift the node m and n between nodes to node K.

"Algorithm Evaluation"

Simulated annealing algorithm is a kind of stochastic algorithm, and it is not always possible to find the global optimal solution, and it can find the approximate optimal solution of the problem fairly quickly. If the parameters are set properly, the simulated annealing algorithm is more efficient than the exhaustive method.

Four, genetic algorithm

Genetic algorithm is a kind of evolutionary algorithm, which is used in computational mathematics to solve the optimal search algorithm. The evolutionary algorithm was originally developed by reference to some phenomena in evolutionary biology, the process of reproduction and development, through breeding, genetic crossover, Gene mutation, the adaptation of individuals will be phased out, and more adaptable individuals will be more and more. Then after the n generation of natural selection, the preserved individuals are highly adaptable.

The genetic algorithm is initially a poor solution of the solution set population, through genetic crossover to reproduce the next generation of the solution set population. In the process of crossover, there is a certain probability that a gene mutation occurs. In the next generation of solutions, by natural selection of the fittest, the poorer solutions (individuals) are eliminated, and only the better solution (individual) can reproduce, thus generating a population representing a new set of solutions. This process will result in a population that is more adaptable to the environment than the previous generation, as naturally evolving epigenetic populations. After many generations of breeding and natural selection, solutions that are close to the real optimal solution can be obtained.

The principle of elitism can be used to optimize the basic genetic algorithm. The so-called elitism principle is to prevent the optimal solution in the evolution process from being destroyed by crossover and mutation, and the optimal solution of each generation can be reproduced intact to the next generation.


V. Ant Colony algorithm

Ant colony Algorithm (Ant Colony Optimization, ACO), also known as Ant Algorithm, is a probabilistic algorithm for finding optimal paths in graphs. It was proposed by Marco Dorigo in his doctoral dissertation in 1992, inspired by the behavior of ants discovering pathways during the search for food.

As the ant moves along the path, it chooses the path it will take, based on the secretions left by the ants that pass by. The probability of selecting a path is proportional to the strength of the secretions on the path. Therefore, the collective behavior of groups composed of large numbers of ants actually constitutes a positive feedback phenomenon of learning information: The more ants a path passes, the greater the likelihood that the ant will choose that path. Through this information exchange, the ant's individual seeks the shortest path to the food.

Ant colony algorithm is based on this feature, by imitating the behavior of ants, so as to achieve optimization. When the program first finds the target, the path is almost impossible to be optimal, and may even contain countless wrong choices and be extremely verbose. However, the program can go through the pheromone principle of the ants looking for food, constantly correcting the original route, making the whole route shorter, and finally finding the best route.

The essence of this optimization process is:

Selection mechanism: The more pheromone path, the greater the probability of being chosen.

Update mechanism: The pheromone on the path increases with the passage of the ant, and fades away over time.

Coordination mechanism: ants are actually through secretions to communicate with each other and work together. Finally, the optimal solution is found by exchanging information and cooperating with each other, so that it has a strong ability to find better solutions.

Error mechanism: It is obvious that if ants move to a place with more pheromone, the problem of local optimal solution will be caused. However, there are always some rebellious spirit of the ants, will not move to more information, so you can jump out of the local optimal solution, find the global optimal solution. From:http://www.educity.cn/wenda/374356.html http://blog.csdn.net/kuvinxu/article/details/35772489

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.