Answers.Body: <p>No, the optimal path is found when you pop the goal state. If you stop the search when you first add the goal state then the final path may not be optimal. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-26T08:35:58.033Z
Answers.Text: Yeah, got it. The definition in the pic doesn't apply for weighted graph. Update Step is missing there. That'll solve it. So yeah, pop will be optimal for goal.
Answers.UserDisplayName: Fenil
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-02T10:52:00.950Z
Answers.Text: I'm not convinced this is true given the OP's mandate that we are ***"assuming a consistent heuristic"***. An example would help.
Answers.UserDisplayName: c z
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-26T06:45:51.003Z
Answers.LastActivityDate: 2019-09-26T06:45:51.003Z
Answers.UserDisplayName: DrMcCleod
Body: <p>I am going through Russel and Norvig's <em>Artificial Intelligence: A Modern Approach</em> (3rd edition). I was reading the part regarding the A* algorithm</p>
  
  <blockquote>
    <p>A* graph search version is optimal when heuristic is consistent and tree search version optimal when heuristic is just admissible.</p>
  </blockquote>
  
  <p>The book gives the following graph search algorithm.</p>
  
  <p><a href="https://i.sstatic.net/IHBOd.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IHBOd.jpg" alt="enter image description here"></a></p>
  
  <p>The above algorithm says that pop the node from the frontier set and expand it (assuming not in explored set), and add its children to frontier only if child not in frontier or explored set. </p>
  
  <p>Now, if I apply the same to A* (assuming a consistent heuristic) and suppose I find goal state (as a child of some node) for the first time I add it to the frontier set. Now, according to this algorithm, if the goal state is already in the frontier set, it must never be added again (this implies never be updated/promoted right?).</p>
  
  <p>I have a few questions.</p>
  
  <ol>
  <li><p>I might as well stop the search when I find goal state for the first time as a child of some node and not wait till I pop the goal state from the frontier?</p></li>
  <li><p>Does a consistent heuristic guarantee that when I add a node to the frontier set I have found the optimal path to it? (because if I don't update it or re-add it with updated cost (according to the graph search algorithm, the answer to the question must be yes.)  </p></li>
  </ol>
  
  <p>Am I missing something? Because it also states that, whenever A* selects the node for expansion, the optimal path to that node is found and doesn't say that when a node is added to the frontier set, the optimal path is found.</p>
  
  <p>So, I'm pretty confused, but I think the general graph search definition (in the above image) is misleading.</p>
  
Tags: <definitions><search><a-star><consistent-heuristic><graph-search>
Title: In the graph search version of A*, can I stop the search the first time I encounter the goal node?
UserDisplayName: Fenil
ThreadText: # In the graph search version of A*, can I stop the search the first time I encounter the goal node?
  
  (Asked by: username_0 on 2019-09-26)
  
  I am going through Russel and Norvig's *Artificial Intelligence: A Modern Approach* (3rd edition). I was reading the part regarding the A\* algorithm
  
  > A\* graph search version is optimal when heuristic is consistent and tree search version optimal when heuristic is just admissible.
  
  The book gives the following graph search algorithm.
  
  [![enter image description here](https://i.sstatic.net/IHBOd.jpg)](https://i.sstatic.net/IHBOd.jpg)
  
  The above algorithm says that pop the node from the frontier set and expand it (assuming not in explored set), and add its children to frontier only if child not in frontier or explored set.
  
  Now, if I apply the same to A\* (assuming a consistent heuristic) and suppose I find goal state (as a child of some node) for the first time I add it to the frontier set. Now, according to this algorithm, if the goal state is already in the frontier set, it must never be added again (this implies never be updated/promoted right?).
  
  I have a few questions.
  
  1. I might as well stop the search when I find goal state for the first time as a child of some node and not wait till I pop the goal state from the frontier?
  2. Does a consistent heuristic guarantee that when I add a node to the frontier set I have found the optimal path to it? (because if I don't update it or re-add it with updated cost (according to the graph search algorithm, the answer to the question must be yes.)
  
  Am I missing something? Because it also states that, whenever A\* selects the node for expansion, the optimal path to that node is found and doesn't say that when a node is added to the frontier set, the optimal path is found.
  
  So, I'm pretty confused, but I think the general graph search definition (in the above image) is misleading.
  
  **Tags:** definitions, search, a-star, consistent-heuristic, graph-search
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-09-26. Score: 0 | Accepted answer
  
  No, the optimal path is found when you pop the goal state. If you stop the search when you first add the goal state then the final path may not be optimal.
  
  > **Comments:**
  > **username_0**: Yeah, got it. The definition in the pic doesn't apply for weighted graph. Update Step is missing there. That'll solve it. So yeah, pop will be optimal for goal.  
  > **username_2**: I'm not convinced this is true given the OP's mandate that we are ***"assuming a consistent heuristic"***. An example would help.  
  
  ---
  
  