Question

Shortestpathfinder and Efficiency


Badge +7

I would like to connect points without taking their order into account but instead their closeness.

Basically, I tried to build a line with all trhe points and then looked for the shortest path finder.

The algorithm seems corrects. However, It taking too much time when it has hundred of points to be treated.

Any ideas on how to improve the efficiency of the shortestpathfinder in this case?

 


3 replies

Userlevel 4
Badge +13

Hi @arthy If you want a quick solution, under Completion Conditions set the Number of Verifications to 0 and set a time-out (minutes) for how long you're willing to wait.

Userlevel 4
Badge +13

Hi @arthy If you want a quick solution, under Completion Conditions set the Number of Verifications to 0 and set a time-out (minutes) for how long you're willing to wait.

Hi @arthy A higher number of iterations is better too. I ran several tests on the same 167 random points and a time-out of 5 minutes. The Total Cost went lower as the number of iterations went higher - my last test had 10,000,000.

Userlevel 4
Badge +25

From what I understand... it's tough. This is what's called an NP problem, which means it is a very complex scenario that is solved in polynomial time. Each additional point you add to the set increases the time taken dramatically (on this graph you are looking at the teal-colored curve in the middle I believe)

In practice what it's doing is guessing a shortest route, then going to look at different routes to see if there is a shorter one (like this GIF). According to your settings, it will do this 10,000 times. Even then you aren't guaranteed that it is the absolute shortest route, just the shortest of the 10,000 attempts.

What I'd do is check the log file. Each time it finds a new shortest route, a message is logged stating how much shorter the route is. If the distance is still coming down dramatically after 10,000 iterations, then you might even want to increase the number to get a good result. If the distance is fairly stable after 100 iterations, then you might want to decrease the number of iterations, since the extra ones aren't getting much benefit.

As Dan says, you can also reduce the amount of verification going on. That's a big amount although - to be honest - I don't really know what it's doing to say if it's of value.

In short: it's a complex problem and I don't think there is a way to improve performance that much, apart from reducing the amount of calculations and checking, getting a potentially lesser result, but in less time. Either that or reduce the amount of points being considered.

Incidentally, you don't say how much time it's taking. Is it seconds, minutes, hours? Days!?

Reply