Learning Objectives

  • Review the components of a search problem
  • Describe the input-output behavior of a search algorithm
  • Be able to define key terminology related to search problems
    • Search tree
    • Node
    • Successor/Child
    • Predecessor/Parent
    • Expanding a node
    • Frontier
    • Interior, Exterior
  • Describe the general behavior of “best-first” search algorithms
  • Describe the specific behavior of Breadth-first, Depth-first, and Uniform-Cost search
  • Be able to reason about the complexity, completeness, and optimality of uninformed search algorithms
  • Compare and contrast uninformed search algorithms

Search Problems

Q: What are the components of a search problem?

Ask your neighbor!

State representation Actions State space Transition Model Initial State Action Cost Goal State

A:

  • State Representation
  • State Space
  • Actions
  • Transition Function
  • Action Cost Function
  • Initial State
  • Goal State

Implicit vs. Explicit

  1. Q: What do these terms mean to you?

    • Implicit - don’t have to literally say it
  2. What they mean here…

    Explicit: The whole thing is written down Implicit: The whole thing isn’t written down, but we have a way to figure it out

Search Algorithms

Input-Output behavior: Accept a “search problem” as input, and return a solution or an indication of failure.

Solution? Path from initial state to goal

Many search algorithms use a search tree

img

img

Terminology

Node: A node in a search tree corresponds to a state in the state space

“Expanding a node” means considering all the actions available to us in the state, and seeing where they would lead.

Expanding a node generates a successor node (child node) for each of the states that are one action away from the current state.

The frontier is the set of nodes that are one action away from an already expanded node.

The frontier separates the interior and exterior of the problem.

img

Affordances

“What can I do with this object?” img

Think about the methods of a class in OOP. See R&N Chapter 3.3.2

What to expand first? Out of all the actions I can take in this state, which one should I pick? Out of all the nodes in the frontier, which one to expand next?

Search algorithms differ in how they solve this dilemma.

Search problems differ in which strategy is optimal.

  1. “Best-First Search”

    A broad class of search algorithms.

    Best-first search algorithms expand the node in the frontier that is the best, according to some function

    We call the evaluation function

Uninformed Best-First Search Algorithms

Uninformed means these algorithms do not utilize heuristics

What’s a heuristic? More on that later.

  • Breadth-first search (BFS)
  • Depth-first search (DFS)
  • Uniform-cost Search (Dijkstra’s; UCS)

Informed Search Algorithms

  • Informed Search algorithms use heuristics to guide the search process

  • Greedy Best-first Search

  • A-star search

Properties of Search Algorithms

Time Complexity

How long does it take to find a solution?

Space Complexity

How much memory is needed to perform the search?

Completeness

Is the algorithm guarantee to find a solution if one exists, or report failure if there is no solution?

To be complete, the search algorithm must be systematic

  1. Q: What does systematic mean?

    Systematic: the algorithm can eventually reach any state that is connected to the initial state.

    The algorithm “leaves no stone unturned”.

    Think about your most meticulous, detail-oriented friend who won’t make a decision until they know all their options.

Cost Optimality

Does the algorithm find the best (lowest path cost) solution?

Action Optimality

Does the algorithm find the solution requiring the fewest number of actions?

Time complexity:

Time complexity measures the number of operations or time taken by an algorithm as a function of input size

Space complexity:

Space complexity measures of the amount of memory used by an algorithm as a function of input size

Worst/Best/Typical Case

Worst Case: What happens if everything doesn’t go in favor of the AI system

Typical Case: What happens in a typical scenario

Best Case: What happens if everything goes in favor of the AI system

All three analyses are useful, but we are often particularly concerned with worst-case behavior.

Branching Factor and Depth

In uninformed search, time and space complexity depend on the branching factor and depth of the search tree

  1. Branching factor ():

    The branching factor is the average number of successors for a state in the search tree

    Higher branching factor leads to a larger number of nodes to explore, increasing time complexity

  2. Depth ():

    Depth refers to the typical number of moves between the initial state and goal state.

    Branching factor for tic tac toe

    • Consider yourself as player 1
    • Go through a game
    • At each step, count up the moves available
  3. Branching Factor: Example

    img

What’s the naive solution?

What’s the “stupidest” search algorithm you can think of? Talk to your neighbor

  1. Time Complexity: where is the state space

  2. Space Complexity:

  3. Cost Optimality: Optimal

  4. Action Optimality: Optimal

  5. Completeness: Complete for finite state spaces

    Can be infinite for infinite search problems!

Algorithm Behavior

Expand the shallowest node first

img

Complexity

  • Breadth-first search (BFS) time complexity: where is the branching factor and is the depth of the shallowest goal node.

  • Breadth-first search (BFS) space complexity: where is the branching factor and is the depth of the shallowest goal node.

Optimality

  • Cost Optimality: Optimal only if all actions have the same cost, not in general
  • Action Optimality: Action-Optimal!

Completeness

Complete

  1. Algorithm Behavior

    Expand the node with the lowest cumulative cost from the root node to the current node

  2. Time Complexity

    , where is the cost of the optimal solution, and is a lower bound on the cost of each action.

  3. Space Complexity

  4. Cost Optimality

    Optimal

  5. Action Optimality

    Optimal

  6. Completeness

    Complete if costs are non-negative and is finite

  1. Algorithm Behavior

    Expand the deepest node first

  2. Complexity

    • Depth-first search (DFS) time complexity: where is the branching factor and is the maximum depth of the search tree.
    • Space Complexity:
  3. Cost Optimality

    NOT cost-optimal

  4. Action Optimality

    Not action-optimal

  5. Completeness

    Not complete in general

Complexity of Informed Search Algorithms

  • Informed Search algorithms use heuristics to guide the search process
  1. Algorithm Behavior

  2. Time Complexity:

  3. Space Complexity:

  4. Cost Optimality: Not optimal

  5. Action Optimality: Not optimal

  6. Completeness: Not complete

  1. Algorithm Behavior

  2. Time Complexity:

  3. Space Complexity:

  4. Cost Optimality: Optimal if heuristic is admissible

  5. Action Optimality: Optimal if heuristic is admissible

  6. Completeness: Complete