I am currently trying to use A* to create cyclical routes (for plotting driving routes of set distances). I want to find a driving route from my start location that is as close to my specified length as possible. If it is bigger or smaller that is fine, just as close as possibleI have therefore adapted the heuristic function to:|target distance-distance Travelled so far| + distance left to travel.for example, I want to travel 20 miles, so my target distance is 20. At some point in the route i may have travelled 18. Therefore my h would be 20-18+2 = 2. I always pick the smallest h value, the idea being a route of 20 miles will be created finished where i starts.I had 2 immediate issues with this. The Start node can't be added to the closed list immediately or it will never create a cyclical route - I believe I have solved this one.If the search goes into a cul-de-sac it gets stuck and the openlist becomes empty and the search terminates.The second problem I cannot think of how to solve. It occurs because the successor node that would get the search out of the cul-de-sac is already in the closed list. Can anyone help me come up with a general solution to my problem? Furthermore do you for see any other issues with my implementation? would really appreciate any help you can give.
Using A* search with different heuristic values
algorithms;search algorithms;search problem;searching
This problem is known as the Target Value Search Problem (TVS) and it can be succintly described as follows:Given a graph $G(V,E)$, two nodes $s$ and $t$ ($s, t\in V)$ and a target value $T$ find a path $P$ from $s$ to $t$ such that the cost of the path is as close as possible to $T$Of course, $s$ and $t$ might be the same node (as in your case). Note that the problem is not asking for paths (or, alternatively routes) whose cost equals exactly $T$ but that no path with a cost closer to $T$ exists. This is known as solving the Target Value Search Problem optimally. As usual, the cost of a path is defined as the sum of the costs of all edges traversed in the path.There are different variations of this problem. All of them are described in the paper:Carlos Linares Lpez, Roni Stern, Ariel Felner: Target-Value Search Revisited. IJCAI 2013The specific case that interests you most has been also investigated. You can find a short summary of results in the paper:Carlos Linares Lpez, Roni Stern, Ariel Felner: Solving the Target-Value Search Problem. SOCS 2014The best solution currently known (to the best of my knowledge) consists of applying a bidirectional search. From your considerations and the notes provided by other people contributing to this thread:You are right! The problem is that you'd like to come back to the same node but the route to traverse when going back is in the closed list. This problem is specifically addressed in the backwards search suggested in the algorithm $T^*$David Richerby is right also! A* should traverse a state space which is exponential.In fact, regarding the second comment. A very simple baseline for solving this problem consists of either using A$^*$ or IDA$^*$ in the path space. IDA$^*$ naturally generates paths (and thus it traverses a state space which can be exponentially large); A$^*$ can do that also if you just ignore nodes in the closed list! In both cases, a node is never re-expanded if and only if it is an ancestor of the current node. However, it seems to me that you might find this acceptable. In that case, you are forced to expand all nodes!Hope this helps,