Is best first search optimal and complete?
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
add a comment |
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
add a comment |
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
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
artificial-intelligence path-finding robotics heuristics best-first-search
asked Nov 15 '18 at 2:12
Ivan SanchezIvan Sanchez
62
62
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
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
add a comment |
Of course, if heuristic function underestimates the costs, best first search is not optimal. In fact, even if your heuristic function is exactly right, best first search is never guaranteed to be optimal. Here is a counter example. Consider the following graph:
The green numbers are the actual costs and the red numbers are the exact heuristic function. Let's try to find a path from node S to node G.
Best first search would give you S->A->G following the heuristic function. However, if you look at the graph closer, you would see that the path S->B->C->G has lower cost of 5 instead of 6. Thus, this is an example of best first search performing suboptimal under perfect heuristic function.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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
add a comment |
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.
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
add a comment |
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.
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.
edited Nov 15 '18 at 14:43
answered Nov 15 '18 at 14:37
Michal BidaMichal Bida
1,047524
1,047524
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
add a comment |
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
add a comment |
Of course, if heuristic function underestimates the costs, best first search is not optimal. In fact, even if your heuristic function is exactly right, best first search is never guaranteed to be optimal. Here is a counter example. Consider the following graph:
The green numbers are the actual costs and the red numbers are the exact heuristic function. Let's try to find a path from node S to node G.
Best first search would give you S->A->G following the heuristic function. However, if you look at the graph closer, you would see that the path S->B->C->G has lower cost of 5 instead of 6. Thus, this is an example of best first search performing suboptimal under perfect heuristic function.
add a comment |
Of course, if heuristic function underestimates the costs, best first search is not optimal. In fact, even if your heuristic function is exactly right, best first search is never guaranteed to be optimal. Here is a counter example. Consider the following graph:
The green numbers are the actual costs and the red numbers are the exact heuristic function. Let's try to find a path from node S to node G.
Best first search would give you S->A->G following the heuristic function. However, if you look at the graph closer, you would see that the path S->B->C->G has lower cost of 5 instead of 6. Thus, this is an example of best first search performing suboptimal under perfect heuristic function.
add a comment |
Of course, if heuristic function underestimates the costs, best first search is not optimal. In fact, even if your heuristic function is exactly right, best first search is never guaranteed to be optimal. Here is a counter example. Consider the following graph:
The green numbers are the actual costs and the red numbers are the exact heuristic function. Let's try to find a path from node S to node G.
Best first search would give you S->A->G following the heuristic function. However, if you look at the graph closer, you would see that the path S->B->C->G has lower cost of 5 instead of 6. Thus, this is an example of best first search performing suboptimal under perfect heuristic function.
Of course, if heuristic function underestimates the costs, best first search is not optimal. In fact, even if your heuristic function is exactly right, best first search is never guaranteed to be optimal. Here is a counter example. Consider the following graph:
The green numbers are the actual costs and the red numbers are the exact heuristic function. Let's try to find a path from node S to node G.
Best first search would give you S->A->G following the heuristic function. However, if you look at the graph closer, you would see that the path S->B->C->G has lower cost of 5 instead of 6. Thus, this is an example of best first search performing suboptimal under perfect heuristic function.
edited Mar 7 at 4:25
itsmysterybox
1,1043920
1,1043920
answered Mar 7 at 2:50
Shuto ArakiShuto Araki
11
11
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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