Introduction to the Optimization algorithm article catalog (UPDATE):
1. Simulated annealing algorithm
2. Genetic algorithms
I. Mountain climbing algorithm (hill climbing)
This paper introduces the mountain climbing algorithm before simulated annealing. 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
two. 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 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 is moving higher than the current place to jump. 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.
three. Simulated annealing algorithm pseudo code code
* * * J (y): evaluation function Value * Y (i) at State y: represents the current state * Y (i+1): Indicates a new state * R: Used to control the cooling speed * T: System temperature, the system should initially be in a state of high temperature * T_min: temperature of the lower limit, if the temperature T reached T_min, Then stop searching */while (T > t_min) {DE = J (Y (i+1))-J (Y (i)); if (DE >= 0)//Expression moves to get a better solution, then always accept the move y (i+1) = y (i); To accept moves from Y (i) to Y (i+1) else {//function exp (de/t) range is (0,1), de/t larger, then exp (de/t) also if (exp (de/t) > Random (0, 1)) Y (i+1) = Y (i); Accept the move from Y (i) to Y (i+1)} t = R * t; Cooling annealing, 0<r<1. R the larger, cooler cooling, r smaller, faster cooling/* If 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 very fast, but may eventually reach a local optimal value */i + +; }
four. Using simulated annealing algorithm to solve the problem of traveling merchant
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.
Five. 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.
From here:http://www.cnblogs.com/heaad/reprint Please specify