Informed Search - Lecture 5 - Artificial intelligence - Notes | CS 440, Study notes of Computer Science

Material Type: Notes; Professor: Draper; Class: Introduction to Artificial Intelligence; Subject: Computer Science; University: Colorado State University; Term: Fall 2008;

Typology: Study notes

Pre 2010

Uploaded on 03/18/2009

koofers-user-7o4-1
koofers-user-7o4-1 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Informed Search
Informed Search
(A*)
(A*)
Lecture #5
Lecture #5
9/09/08
9/09/08
Announcements
Announcements
Turn in writing assignment #1 now
Turn in writing assignment #1 now
You should give two copies to Jason
You should give two copies to Jason
One with your name on it
One with your name on it
One without
One without
At the end of class, Jason will give you back someone else
At the end of class, Jason will give you back someone else
s
s
(anonymous) essay to critique
(anonymous) essay to critique
Your evaluation will not effect their grade
Your evaluation will not effect their grade
You will be graded on your critique
You will be graded on your critique
Critique: one paragraph
Critique: one paragraph
What they did right
What they did right
What they did wrong
What they did wrong
The grade you would have given them
The grade you would have given them
Due Thursday
Due Thursday
ACM club: Wed., 5:00
ACM club: Wed., 5:00-
-6:00, USC 110
6:00, USC 110
Automation and Revisions
Automation and Revisions
(
(cron
cron,
, svn
svn)
)
Review:
Review:
Tree search
Tree search
function
function TREE
TREE-
-SEARCH(
SEARCH(problem, fringe, strategy
problem, fringe, strategy)
) returns
returns a solution or failure
a solution or failure
fringe
fringe
INSERT(MAKE
INSERT(MAKE-
-NODE(
NODE(problem
problem.InitialState
.InitialState()),
()), fringe
fringe)
)
loop do
loop do
if
if EMPTY?(
EMPTY?(fringe
fringe)
) then
then return
return failure
failure
node
node
strategy
strategy.SelectAndRemoveNode(
.SelectAndRemoveNode(fringe
fringe)
)
if
if problem
problem.Solution?(
.Solution?(node
node)
) then
then return
return node
node
else
else fringe
fringe
APPEND(
APPEND(fringe
fringe,
, problem
problem.EXPAND(
.EXPAND(node
node))
))
enddo
enddo
Best
Best-
-first search
first search
Informed search strategy: expand apparently best
Informed search strategy: expand apparently best
node
node
Factors going into determination of
Factors going into determination of best:
best:
Current cost of the solution path
Current cost of the solution path
Estimated distance to the nearest goal st ate
Estimated distance to the nearest goal st ate
Node is selected for expansion based on an
Node is selected for expansion based on an
evaluation function
evaluation function f(n)
f(n)
Implementation:
Implementation:
Fringe
Fringe is a queue sorted in decreasing order of
is a queue sorted in decreasing order of f
f
Special cases: greedy search, A* search
Special cases: greedy search, A* search
Heuristics
Heuristics
Heuristic:
Heuristic:
A rule of thumb, simplification, or
A rule of thumb, simplification, or
educated guess that reduces or limits the
educated guess that reduces or limits the
search for solutions in domains that are
search for solutions in domains that are
difficult and poorly understood.
difficult and poorly understood.
The heuristic function
The heuristic function h(n)
h(n) estimates cost
estimates cost
of the cheapest path from node
of the cheapest path from node n
nto goal
to goal
node.
node.
If
If n
nis a goal node
is a goal node h(n)=0
h(n)=0
Greedy best
Greedy best-
-first search
first search
Expand node on the frontier closest to
Expand node on the frontier closest to
goal
goal
Determination of closest based upon the
Determination of closest based upon the
heuristic function
heuristic function h
h
pf3
pf4
pf5

Partial preview of the text

Download Informed Search - Lecture 5 - Artificial intelligence - Notes | CS 440 and more Study notes Computer Science in PDF only on Docsity!

Informed SearchInformed Search

(A)(A)

Lecture #5Lecture

AnnouncementsAnnouncements

Turn in writing assignment #1 now Turn in writing assignment #1 now

  • – You should give two copies to JasonYou should give two copies to Jason One with your name on itOne with your name on it One withoutOne without At the end of class, Jason will give you back someone else’ At the end of class, Jason will give you back someone else’ss (anonymous) essay to critique(anonymous) essay to critique
  • – Your evaluation will not effect their gradeYour evaluation will not effect their grade
  • –^ You will be graded on your critiqueYou will be graded on your critique
  • – Critique: one paragraphCritique: one paragraph What they did rightWhat they did right What they did wrongWhat they did wrong The grade you would have given themThe grade you would have given them
  • – Due ThursdayDue Thursday ACM club: Wed., 5:00- ACM club: Wed., 5:00-6:00, USC 1106:00, USC 110
  • – ““Automation and RevisionsAutomation and Revisions”” ((croncron,, svnsvn))

Review:Review:

Tree searchTree search

functionfunction TREETREE--SEARCH(SEARCH( problem, fringe, strategyproblem, fringe, strategy )) returnsreturns a solution or failurea solution or failure fringefringe ←← INSERT(MAKEINSERT(MAKE--NODE(NODE( problemproblem .InitialState.InitialState()),()), fringefringe )) loop doloop do ifif EMPTY?(EMPTY?( fringefringe )) thenthen returnreturn failurefailure node node ←← strategystrategy .SelectAndRemoveNode(.SelectAndRemoveNode( fringefringe )) ifif^ problemproblem .Solution?(.Solution?( nodenode ))^ thenthen returnreturn^ nodenode elseelse fringefringe ←← APPEND(APPEND( fringefringe ,, problemproblem .EXPAND(.EXPAND( nodenode )))) enddoenddo

BestBest--first searchfirst search

Informed search strategy: expand apparently best Informed search strategy: expand apparently best

nodenode

Factors going into determination of best: Factors going into determination ofbest:

  • – Current cost of the solution pathCurrent cost of the solution path
  • – Estimated distance to the nearest goal stateEstimated distance to the nearest goal state

Node is selected for expansion based on an Node is selected for expansion based on an

evaluation function evaluation function f(n)f(n)

Implementation: Implementation:

  • FringeFringe is a queue sorted in decreasing order ofis a queue sorted in decreasing order of ff
  • – Special cases: greedy search, A* searchSpecial cases: greedy search, A* search

HeuristicsHeuristics

Heuristic:Heuristic: “A rule of thumb, simplification, or“A rule of thumb, simplification, or

educated guess that reduces or limits theeducated guess that reduces or limits the

search for solutions in domains that aresearch for solutions in domains that are

difficult and poorly understood.difficult and poorly understood.””

– – The heuristic functionThe heuristic function h(n)h(n) estimates costestimates cost

of the cheapest path from nodeof the cheapest path from node nn to goalto goal

node.node.

– – IfIf^ nn^ is a goal nodeis a goal node^ h(n)=0h(n)=

Greedy best- Greedy best-first searchfirst search

Expand node on the frontier closest to Expand node on the frontier closest to

goalgoal

Determination of closest based upon the Determination of closest based upon the

heuristic functionheuristic function hh

Greedy search: An exampleGreedy search: An example

Consider path planning between two citiesConsider path planning between two cities

Use the straight line distance heuristic,Use the straight line distance heuristic,^ hh^ SLDSLD

The greedy solution is (A, B, D)The greedy solution is (A, B, D)

The least cost solution is (A, B, D)The least cost solution is (A, B, D)

A B

C

D

Greedy search: An exampleGreedy search: An example

Consider path planning between two cities Consider path planning between two cities

Use the straight line distance heuristic, Use the straight line distance heuristic, (^) hh (^) SLDSLD

The greedy solution is (A, C, D) The greedy solution is (A, C, D)

The least cost solution is (A, B, D) The least cost solution is (A, B, D)

A B

C

D

A* SearchA* Search

Order states by theirOrder states by their total estimatedtotal estimated costcost

Always select the node with the lowest valueAlways select the node with the lowest value

Total estimated cost:Total estimated cost:

g(n)g(n) the cost to reachthe cost to reach n (n ( known)known)

h(n)h(n)^ the estimated cost to the goalthe estimated cost to the goal

f(n) = g(n) + h(n)

Avoiding repeated statesAvoiding repeated states

BFS: BFS:

  • – Add to fringe only if state not already visited.Add to fringe only if state not already visited.
  • – i.e., state absent from thei.e., state absent from the^ closed listclosed list ..

A: A:

  • – If node represents state already visited,If node represents state already visited,

update cost according lower total estimatedupdate cost according lower total estimated cost.cost.

Heuristic functionsHeuristic functions

Heuristics for the 8 puzzle:Heuristics for the 8 puzzle:

hh^11 = the number of misplaced tiles= the number of misplaced tiles

  • – hh^11 (s)=8(s)=

hh^22 = the sum of the distances of the tiles from their goal= the sum of the distances of the tiles from their goal

positions (manhattan distance)positions (manhattan distance)

  • – hh 22 (s)=3+1+2+2+2+3+3+2=18(s)=3+1+2+2+2+3+3+2=

Comparison of heuristics Comparison of heuristics

Even very simple heuristics likeEven very simple heuristics like hh 11 andand hh (^22)

can significantly reduce the search cost: can significantly reduce the search cost:

A* withA* with hh 22 3939 113113

A* withA* with^ hh 11 9393 539539

Iterative DeepeningIterative Deepening 47,12747,127 3,473,9413,473,

AlgorithmAlgorithm Depth 10Depth 10 Depth 14Depth 14

A* in RomaniaA* in Romania

Expand Pitesti and determineExpand Pitesti and determine f(n)f(n) for each nodefor each node

  • f(Bucharest)=f(Bucharest)=c(Pitesti,Bucharest)+h(Bucharestc(Pitesti,Bucharest)+h(Bucharest)=418+0=418)=418+0= Best choice is BucharestBest choice is Bucharest

Note values along solution path !!Note values along solution path !!

