AI 笔记 Week 03 Search

This week you should watch Lecture 2, Search, and read Chapter 3 in *AIMA *(Russell & Norvig).

膜拜AI大神 Peter Norvig

challenge question

Which algorithm to choose to solve a tri-city problem?
AI 笔记 Week 03 Search_第1张图片
Challenge 2 Rubik’s Cube

Readings
Korf, 1997. Finding Optimal Solutions to Rubik's Cube Using Pattern Databases.
God's Number is 26 in the Quarter-Turn Metric.

Introduction

AI 笔记 Week 03 Search_第2张图片
Intro
  • Problem-solving: the theory, and technology of building agents to plan ahead to solve problems
AI 笔记 Week 03 Search_第3张图片
Definition of a problem

Example Route Finding

Route finding problem
  • Here we have 3 regions in the problem world: Frontier, explored and unexplored
  • Step costs are distances between cities and path cost is the sum of the step costs of all the steps on the path

Tree Search

AI 笔记 Week 03 Search_第4张图片
Tree search algorithm
  • Tree search is a set of algorithms: There are multiple ways to choose the frontier

Breadth-First Search

  • with the Breadth-First search, the algorithm always choose to explore the shortest path. In the example above, Arad goes to Zerind, Sibiu and Timisoara are the three shortest paths ( short in terms of depth, not distance or cost).
  • Quiz: Given Tree search, we are going to explore sibiu's next step, which city will be explored?
AI 笔记 Week 03 Search_第5张图片
the next fronts from "sibiu"
  • Answer: Rimic Vilcea, Fagaras, Oradea and Arad
  • Note: tree search will not know if the search resulted in a back-track path. (Thus Arad was explored again)
AI 笔记 Week 03 Search_第6张图片
Back-track path in Tree search
  • So we need to track the "explored region" of the tree so that they won't be visited again to avoid repeated search

Graph Search

avoid repeated search
AI 笔记 Week 03 Search_第7张图片
Quize: frontier to add if we visit Zerind
  • answer: nothing to add since Orada is already in the frontier and the path won't go back in a graph search algorithm
Quiz: what' the next state and is the problem solved?
  • the next state is the target city Bucharest
  • No, the problem is not solved, even the agent reached the target state.
  • the search won't stop when we add the goal state to the frontier
  • because the problem is not just to reach the target goal, but to meet the goal with the shortest path.
  • in this case, the upper path has shortest steps, but the cost is not the smallest.

Uniform Cost Search (AKA cheapest-first search)

AI 笔记 Week 03 Search_第8张图片
Which path to choose?
  • given Uniform Cost Search, the agent chooses the path with the cheapest cost first, thus, the Zerind path is chosen first.
  • after this, the cheapest path becomes Arad->Timisoara
AI 笔记 Week 03 Search_第9张图片
which to expand to next?
  • after each expansion of the frontier, the length of each available path will be evaluated and the cheapest path will be chosen to expand, until the goal state is reached.
Expand the cheapest path
expand rimnicu Vilcea
Expean Eugoj to Mehadia, and then Fagars to Bucharest
  • The search won't stop when it reaches the goal state.
  • The search will stop when it is moved out of the frontier not when it is added to the frontier
AI 笔记 Week 03 Search_第10张图片
  • the search going and we will find the path with a cost of 418 is the one pop out the goal state from frontier first.
  • and this is how the uniform cost search guaranteed the search of the cheapest path

Search Comparison

Breadth-first V.S. Cheapest-first V.S. Depth-first

AI 笔记 Week 03 Search_第11张图片
Find the search order and if the algorithm optimal
  • +++++++ don't understand why Depth-first is not optimal.
AI 笔记 Week 03 Search_第12张图片
Is all the search algorithms are complete?
  • Breadth-first and cheapest-first are complete
  • Depth-first is not complete given infinite steps of the tree.
  • Depth-first tree saves search space.

More On Uniform Cost

