0

Given a Graph with a set of 5 nodes, 2 of which are goal nodes.

By running the algorithm it finds goal-1 node with a cost of 7 and it terminates.
Although, there's another goal, goal-2, with a cost of 6.

Is, finding the goal-1 as first solution correct? Or the optimal solution is for the A* to find the goal-2 with the cost of 6?

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
Chris
  • 3,619
  • 8
  • 44
  • 64
  • it should find goal 2. The heuristic should not be the same from one goal search to multiple goals search – UmNyobe Jan 09 '14 at 12:06
  • Is this your homework? – thiago.lenz Jan 09 '14 at 12:06
  • @UmNyobe: But A* simply uses a function f, that calculates the sum of the cost of the path that node N (g function) and the heuristic function simply has the distance from the current goal to a goal node. That is, in mathematical terms: f(n) = g(n) + h(n). – Chris Jan 09 '14 at 12:12
  • @thiago.lenz: It is a question that came to me when trying to solve an exercise. Should I tag this question as homework? – Chris Jan 09 '14 at 12:13
  • I am talking about `h(n)`. You meant "current node" and not "current goal" right? What I am saying is that you need to change `h(n)` – UmNyobe Jan 09 '14 at 12:45
  • @UmNyobe: Yes, I meant to write current node. The problem states that the algorithms stop when they find the first goal. So it's not a multiple goal problem, right? – Chris Jan 09 '14 at 12:53

1 Answers1

3

Is, finding the goal-1 as first solution correct?

Yes correct but not optimal

Or the optimal solution is for the A* to find the goal-2 with the cost of 6?

Indeed

A* rely on a heuristic to perform the search. You should provide different heuristics depending on whether you are performing a "one goal" or "multiple goals" search. If you have an admissible heuristic for one goal it does not mean it is admissible for multiple goals.

Your initial heuristic is h(x) = somedistance(x,g).

The generalized version is h'(x) = min{ somedistance(x,gi), gi in GoalSet }.

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
  • The problem defines our heuristic like this: The minimum number of paths from the current node to a goal node. So, we have to use this heuristic function. Considering the above, finding goal-1 is an acceptable solution, right? A* find the optimal path cost for goal-1, as there is another path with a cost of 12. – Chris Jan 09 '14 at 12:57
  • post in the question how you implemented this function – UmNyobe Jan 09 '14 at 13:09
  • "minimum number of paths" ? really ? – UmNyobe Jan 09 '14 at 13:12