{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Admissible Heuristics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "An **admissible heuristic** is one that never overestimates the cost\n", "of the minimum cost path from a node to the goal node. So, a\n", "heuristic is specific to a particular state space, and also to a\n", "particular goal state in that state space. It must be **admissible**\n", "for all states in that search space.\n", "\n", "To help remember whether it is \"never overestimates\" or \"never\n", "underestimates\", just remember that an admissible heuristic is too\n", "optimistic. It will lead A\\* to search paths that turn out to be more\n", "costly that the optimal path. It will not prevent A\\* from expanding\n", "a node that is on the optimal path by producing a heuristic $h$ value\n", "that is too high.\n", "\n", "A stronger requirement on a heuristic is that it is **consistent**,\n", "sometimes called **monotonic**. A heuristic $h$ is consistent if its value is nondecreasing along a path. Mathematically, a heuristic $h$ is consistent if for\n", "every node $n$ of a parent node $p$,\n", "\n", "$$h(p) \\le h(n) + \\mathrm{stepcost}(p,n)$$\n", "\n", "Every consistent heuristic must be admissible. (How would you show\n", "this?) Sometimes showing a \n", "heuristic is consistent is a good way of proving it is admissible.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Example Robot Search Problem" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Proof of A\\* Optimality" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Section 3.5.2 describes one proof of A\\* optimality that relies on $h$\n", "being consistent. It proceeds as follows.\n", "\n", "For a goal node $n$, $f(n)$ is the true cost of the path from the\n", "start node to this goal node; $f(n) = g(n) + h(n) = g(n) + 0$ because\n", "$h(n)=0$ for goal nodes.\n", "\n", "If A\\* expands nodes in nondecreasing order of $f(n)$, then the first\n", "goal node selected for expansion must be an optimal solution, because\n", "for goal nodes $f(n)$ is the true cost of path to this goal node.\n", "\n", "We must show that A\\* expands nodes in nondecreasing order.\n", "\n", "Suppose node $n$ is a child of node $p$. Then\n", "\n", "\n", "$$\\begin{align*}\n", "f(n) &= g(n) + h(n)\\\\\n", " &= g(p) + \\mathrm{stepcost}(p,n) + h(n) & \\text{ because } g(n) = g(p) + \\mathrm{stepcost}(p,n)\\\\\n", " &\\ge g(p) + h(p) & \\text{ assuming } h \\text{ is consistent,\n", " meaning }\\\\\n", " & & ~~~~~~~~~ h(p) \\le h(n) + \\mathrm{stepcost}(p,n) \\\\\n", " &= f(p)\n", "\\end{align*}$$\n", "\n", "so\n", "\n", "$$\\begin{align*}\n", "f(n) &\\ge f(p)\n", "\\end{align*}$$\n", "\n", "In other words, if $h(n)$ is consistent for all $n$, then the values of $f(n)$ along\n", "any path are nondecreasing.\n", "\n", "Now we must show that whenever A\\* selects a node $n$ for expansion, an\n", "optimal path to that node has been found. If this were not true, another\n", "node $m$ must exist on the unexpanded (frontier) list through which a\n", "better path exists from start node to node $n$. But, this node would\n", "have a lower $f$ value and would be selected next instead of node\n", "$n$, a contradiction.\n", "\n", "Here is another way of proving that the optimal path to a goal is\n", "found. It only assumes the heuristic is admissible.\n", "\n", "Consider this situation.\n", "\n", "\n", "\n", "$a$ and $b$ both satisfy the goal function, but $b$ is optimal, $a$\n", "is not.\n", "\n", "Assume $a$ is selected before $n$. This will lead to a contradiction,\n", "showing this assumption is wrong.\n", "\n", "Let $f^*$ be the cost of the optimal path to $b$. Let $n$ be a parent\n", "node to $b$ on the optimal path to $b$.\n", "\n", "If $h$ is admissible,\n", "\n", "$$\\begin{align*}\n", "h(n) & \\le \\text{true optimal cost from }n\\text{ to a goal.}\\\\\n", "g(n) + h(n) &\\le g(n) + \\text{true optimal cost from }n\\text{ to a goal.}\\\\\n", "f(n) &\\le f^*\n", "\\end{align*}$$\n", "\n", "Since we are assuming $a$ is selected before $n$,\n", "\n", "$$\\begin{align*}\n", "f(a) & \\le f^*\\\\\n", "g(a) + h(a) & \\le f*\\\\\n", "g(a) &\\le f^* &\\text{because }a\\text{ is a goal node so }h(a)=0\n", "\\end{align*}$$\n", "\n", "This means we have just proved that the true cost to $a$, $g(a)$, is\n", "less than the optimal cost to a goal node, a contradiction. So, our\n", "assumption that a suboptimal goal is chosen was wrong." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Optimally Efficient" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "No other algorithm that extends search paths from the start node and\n", "uses the same heuristic information will expand fewer nodes that A\\*.\n", "\n", "However, maintaining the list of unexpanded frontier nodes can quickly\n", "consume all storage. This is why we focus on the\n", "recursive-best-first-search version of A\\*. Its iterative-deepening\n", "strategy of throwing away and regenerating nodes reduces the maximum\n", "number of nodes stored at any point of the algorithm. Its space\n", "complexity is linear in the depth of the deepest optimal solution. Its\n", "time complexity is hard to characterize as it depends on the accuracy\n", "of the heuristic function.\n", "\n", "This form of A\\* throws away too many nodes to be as efficient in time\n", "as it can be. Alternatives include the simplified memory-bounded A\\*,\n", "SMA\\*, algorithm. SMA\\* proceeds like a graph-based search maintaining\n", "the unexplored frontier list. When it runs out of memory, it deletes\n", "the node with the worst $f$ value and backs that value up to the\n", "deleted node's parent." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Heuristic Functions " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Okay, so we must have admissible heuristic functions, ones that never\n", "overestimate the true remaining cost to a goal. Are some admissible\n", "heuristics better than others?\n", "\n", "We want ones that mislead A\\* least often. A heuristic will mislead if\n", "its estimate of remaining cost to goal is much, much lower than the\n", "true cost. So, we want heuristics that are as close as possible to the true\n", "remaining cost for all nodes without going over the true cost, and\n", "thus overestimate and are not admissible. A heuristic $h_1$ is\n", "better than $h_2$ if $h_1(n) \\ge h_2(n)$ for all $n$. $h_1$ is said\n", "to \"dominate\" $h_2$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# A* Practice Exercise" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Complete the following A\\* search tree before next class. Answer will be discussed in class." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[A\\* star exercise](http://www.cs.colostate.edu/~anderson/cs440/notebooks/astarexercise.pdf)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [Root]", "language": "python", "name": "Python [Root]" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }