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
-
Q: What do these terms mean to you?
- Implicit - donât have to literally say it
-
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
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.
Affordances
âWhat can I do with this object?â
Think about the methods of a class in OOP. See R&N Chapter 3.3.2
The core problem in search
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.
-
â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
-
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?
Complexity of Uninformed Search
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
-
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
-
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
-
Branching Factor: Example
Whatâs the naive solution?
Whatâs the âstupidestâ search algorithm you can think of? Talk to your neighbor
Exhaustive Search
-
Time Complexity: where is the state space
-
Space Complexity:
-
Cost Optimality: Optimal
-
Action Optimality: Optimal
-
Completeness: Complete for finite state spaces
Can be infinite for infinite search problems!
Breadth-first search
Algorithm Behavior
Expand the shallowest node first
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
Dijkstraâs Algorithm (Uniform-Cost Search)
-
Algorithm Behavior
Expand the node with the lowest cumulative cost from the root node to the current node
-
Time Complexity
, where is the cost of the optimal solution, and is a lower bound on the cost of each action.
-
Space Complexity
-
Cost Optimality
Optimal
-
Action Optimality
Optimal
-
Completeness
Complete if costs are non-negative and is finite
Depth-first search
-
Algorithm Behavior
Expand the deepest node first
-
Complexity
- Depth-first search (DFS) time complexity: where is the branching factor and is the maximum depth of the search tree.
- Space Complexity:
-
Cost Optimality
NOT cost-optimal
-
Action Optimality
Not action-optimal
-
Completeness
Not complete in general
Complexity of Informed Search Algorithms
- Informed Search algorithms use heuristics to guide the search process
Greedy Best-first Search
-
Algorithm Behavior
-
Time Complexity:
-
Space Complexity:
-
Cost Optimality: Not optimal
-
Action Optimality: Not optimal
-
Completeness: Not complete
A-star search
-
Algorithm Behavior
-
Time Complexity:
-
Space Complexity:
-
Cost Optimality: Optimal if heuristic is admissible
-
Action Optimality: Optimal if heuristic is admissible
-
Completeness: Complete