Domanda

My research is about find a shortest path between an origin and a destination predefined. Both (origin and destination) were located using the GIS extension, because they were obtained by a shape file. I used the command ask patches gis:intersecting shapefile to create a person in an origin and a school in the destination.

I have 10 origins and for each I have a specify destination. I noticed that when I use the Dijsktra's algorithm to find the shortest path, for certain origin the destination isn't the respective point but the closest destination. So, my doubt is: Is the Dijsktra's the best algorithm for my problem or I need to use the A* algorithm?

If the Dijsktra's algorithm is the best, how do I inform the pairs origin and destination in the code?

If the A* algorithm is the best, how do I construct the code in the version 5.0 of Netlogo?

È stato utile?

Soluzione

Not sure about netlogo, but since your question doesn't quote it in the tags I'll assume an algorithm oriented answer is ok.

Dijkstra and A* are similar; both look and find the shortest path from one point to another. A* is more effective when you've got a known-in-advance destination as it optimally looks for the shortest possible path through the heuristics, while dijkstra exapnds more nodes in your graph by searching all directions.

If you find that Dijkstra returns a path to a different destination than the one you expect, you should consider verifying the destination detection: you should conclude the dijkstra searcg when you find THAT destination, not ANY destination.

A* doesn't suffer so much of the same since the heuristics will point them towards the correct destination, but can in special cases find the same problem (i.e. shortest path to correct destination passes through a different destination).

TO be more precise, I'd need some code - pseudocode is ok - of your conclusion, or details on the graph.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top