algorithm - Adding waypoints to A* graph search -


I have the ability to calculate the best route between a start and end point using A *. Right now, I add points between all the start and end points by applying A * to the pair in all the permutations of my points.

Example:

I want to get from point 1 to point 4. In addition, I want to pass points 2 and 3.

I compute the permutations of (1, 2, 3, 4):

  1 2 3 4 1 2 4 3 1 3 2 4 1 3 4 2 1 4 2 3 1 4 3 2 2 1 3 4 2 1 4 3 2 3 1 4 2 3 4 1 2 4 1 3 2 4 3 1 3 1 2 4 3 1 4 2 3 2 1 4 3 2 4 1 3 4 1 2 3 4 2 1 4 1 2 3 4 1 3 2 4 2 1 3 4 2 3 1 4 3 1 2 4 3 2 1 Then, for each permutation, I first I calculate the A * route from one to the other, then the third to the third place, then from third to the third number. 

When I calculate it for each permutation, then I fix the routes based on distance and at least return.

Obviously, this works, but it involves a lot of calculations and I have 6 ways (801 permutations items 40320: -))

Doing this Better way?

First of all, you should store all intermediate calculations. Once you calculate the route from 1 to 2, you should not do it again again, just look in a table. Second, if your article is unrestricted, the path between 2 to 1 is equal to the path from 1 to 2, so you should not resume it again.

And in the end, you have an algorithm in any case that is exponential for the number of digits required to pass by you. This journey is similar to the vendor's problem, and if you include all the available points, then it will actually be a problem. The problem is NP-complete, that is complexity in it, in the way the number of points are exponential.

So if you have a lot of points that you have to pass, the exponential collapse is inevitable.


Comments