Solving tsp problem by simulated annealing algorithm

Source: Internet
Author: User

I. Description of the problem

The traveling salesman problem, that is TSP (travelling salesman Problem), is one of the famous problems in the field of mathematics. Suppose a traveling businessman wants to visit N cities, he must choose the path he wants to take, the limit of which is that each city can only visit once, and finally return to the original city. The path's selection target is the minimum value in all paths required for the path to be travelled.

Fig. 1 schematic diagram of the TSP problem

Second, traversal algorithm

One of the easiest ways to think about it is to use permutations and combinations to calculate all the paths, and to compare them to select the smallest path. Although the method is feasible theoretically, the number of paths and the number of cities increase exponentially, when the number of cities is large, the solution time of this method is unbearable, even impossible to complete. Estimated at 100 million times per second, if the TSP problem contains 20 cities, the solution time is up to 350 years, and if 30 cities are to be processed, the solution time is longer than 1+10e16 years. Such a long time, in the actual completion is unimaginable.

Third, simulated annealing algorithm

Simulated annealing algorithm is one of the effective methods to solve TSP problem, its initial thought was proposed by Metropolis in 1953, Kirkpatrick successfully applied it in the combinatorial optimization problem in 1983.

The simulated annealing algorithm is derived from the principle of solid annealing the solid heat to the full height, and then let it slowly cooling, heating, solid particles with temperature rise into disorder, internal energy, and slowly cooling particles gradually orderly, at each temperature to achieve equilibrium, and finally at room temperature to the ground state, internal energy reduced to the minimum. Using the solid annealing simulation combinatorial optimization problem, the internal energy E is simulated as the objective function value F, the temperature T evolved into the control parameter T, that is, the simulated annealing algorithm for solving combinatorial optimization problems: Starting with the initial solution I and the initial value T of the control parameter, the iteration of "producing new solution → calculating objective function difference → accepting or discarding" is repeated to the current solution. and gradually decay the T value, the current solution at the end of the algorithm is the approximate optimal solution, which is a heuristic random search process based on Monte Carlo iterative method.
The simulated annealing algorithm model for solving TSP can be described as follows:

Solution Space: Solution Space S is all the paths that happen once in every city, the solution can be expressed as {w1,w2,......, wn},w1 ..., WN is an arrangement of 1,2,......, N, which indicates that the W1 city embarks, after W2, ..., wn the city, and returns to the W1 city. The initial solution can be selected as (1,......, N);

Objective function: The target function is the total length of the path to access all cities;

The optimal path we require is the path corresponding to the minimum value of the target function.

Generation of new paths: randomly producing two different numbers k and m between 1 and N, suppose K<m, the original path

(w1,w2,..., wk,wk+1,..., wm,wm+1,..., wn)

Change to New path:

(w1,w2,..., wm,wk+1,..., wk,wm+1,..., wn) The above transformation method is to exchange the position of the two cities corresponding to K and m in the path sequence, called the 2-opt mapping. According to the above description, the flow diagram of the simulated annealing algorithm to solve TSP problem is as follows

Fig. 2 Flow diagram of simulated annealing algorithm

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.