0

I am new to the field of shortest-path problems but after a fair amount of Googling, I think my problem is a variation on the TSP.

I have multiple frames/planes of points scattered on a 2D grid and must select one point from each frame sequentially so that the cartesian distance between successive points is minimized. Each point can only be selected once.

Alternatively, the problem can be viewed as points mixed on a single plane with X = {x1, x2, ..., xn} possible categorizations , and the points must be selected one at a time in a path from x1 to xn, repeated until all points have been selected. (In this formulation, however, there may be multiple points at a single location, so perhaps it makes more sense to say they are separated by an imaginary distance, as above.)

I don't need an exact solution, just a decent-looking heuristic. All paths between points must be less than a threshold cartesian distance T, and this is more important than minimizing total path length. (I assume that minimizing the paths selected between all the various nodes in each category will result in a minimum total path length, however, it is theoretically possible that one or two large paths would allow for all other points to be minimized to a degree that would overshadow those large outlier distances. That solution must be rejected.)

The number of nodes per category is on the order of ~200-400, and the number of categories around 200-900 (inversely related - the more categories, the fewer points in each.) There are exactly the same number of points in each category.

The points are scattered on each frame(/category) in a random way that is denser toward the center, so while there are many acceptable solutions toward the center of the plane, the edges have a very sparse scattering of points. I keep running into problems at those outer edges, e.g. where choosing the next point to minimize the distance between frame 2 and 3 on iteration n means that the point chosen on frame 2 for iteration n+1 has no point on frame 3 nearer than T.

enm
  • 1
  • 3
  • What do you mean by "frame of points"? – Dai Feb 25 '21 at 03:58
  • https://en.wikipedia.org/wiki/Euclidean_distance – aran Feb 25 '21 at 04:01
  • @Dai I mean a set of points on a 2D plane (that in my real world problem corresponds to something like a single frame of a movie.) There are multiple sets of points, where points within a set possibly overlap, which is why I prefer to think of them as a 3D matrix, with each plane of the matrix being a binary label for which points belong to that set from all possible locations (where the possible locations are bounded by a 256x128 matrix.) In a simplified 1D case, I would end up with the 2D matrix [0 1 1 0 1; 1 1 0 1 0; 1 0 0 1 1], i.e. each set has 3 points in the possible range of x = 1-5. – enm Feb 25 '21 at 04:31
  • @aran Your response make me wonder if my problem description wasn't clear enough, because I'm not sure what you are responding to. – enm Feb 25 '21 at 04:34
  • **An Optimal Algorithm for Euclidean Shortest Paths in the Plane** -- https://research.monash.edu/files/319671243/316401219_oa.pdf – aran Feb 25 '21 at 06:24
  • **It discusses the 3D Euclidean distance followed by Distance transformations by acquiring and deriving approaches. The chapter presents the shortest path planning** https://www.researchgate.net/publication/315737423_Distance_Transformation_and_Shortest_Path_Planning – aran Feb 25 '21 at 06:46
  • Thank you @aran. Yes I am somewhat new to this area, although I had a brief, basic introduction a while ago. This would work for me if I only needed a single path from the first plane to the last. However I need a path going from plane 1 to plane N, then back to plane 1 to plane N (until all points have been visited) without repeating points. Therefore choosing a point for my first path might adversely affect the distance of a later path, and it would have been better to choose a different point to minimize the total length of both path choices. Does that make sense? – enm Feb 25 '21 at 15:26
  • It makes total sense. Indeed, thats how all these mechanisms work. Your context is exactly what these algorithms are meant to. Just think of It, how would they identity a shortest path, without knowing the other paths? Regardless of how many times you must go back and forth; that would only mean calculating another shortest path. – aran Feb 25 '21 at 15:55
  • https://en.m.wikipedia.org/wiki/Dijkstra%27s_algorithm take a look at that. *A demo of Dijkstra's algorithm based on Euclidean distance. Red lines are the shortest path covering, i.e., connecting u and prev[u]. Blue lines indicate where relaxing happens, i.e., connecting v with a node u in Q, which gives a shorter path from the source to v.* https://en.m.wikipedia.org/wiki/File:DijkstraDemo.gif – aran Feb 25 '21 at 16:00
  • Thanks aran, I decided to try implementing it to clarify my confusions. If I use Dijkstra's algorithm, I can find the shortest path from a specific point in frame 1, through to N and back to frame 1, but there the cycle ends. I would then have to delete the used nodes and specify a new destination point in frame 1 to create another cycle, but this would mean that each cycle through the frames was separate and didn't take into account the total path of all cycles. How do I code in continuous path cycles until all points are selected -especially since I don't which "should" be the final point? – enm Feb 28 '21 at 22:48
  • Additionally, just a single iteration through 300 frames takes just about one minute, and there are almost 700 points per frame. I would have to run this code for hours, or parallelize it somehow. I'm using the graphshortestpath function in Matlab. – enm Feb 28 '21 at 23:13

0 Answers0