scaling factor for the cost distance between nodes in A* algorithm
I have a set data which is a collection of node - node - associated cost. This cost is represented as a开发者_C百科 distance in feet.
I also have a x-y-coordinate for each node. Now in the A* algorithm I will need to add the cost from node to node + the heuristic cost from the middle node to the destination. However, these two values needs to be having the same metric/unit. I can't have one in feet and the other one in coordinate distance.
I know that in order to do this I first need to find a scaling factor, to scale the cost from feet to x-y-coordinate distance. Right? All I can say is that all this cost is scalable. So this beta value will be the same for all pair of node-node.. Question is how do I find this value?
What I've done right now is to find the coordinate distance between node - node and then from that compare with the cost in feet. And I can therefore find a beta, which is a constant and should work for every node-node-cost (feet)... I am not sure if this is true though. I am not looking for a magic trick here, just a simple way/math to solve this
Usually we know that the grid is modeling the physical world at some scale factor. Do you not already know that?
In any case, I think your intuition is right. That is, figure the coordinate distance between two points where you know the actual cost in feet, divide one by the other and that's your scale factor. Assuming, of course, that the "cost" is the straight line distance between the two nodes.
That is, if the distance between node1 and node2 is, say, 3 feet, and the nodes' coordinates are [0,0]
and [0,9]
respectively, then the "scaling factor" is 3/9 ... or 9/3, depending on which way you want to do the conversion.
In this case, one unit in coordinate distance is 1/3 foot. Or one foot is 3 units in coordinate distance. So to go from coordinates to feet, you divide by 3. To go from feet to coordinates, you multiply by 3.
精彩评论