Is the solution optimal?Is the solution optimal?

Admissible heuristics Admissible heuristics

A heuristic is admissible if it A heuristic is admissible if it never overestimatesnever overestimates the cost to reach the goal (optimistic) the cost to reach the goal (optimistic) Formally:Formally: 1.1. h(n) <= h(n)h(n) <= h(n) wherewhere h(n)h(n) is the true cost fromis the true cost from nn 2.2. h(n) >= 0h(n) >= 0 soso h(G)=0h(G)=0 for any goalfor any goal GG ..

Examples:Examples: hh (^) SLDSLD (n(n)) never overestimates the actual road distancenever overestimates the actual road distance Heuristics for 8 puzzleHeuristics for 8 puzzle

Optimality of AOptimality of A

LetLet^ GG^22 be a suboptimal goal node.be a suboptimal goal node.

LetLet^ nn^ be an unexpanded node on an optimal cost path tobe an unexpanded node on an optimal cost path to

goalgoal GG. Then:. Then:

f(Gf(G 22 )) = g(G= g(G 22 )) sincesince h(Gh(G 22 )=0)=

> g(G)> g(G) sincesince GG 22 is suboptimalis suboptimal

>= f(n)>= f(n) sincesince hh is admissibleis admissible

SinceSince^ f(Gf(G^22 ) > f(n)) > f(n) , A* will never select, A* will never select^ GG^22 for expansionfor expansion

Graph searchGraph search

Turns out there is an additional way to Turns out there is an additional way to

avoid the necessary bookkeeping requiredavoid the necessary bookkeeping required

for graph search: use a consistentfor graph search: use aconsistent

heuristic.heuristic.

Consistency Consistency

A heuristic isA heuristic is consistentconsistent if:if:

h(n)h(n) ≤≤ c(n, a, nc(n, a, n’’) + h(n) + h(n’’))

Given a consistent heuristic:Given a consistent heuristic:

f(nf(n’’) =) = g(ng(n’’) +) + h(nh(n’’))

≥ ≥ g(n) + c(n,a,ng(n) +c(n,a,n’’) +) + h(nh(n’’))

≥ ≥ g(n) + h(n) = f(n)g(n) + h(n) = f(n)

A consequence of consistency:A consequence of consistency: f(n)f(n)

monotonically decreasing along a pathmonotonically decreasing along a path

Monotonicity implies optimalityMonotonicityimplies optimality

A* expands nodes in order of increasing A* expands nodes in order of increasing ff valuevalue

Expansion represented as contours of states with Expansion represented as contours of states with

equalequal ff valuevalue

A* expands all nodes with A* expands all nodes with f(n) < Cf(n) < C

When a heuristic isWhen a heuristic is ““almostalmost””

admissibleadmissible

Graceful Decay of AdmissibilityGraceful Decay of Admissibility

If a heuristic rarely overestimates cost by more thanIf a heuristic rarely overestimates cost by more than δ δ ,,

then the A* algorithm will rarely find a solution whosethen the A* algorithm will rarely find a solution whose

cost is more thatcost is more that δδ greater than the cost of the optimalgreater than the cost of the optimal

solution.solution.

Means:Means:

  • – So long as we undershoot almost all the time, andSo long as we undershoot almost all the time, and

bound how much we overshoot, we seldom get inbound how much we overshoot, we seldom get in

trouble, and the trouble is minor.trouble, and the trouble is minor.

Evaluation of AEvaluation of A

Completeness: YES Completeness: YES

  • – Unless there are infinitely many nodes withUnless there are infinitely many nodes with f<f(G)f<f(G)

Evaluation of A* Evaluation of A*

Completeness: YESCompleteness: YES

Time complexity:Time complexity:

  • – Number of nodes expanded is still exponential since ANumber of nodes expanded is still exponential since A

expands all nodes withexpands all nodes with f(n) < Cf(n) < C

Evaluation of A* Evaluation of A*

Completeness: YES Completeness: YES

Time complexity: Time complexity:

  • – Number of nodes expanded is still exponential since ANumber of nodes expanded is still exponential since A

expands all nodes withexpands all nodes with f(n) < Cf(n) < C

Space complexity: also exponential. Space complexity: also exponential.

Evaluation of AEvaluation of A

Completeness: YESCompleteness: YES

Time complexity:Time complexity:

  • – Number of nodes expanded is still exponential since ANumber of nodes expanded is still exponential since A

expands all nodes withexpands all nodes with^ f(n) < Cf(n) < C

Space complexity: also exponential.Space complexity: also exponential.

Optimality: YESOptimality: YES

  • – A* does not expand any node withA* does not expand any node with^ f(n) > Cf(n) > C
  • Assuming anAssuming an admissableadmissable heuristicheuristic

Comparing heuristicsComparing heuristics

Heuristics for the 8 puzzle:Heuristics for the 8 puzzle:

h h 11 = the number of misplaced tiles= the number of misplaced tiles

h h 22 = the sum of the distances of the tiles from their goal= the sum of the distances of the tiles from their goal

positions (manhattan distance)positions (manhattan distance)