Simulated Annealing Algorithm
The simulated annealing algorithm is derived from the solid annealing principle. The solid is heated to a sufficiently high level, and then cooled slowly. when heated, the particles inside the solid become unordered with the temperature rise, and the internal energy increases, when slowly cooling, the particles gradually become orderly. When each temperature reaches the equilibrium state, and finally reaches the ground state at normal temperature, the energy can be reduced to a minimum. According to the Metropolis principle, the probability that the particle tends to be balanced at the temperature T is e-△e/(KT), where E is the internal energy when the temperature T, and △e is the amount of change, K is the Boltzmann constant. Using Solid-State annealing to simulate the combination optimization problem, the internal energy E is simulated as the target function value F, and the temperature T is evolved into the control parameter T, that is, the simulated annealing algorithm for solving the combination optimization problem is obtained: start from initial solution I and initial value T of the control parameter, repeat the iteration of the current solution to "generate a new solution → calculate the target function deviation → accept or discard", and gradually decrease the tvalue, the current solution at algorithm termination is the obtained approximate optimal solution. This is a heuristic random search process based on the Monte Carlo iterative solution. The annealing process is controlled by the cooling schedule, including the initial value T of the Control Parameter and its attenuation factor △t, the number of iterations of each tvalue l, and the condition s.
1. Model of Simulated Annealing Algorithm
The simulated annealing algorithm can be divided into three parts: solution space, target function, and initial solution.
The basic idea of simulated annealing:
(1) initialization: the initial temperature T (sufficiently large), the initial solution state s (the starting point of the algorithm iteration), and the number of iterations of each t value L
(2) For k = 1 ,......, L perform steps (3) to 6th:
(3) generate a new solution s ′
(4) Calculate the incremental △t' = C (s')-C (s), where C (s) is the evaluation function.
(5) If △t' <0, it accepts s' as the new current solution. Otherwise, it accepts s' as the new current solution by probability exp (-△t'/T.
(6) If the termination condition is met, the current solution is output as the optimal solution and the program is ended.
The termination condition is usually set to terminate an algorithm when several consecutive new solutions are not accepted.
(7) T gradually decreases, and t-> 0, then go to step 1.
The algorithm corresponds to a dynamic presentation diagram:
The generation and acceptance of the new solution of the simulated annealing algorithm can be divided into the following four steps:
The first step is to generate a new solution located in the solution space from the current solution of a production function. To facilitate subsequent computation and acceptance, reduce the algorithm time consumption, generally, a method is used to generate a new solution after a simple transformation of the current new solution, for example, replacing or swapping all or part of the elements that constitute the new solution, note that the transformation method of the new solution determines the structure of the neighborhood of the current new solution, which affects the selection of the cooling schedule.
The second step is to calculate the target function difference corresponding to the new solution. Because the objective function difference is only generated by the transformation part, it is best to calculate the objective function difference in incremental mode. Facts show that for most applications, this is the fastest way to calculate the objective function difference.
The third step is to determine whether a new solution is accepted. The judgment is based on an acceptance criterion. The most common acceptance criterion is the metropo1is criterion: if △t' <0, then the s 'is accepted as the new current solution S. Otherwise, the probability exp (-△t'/T) is accepted as the new current solution S.
Step 4: when the new solution is determined to accept, replace the current solution with the new solution, which only needs to implement the transformation part corresponding to the new solution, modify the target function value. At this time, the current solution implements an iteration. Next round of tests can be started on this basis. When the new solution is determined to be discarded, the next round of test will continue on the basis of the current solution.
The simulated annealing algorithm has nothing to do with the initial value, and the solution obtained by the algorithm has nothing to do with the initial solution state s (the starting point of the algorithm iteration). The simulated annealing algorithm has the gradual convergence, theoretically, it has been proved that it is a global optimization algorithm that converges at the global optimal solution with probability L. The simulated annealing algorithm has parallelism.
2 simple application of Simulated Annealing Algorithm
As an application of the simulated annealing algorithm, we discuss the traveling salesman problem (TSP): It has n cities and uses digital 1 ,..., N stands. The distance between city I and city J is d (I, j) I, j = 1 ,..., N. The TSP problem is to find a loop that is exactly once visited every city, and its path length is the shortest ..
The simulated annealing algorithm model for solving TSP can be described as follows:
Solution Space solution space s is all the loops that occur exactly once in every city, which is {1 ,......, A set of all loops of n}. The members in S are marked as (W1, W2 ,......, And remember Wn + 1 = W1. The initial solution can be (1 ,......, N)
The target function at this time is the total length of the path to access all cities or the cost function:
We require the minimum value of this cost function.
The generation of the new solution randomly generates two different K and M values between 1 and N. If K <m
(W1, W2 ,..., Wk, wk + 1 ,..., WM ,..., Wn)
Changed:
(W1, W2 ,..., WM, wm-1 ,..., WK + 1, wk ,..., Wn ).
If K> m
(W1, W2 ,..., Wk, wk + 1 ,..., WM ,..., Wn)
Changed:
(WM, wm-1 ,..., W1, WM + 1 ,..., Wk-1, Wn, wn-1 ,..., WK ).
The above transformation method can be simply described as "reversing the middle or reversing the two ends ".
You can also use other transformation methods. Some transformations have unique advantages, and sometimes they are used in turn to obtain a better method.
The cost function is set to (W1, W2 ,......, Wn) to (U1, U2 ,......, UN), the cost function difference is:
Based on the above analysis, you can write a pseudo program that uses the simulated annealing algorithm to solve the TSP problem:
Procedure tspsa:
Begin
Init-of-T; {T is the initial temperature}
S = {1 ,......, N };{ S is the initial value}
Termination = false;
While termination = false
Begin
For I = 1 to l do
Begin
Generate (s' Form S); {generate new circuit s' from current circuit s ′}
△T: = f (s ')-f (s); {f (s) is the total path length}
If (△t <0) or (exp (-△t/T)> random-of-[0, 1])
S = s ′;
If the-halt-condition-is-true then
Termination = true;
End;
T_lower;
End;
End
The simulated annealing algorithm is widely used and can solve the Max cut problem, Zero One knapsack problem, and graph coloring problems with high efficiency) scheduling problem.
3. Parameter Control of simulated annealing Algorithms
The simulated annealing algorithm is widely used and can solve the NP-complete problem, but its parameters are difficult to control. The main problems are as follows:
(1) The Initial Value Setting of temperature T.
The initial value setting of temperature T is one of the important factors affecting the global search performance of the simulated annealing algorithm. When the initial temperature is high, it is more likely to find the global optimal solution, but it takes a lot of time to calculate it; however, global search performance may be affected. In practice, the initial temperature usually needs to be adjusted several times based on the experiment results.
(2) The annealing speed problem.
The global search performance of the simulated annealing algorithm is also closely related to the annealing speed. In general, it is quite necessary to search (annealing) at the same temperature, but this requires computing time. In practical application, we need to set reasonable annealing conditions for the nature and features of specific problems.
(3) temperature management problems.
The temperature management problem is also one of the problems that the simulated annealing algorithm is difficult to solve. In practical application, the following cooling method is often used because the practical feasibility of computing complexity must be considered:
T (t + 1) = K × T (t)
In formula, K is a constant slightly less than 1.00, and T is the number of times of cooling.
Please note that the program implementation is in progress (to be continued ).