Intelligence 2E

foundations of computational agents

For many domains, arcs have non-unit costs, and the aim is to find an optimal solution, a solution such that no other solution has a lower total cost. For example, for a delivery robot, the cost of an arc may be resources (e.g., time, energy) required by the robot to carry out the action represented by the arc, and the aim is for the robot to solve a given goal using fewest resources. The cost for a tutoring system may be the time and effort required by a student. In each of these cases, the searcher should try to minimize the total cost of the path found to a goal.

The search algorithms considered thus far are not guaranteed to find the minimum cost paths; they have not used the arc cost information at all. Breadth-first search finds a solution with the fewest arcs first, but the distribution of arc costs may be such that a path with the fewest arcs is not one of minimal cost.

The simplest search method that is guaranteed to find a minimum cost path is lowest-cost-first search, which is similar to breadth-first search, but instead of expanding a path with the fewest number of arcs, it selects a path with the lowest cost. This is implemented by treating the frontier as a priority queue ordered by the cost function.

Consider a lowest-cost-first search from ${o}{\mathit{}}{\mathrm{103}}$ to ${r}{\mathit{}}{\mathrm{123}}$ in the graph given in Figure 3.2. In this example, the frontier is shown as a list of paths in order of cost, where paths are denoted by the node at the end of the path, with a subscript showing the cost of the path.

Initially, the frontier is ${\mathrm{[}}{o}{\mathit{}}{{\mathrm{103}}}_{{\mathrm{0}}}{\mathrm{]}}$. At the next stage it is ${\mathrm{[}}{b}{\mathit{}}{{\mathrm{3}}}_{{\mathrm{4}}}{\mathrm{,}}{{\text{\mathit{t}\mathit{s}}}}_{{\mathrm{8}}}{\mathrm{,}}{o}{\mathit{}}{{\mathrm{109}}}_{{\mathrm{12}}}{\mathrm{]}}$. The path to ${b}{\mathit{}}{\mathrm{3}}$ is selected, with the resulting frontier

$${[}{b}{}{{1}}_{{8}}{,}{{\text{\mathit{t}\mathit{s}}}}_{{8}}{,}{b}{}{{4}}_{{11}}{,}{o}{}{{109}}_{{12}}{]}{.}$$ |

The path to ${b}{\mathit{}}{\mathrm{1}}$ is then selected, resulting in frontier

$${[}{{\text{\mathit{t}\mathit{s}}}}_{{8}}{,}{c}{}{{2}}_{{11}}{,}{b}{}{{4}}_{{11}}{,}{o}{}{{109}}_{{12}}{,}{b}{}{{2}}_{{14}}{]}{.}$$ |

Then the path to ts is selected, and the resulting frontier is

$${[}{c}{}{{2}}_{{11}}{,}{b}{}{{4}}_{{11}}{,}{o}{}{{109}}_{{12}}{,}{{\text{\mathit{m}\mathit{a}\mathit{i}\mathit{l}}}}_{{14}}{,}{b}{}{{2}}_{{14}}{]}{.}$$ |

Then ${c}{\mathit{}}{\mathrm{2}}$ is selected, and so forth. Note how the lowest-cost-first search grows many paths incrementally, always expanding the path with lowest cost.

If the costs of the arcs are all greater than a positive constant (bounded arc costs) and the branching factor is finite, the lowest-cost-first search is guaranteed to find an optimal solution – a solution with lowest path cost – if a solution exists. Moreover, the first path to a goal that is expanded is a path with lowest cost. Such a solution is optimal, because the algorithm expands paths from the start node in order of path cost. If a better path to a goal existed than the first solution found, it would have been expanded from the frontier earlier.

The bounded arc cost is used to guarantee the lowest-cost search will find a solution, when one exists, in graphs with finite branching factor. Without such a bound there can be infinite paths with a finite cost. For example, there could be nodes ${n}_{0},{n}_{1},{n}_{2},\mathrm{\dots}$ with an arc $$ for each $i>0$ with cost $1/{2}^{i}$. Infinitely many paths of the form $$ all have a cost of less than 1. If there is an arc from ${n}_{0}$ to a goal node with a cost equal to 1, it will never be selected. This is the basis of Zeno’s paradox that Aristotle wrote about more than 2300 years ago.

Like breadth-first search, lowest-cost-first search is typically exponential in
both space and time. It generates *all* paths from the start that have
a cost less than the cost of a solution.