Is best first search optimal and complete?












1















I have some doubts regarding best first search algorithm. The pseudocode that I have is the following:
best first search pseudocode



First doubt: is it complete? I have read that it is not because it can enter in a dead end, but I don't know when can happen, because if the algorithm chooses a node that has not more neighbours it does not get stucked in it because this node is remove from the open list and in the next iteration the following node of the open list is treated and the search continues.



Second doubt: is it optimal? I thought that if it is visiting the nodes closer to the goal along the search process, then the solution would be the shortest, but it is not in that way and I do not know the reason for that and therefore, the reason that makes this algorithm not optimal.



The heuristic I was using is the straight line distance between two points.



Thanks for your help!!










share|improve this question



























    1















    I have some doubts regarding best first search algorithm. The pseudocode that I have is the following:
    best first search pseudocode



    First doubt: is it complete? I have read that it is not because it can enter in a dead end, but I don't know when can happen, because if the algorithm chooses a node that has not more neighbours it does not get stucked in it because this node is remove from the open list and in the next iteration the following node of the open list is treated and the search continues.



    Second doubt: is it optimal? I thought that if it is visiting the nodes closer to the goal along the search process, then the solution would be the shortest, but it is not in that way and I do not know the reason for that and therefore, the reason that makes this algorithm not optimal.



    The heuristic I was using is the straight line distance between two points.



    Thanks for your help!!










    share|improve this question

























      1












      1








      1








      I have some doubts regarding best first search algorithm. The pseudocode that I have is the following:
      best first search pseudocode



      First doubt: is it complete? I have read that it is not because it can enter in a dead end, but I don't know when can happen, because if the algorithm chooses a node that has not more neighbours it does not get stucked in it because this node is remove from the open list and in the next iteration the following node of the open list is treated and the search continues.



      Second doubt: is it optimal? I thought that if it is visiting the nodes closer to the goal along the search process, then the solution would be the shortest, but it is not in that way and I do not know the reason for that and therefore, the reason that makes this algorithm not optimal.



      The heuristic I was using is the straight line distance between two points.



      Thanks for your help!!










      share|improve this question














      I have some doubts regarding best first search algorithm. The pseudocode that I have is the following:
      best first search pseudocode



      First doubt: is it complete? I have read that it is not because it can enter in a dead end, but I don't know when can happen, because if the algorithm chooses a node that has not more neighbours it does not get stucked in it because this node is remove from the open list and in the next iteration the following node of the open list is treated and the search continues.



      Second doubt: is it optimal? I thought that if it is visiting the nodes closer to the goal along the search process, then the solution would be the shortest, but it is not in that way and I do not know the reason for that and therefore, the reason that makes this algorithm not optimal.



      The heuristic I was using is the straight line distance between two points.



      Thanks for your help!!







      artificial-intelligence path-finding robotics heuristics best-first-search






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 2:12









      Ivan SanchezIvan Sanchez

      62




      62
























          1 Answer
          1






          active

          oldest

          votes


















          2














          In general case best first search algorithm is complete as in worst case scenario it will search the whole space (worst option). Now, it should be also optimal - given the heuristic function is admissible - meaning it does not overestimate the cost of the path from any of the nodes to goal. (It also needs to be consistent - that means that it adheres to triangle inequality, if it is not then the algorithm would not be complete - as it could enter a cycle)



          Checking your algorithm I do not see how the heuristic function is calculated. Also I do not see there is calculated the cost of the path to get to the particular node.
          So, it needs to calculate the actual cost of the path to reach a particular node and then it needs to add a heuristics estimate of the cost of the path from the node towards goal.



          The formula is f(n)=g(n)+h(n) where g(n) is the cost of the path to reach the node and h(n) is the heuristics estimating the cost of the cheapest path from n to the goal.



          Check the implementation of A* algorithm which is an example of best first search on path planning.



          TLDR In best first search, you need to calculate the cost of a node as a sum of the cost of the path to get to that node and the heuristic function that estimate the cost of the path from that node to the goal. If the heuristic function will be admissible and consistent the algorithm will be optimal and complete.






          share|improve this answer


























          • The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

            – Ivan Sanchez
            Nov 16 '18 at 11:41











          • If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

            – Michal Bida
            Nov 16 '18 at 14:21











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311457%2fis-best-first-search-optimal-and-complete%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          In general case best first search algorithm is complete as in worst case scenario it will search the whole space (worst option). Now, it should be also optimal - given the heuristic function is admissible - meaning it does not overestimate the cost of the path from any of the nodes to goal. (It also needs to be consistent - that means that it adheres to triangle inequality, if it is not then the algorithm would not be complete - as it could enter a cycle)



          Checking your algorithm I do not see how the heuristic function is calculated. Also I do not see there is calculated the cost of the path to get to the particular node.
          So, it needs to calculate the actual cost of the path to reach a particular node and then it needs to add a heuristics estimate of the cost of the path from the node towards goal.



          The formula is f(n)=g(n)+h(n) where g(n) is the cost of the path to reach the node and h(n) is the heuristics estimating the cost of the cheapest path from n to the goal.



          Check the implementation of A* algorithm which is an example of best first search on path planning.



          TLDR In best first search, you need to calculate the cost of a node as a sum of the cost of the path to get to that node and the heuristic function that estimate the cost of the path from that node to the goal. If the heuristic function will be admissible and consistent the algorithm will be optimal and complete.






          share|improve this answer


























          • The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

            – Ivan Sanchez
            Nov 16 '18 at 11:41











          • If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

            – Michal Bida
            Nov 16 '18 at 14:21
















          2














          In general case best first search algorithm is complete as in worst case scenario it will search the whole space (worst option). Now, it should be also optimal - given the heuristic function is admissible - meaning it does not overestimate the cost of the path from any of the nodes to goal. (It also needs to be consistent - that means that it adheres to triangle inequality, if it is not then the algorithm would not be complete - as it could enter a cycle)



          Checking your algorithm I do not see how the heuristic function is calculated. Also I do not see there is calculated the cost of the path to get to the particular node.
          So, it needs to calculate the actual cost of the path to reach a particular node and then it needs to add a heuristics estimate of the cost of the path from the node towards goal.



          The formula is f(n)=g(n)+h(n) where g(n) is the cost of the path to reach the node and h(n) is the heuristics estimating the cost of the cheapest path from n to the goal.



          Check the implementation of A* algorithm which is an example of best first search on path planning.



          TLDR In best first search, you need to calculate the cost of a node as a sum of the cost of the path to get to that node and the heuristic function that estimate the cost of the path from that node to the goal. If the heuristic function will be admissible and consistent the algorithm will be optimal and complete.






          share|improve this answer


























          • The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

            – Ivan Sanchez
            Nov 16 '18 at 11:41











          • If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

            – Michal Bida
            Nov 16 '18 at 14:21














          2












          2








          2







          In general case best first search algorithm is complete as in worst case scenario it will search the whole space (worst option). Now, it should be also optimal - given the heuristic function is admissible - meaning it does not overestimate the cost of the path from any of the nodes to goal. (It also needs to be consistent - that means that it adheres to triangle inequality, if it is not then the algorithm would not be complete - as it could enter a cycle)



          Checking your algorithm I do not see how the heuristic function is calculated. Also I do not see there is calculated the cost of the path to get to the particular node.
          So, it needs to calculate the actual cost of the path to reach a particular node and then it needs to add a heuristics estimate of the cost of the path from the node towards goal.



          The formula is f(n)=g(n)+h(n) where g(n) is the cost of the path to reach the node and h(n) is the heuristics estimating the cost of the cheapest path from n to the goal.



          Check the implementation of A* algorithm which is an example of best first search on path planning.



          TLDR In best first search, you need to calculate the cost of a node as a sum of the cost of the path to get to that node and the heuristic function that estimate the cost of the path from that node to the goal. If the heuristic function will be admissible and consistent the algorithm will be optimal and complete.






          share|improve this answer















          In general case best first search algorithm is complete as in worst case scenario it will search the whole space (worst option). Now, it should be also optimal - given the heuristic function is admissible - meaning it does not overestimate the cost of the path from any of the nodes to goal. (It also needs to be consistent - that means that it adheres to triangle inequality, if it is not then the algorithm would not be complete - as it could enter a cycle)



          Checking your algorithm I do not see how the heuristic function is calculated. Also I do not see there is calculated the cost of the path to get to the particular node.
          So, it needs to calculate the actual cost of the path to reach a particular node and then it needs to add a heuristics estimate of the cost of the path from the node towards goal.



          The formula is f(n)=g(n)+h(n) where g(n) is the cost of the path to reach the node and h(n) is the heuristics estimating the cost of the cheapest path from n to the goal.



          Check the implementation of A* algorithm which is an example of best first search on path planning.



          TLDR In best first search, you need to calculate the cost of a node as a sum of the cost of the path to get to that node and the heuristic function that estimate the cost of the path from that node to the goal. If the heuristic function will be admissible and consistent the algorithm will be optimal and complete.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 14:43

























          answered Nov 15 '18 at 14:37









          Michal BidaMichal Bida

          1,037423




          1,037423













          • The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

            – Ivan Sanchez
            Nov 16 '18 at 11:41











          • If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

            – Michal Bida
            Nov 16 '18 at 14:21



















          • The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

            – Ivan Sanchez
            Nov 16 '18 at 11:41











          • If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

            – Michal Bida
            Nov 16 '18 at 14:21

















          The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

          – Ivan Sanchez
          Nov 16 '18 at 11:41





          The thing is that in the book "Artificial Intelligence: a modern approach", the book I am studying (its pdf can be found easily in Google), when talking about this algorithm it sais that best first is neither optimal not complete and that's why I am doubtful because until that moment the book does not talk about admissibility and consistency for heuristics. Maybe is it asumming neither optimal not complete because of the probability of using a non consistent heuristic and enter into a cycle so in this case the algorithm does not find a solution? I am quite confuse, any idea?. Thanks you!!!

          – Ivan Sanchez
          Nov 16 '18 at 11:41













          If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

          – Michal Bida
          Nov 16 '18 at 14:21





          If you do not put any contraints on the heuristic function then indeed the algorithm is not optimal or complete in the general case. Not it seems that it does not make sense to develop such algorithm but in some cases "messing up" with the heuristic function can lead to faster solutions. Generally, you do not do that though.

          – Michal Bida
          Nov 16 '18 at 14:21




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311457%2fis-best-first-search-optimal-and-complete%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python