Uniform Cost will cost a lot of time when the search space is large.

  • Greedy best-first search can use smaller steps to reach the goal
  • but when there are obstacles on the way, the greedy best-first search will spend more time to find the goal
  • solution: combine Uniform Cost with Greedy Best-First search, that is A* search

Greedy best-first search

Greedy best-first search
Greedy best-first search with obstacles

A* Search

AI 笔记 Week 03 Search_第13张图片
formula
AI 笔记 Week 03 Search_第14张图片
example
  • In A* Search, we need to minimize g and h functions at the same time so that we will have the cheapest the path and also focus on reaching the goal.
Quiz: which path should we choose to explore next
  • here, g is the cost, h is the estimated the strait-line distance between each city to the goal.
  • A* chooses the smallest g + h as the path to explore
  • for the paths, see figures below
keep spending with A*
expanding...
The algorithm does not stop when the agent add the goal state into the frontier
A* finds the optimal paths
Will A* always find the optimal?
  • No. In the example above, h always shortens as g increases
  • what if reaching the goal requires the both g and h increases?
AI 笔记 Week 03 Search_第15张图片
Conditions h should meet

Optimistic Heuristic

AI 笔记 Week 03 Search_第16张图片
  • f(p) < f of other paths since it reached G the first
  • h(s) < true cost of S-> G, for the next step, f(s) =g(p)+g(s) -h(s) > f(g), so p will pop the G state out of the frontier, thus ends the search with the path p. (the argument is for tree search)

Quiz: State Spaces

Vacuum world

AI 笔记 Week 03 Search_第17张图片
How many states are in the space?
  • robot position = 2, cleaness of the position (clean/dirty) 22
  • 2 x 22 = 8
AI 笔记 Week 03 Search_第18张图片
all the states and connections between states
AI 笔记 Week 03 Search_第19张图片
state space 2
  • 3 x 2 x 5 x 10 x 210 =307200

Sliding Blocks Puzzle

AI 笔记 Week 03 Search_第20张图片
Sliding Blocks

Which function is admissible?
(what is admissible?)

Assume that a move in this game is moving a single block into the empty space (and cannot be a shift of multiple blocks).

  • h1 is admissible: each tile in the wrong position must be moved at least once to be in the correct position. it never overestimates
  • h2 is admissible: each tile in the wrong position can not move more than 1 blocks
  • h2 >= h1

Can the AI come up heuristic functions by itself?

AI 笔记 Week 03 Search_第21张图片
Generate h function be relaxing constrains
  • Where the heuristics can come from?
  • loosen the restriction of the problem can generate heuristic
  • relaxing restriction equals to adding operators in the problem and make the problem easier but never overestimates, thus, is admissible.
AI 笔记 Week 03 Search_第22张图片
Search only works when:
AI 笔记 Week 03 Search_第23张图片
implementing Search
  • path is linked nodes by parent pointer.
  • Notes can be dealt with data structure Frontier and Explored list
  • Frontier: moving best items and add items in the queue; membership check
  • Explored list: add new members and membership check. simple set: table or hash table

Readings

  • AIMA: Chapters 1-3
  • Korf, 1997. Finding Optimal Solutions to Rubik's Cube Using Pattern Databases.
    Further Information:
  • Goldberg, 2011. Reach for A∗ : An Efficient Point-to-Point Shortest Path Algorithm (slides).
  • Goldberg & Harrelson, March 2003. Computing the Shortest Path: A∗ Search Meets Graph Theory.
  • Gutman, 2004. Reach-based Routing: A New Approach to Shortest Path Algorithms Optimized for Road Networks.

Challenge Question Revisited

AI 笔记 Week 03 Search_第24张图片
challenge question
  • avoid repeatedly visiting explored notes
  • tri-directional search or A* search need to identify an admissible h function

Peter's Take On AI

Definition of AI: program computer to do the right thing when you don't know that the right thing is.

20170907 first try, stopped at "sliding block" 150 min
20170908 finished the rest 

你可能感兴趣的:(AI 笔记 Week 03 Search)