Академический Документы
Профессиональный Документы
Культура Документы
Motivation
moebius puzzle
Moebius puzzle
Rubiks cube
Tetris
2
Today
Robotics
Reasoning
Search
Learning
Informed search
Perception
Uninformed search
Agent
Hill climbing
Best-First
A*
Summary
Planning
Natural
language
KnowledgeConstraint
rep. satisfaction
...
Expert
Systems
Example: 8-Puzzle
8
Initial state
Goal state
State: Any arrangement of 8 numbered tiles and an empty tile on a 3x3 board
(n2-1)-puzzle
10 11 12
8-puzzle
....
13 14 15
15-puzzle
15-Puzzle
Invented in 1874 by Noyes Palmer Chapman
but Sam Loyd claimed he invented it!
15-Puzzle
Sam Loyd even offered $1,000 of his own
money to the first person who would solve the
following problem:
1
10
11
12
13
14
15
10
11
12
13
15
14
7
State Space
Heuristic search:
State Space
Initial State
2.
Set of operators
3.
4.
starting state
ex. unsolved puzzle, being at home
Initial state
Goal state
Set of operators:
blank moves up, blank moves down, blank moves left, blank moves right
Goal test function:
state matches the goal state
Path cost function:
each movement costs 1
so the path cost is the length of the path (the number of moves)
source: G. Luger (2005)
11
7
4
S
1
3
State space S
Successor function:
xS SUCCESSORS(x)
Initial state s0
Goal states:
xS GOAL?(x) =T or F
Arc cost
13
State Graph
Each state is
represented by a
distinct node
An arc (or edge)
connects a node s
to a node s if
s SUCCESSOR(s)
The state graph may
contain more than one
connected component
14
15
Nb of states:
It is often not
feasible (or too
expensive) to
build a complete
representation
of the state
graph
17
3
6
Initial state
Goal state
18
19
Search tree
20
Salesperson has
to visit 5 cities
must return home afterwards
minimize cost and/or time of
travel
21
22
Today
Uninformed search
Informed search
Summary
23
Uninformed search
24
Today
Uninformed search
Informed search
Summary
25
Depth-first:
Breadth-first:
26
Data Structures
ex:
Closed = [A, B, C, D, E]
Open = [K, L, F, G, H, I, J]
27
Data Structures
8 2
3 4 7
5 1
PARENT-NODE
6
BOOKKEEPING
CHILDREN
...
Action
Right
Depth
Path-Cost
Initialize the open list with the initial node so (top node)
2.
3.
Repeat
a)
b)
c)
d)
e)
Notes:
The order of the nodes in the open list depends on the search
strategy
29
DFS and BFS differ only in the way they order nodes in the
open
list:
DFS uses a stack:
nodes are added on the top of the list.
30
Breadth-First Search
a)
b)
c)
d)
e)
31
32
Snapshot of BFS
Search graph at
iteration 6 of
breadth-first
search
States on open
and closed are
highlighted
33
Goal
34
d)
e)
35
36
Snapshot of DFS
Search graph at
iteration 6 of
depth-first
search
States on open
and closed are
highlighted
37
Goal
38
Breadth-first:
Complete: always finds a solution if it exists
Optimal: always finds shortest path
But:
inefficient if branching factor B is very high
memory requirements high -- exponential space for states
required: Bn
Depth-first:
Not complete (ex. may get stuck in an infinite branch)
Not optimal (will not find the shortest path)
But:
Requires less memory -- only memory for states of one path
needed: B
n
May find the solution without examining much of the search space
Efficient if solution path is known to be long
39
Depth-limited Search
Iterative deepening search
Uniform-cost search
Bidirectional search
40
Today
Uninformed search
Informed search
Summary
41
Depth-Limited Search
Compromise for DFS :
Solution
Failure (no solution)
Cutoff (no solution within cutoff)
42
Today
Uninformed search
Informed search
Summary
43
Iterative Deepening
Compromise between BFS and DFS:
use depth-first search, but
with a maximum depth before going to next level
44
45
46
47
48
Today
Uninformed search
Informed search
Summary
49
50
51
52
Informed Search
Heuristic - Heureka!
Heuristic:
Heuristic search:
1.
2.
Today
Uninformed search
Informed search
Summary
56
Operators:
pickUp(Block)
putOnTable(Block)
stack(Block1,Block2)
Heuristic:
h(initial) = 2
h(goal) = 0
pickUp(A)+putOnTable(A)
h(n) = 1
pickUp(A)+stack(A,H)
pickUp(H)+putOnTable(H)
pickUp(H)+stack(H,A)
h(n) = 2
h(n) = 2
h(n) = 2
58
Hill Climbing
59
pickUp(A)+putOnTable(A)
h(n) = 1
pickUp(A)+stack(A,H)
pickUp(H)+putOnTable(H)
pickUp(H)+stack(H,A)
Dont be confused
a lower h(n) is better
So with lower h(n),
hill-climbing should really be
called deep-diving
h(n) = 2
h(n) = 2
h(n) = 2
60
61
Plateau
62
Random-restart hill-climbing
keep going even if the best successor has the same value as
current node
source: Rich & Knight, Artificial Intelligence, McGraw-Hill College 1991. & Russel & Norvig (2003)
63
Today
Uninformed search
Informed search
Summary
64
Best-First Search
solution to hill-climbing:
Best-first search:
65
Best-First: Example
Notes on Best-first
67
3
4
68
69
Designing Heuristics
70
3
6
STATE n
Goal state
h1(n) = 6
does not consider the
distance tiles have to be
moved
71
3
6
STATE n
Goal state
h2(n) = 2+3+0+1+3+0+3+1
= 13
72
73
STATE n
For each numbered tile, count how many tiles on its right
should be on its left in the goal state.
1 2 3
h3(n) = n5 + n8 + n4 + n2 + n1 + n7 + n3 + n6
4 5 6
=4 +6 +3 +1 +0 +2 +0 +0
= 16
7 8
BTW:
Goal state
If this number is even, the puzzle is solvable.
If this number is odd, the puzzle is not solvable.
74
75
3
6
STATE n
Goal state
76
Algorithm A
Solution:
77
78
79
80
81
Today
Uninformed search
Informed search
Summary
82
Evaluating Heuristics
Admissibility:
Monotonicity:
optimistic
never overestimates the cost of reaching the goal
guarantees to find the shortest path to the goal, if it exists
e.g.: breadth-first is admissible -- it uses f(n) = g(n) + 0
local admissibility
guarantees to find the shortest path to each state
encountered in the search
Informedness:
Admissibility
Algorithm A*
85
Example: 8-Puzzle
5
1 2 3
4 5 6
7 8
goal
86
Monotonicity
(aka consistent)
87
Informedness
Today
Uninformed search
Informed search
Summary
89
Summary
Search
Uses
h(n) ?
Open is a
Breadth-first
No
Queue
Depth-first
No
Stack
Depth-limited
No
Stack
Iterative Deepening
No
Stack
Hill climbing
Yes
none
Best-First
Yes
A*
Yes
90
Today
Uninformed search
Breadth-first and Depth-first
Depth-limited Search
Iterative Deepening
Informed search
Hill climbing
Best-First
A*
Summary
91