Traveling Salesman Problem simplified version of the model

Learned, I got a linear model of dynamic programming.

Just in case, I'd better simplified version of the traveling salesman problem briefly explain the meaning of the questions.

The original traveling salesman problem is to find the shortest loop access to each city has one and only one lap in between cities. Now add the restriction: For each city, all numbers or all visited the city than this small city all else does not have access. For a whole so that we can get access to the queue an abstract two-way queue.

Start by adding 1,1 is fixed.
1
was then added 2,2 position may also be behind the front 1 1.
2. 1
2. 1
in both cases are legitimate, then we may also add the 3,3 position in the queue but not in front of or behind the middle of the queue.
. 1 2 3
. 1 2 3
3 2. 1
2 3. 1
and only the four legitimate in the case where n is equal to 3. For the next behavior pressed, only the ends of the elements of the queue state influential. Therefore, we define the state (i, j), two queues are represented by i and j and i is the minimum cost of the current queue, the largest element, i is greater than j remains. (Second case and third case is equivalent) so we get the state transition equation.

dp[i+1][j]=min(dp[i+1][j],dp[i][j]+dis[i+1][i]);
dp[i+1][i]=min(dp[i+1][i],dp[i][j]+dis[i+1][j]);

Problem of size n n-1 is actually only valid with a feasible solution.

Then for the last solved, we

dp[n][i](i<n)

To seek the minimum value.

Guess you like

Origin www.cnblogs.com/Schwarzkopf-Henkal/p/11752379.html