0% found this document useful (0 votes)
17 views20 pages

cour1

c1

Uploaded by

yasmine chiter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views20 pages

cour1

c1

Uploaded by

yasmine chiter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

CS : Artificial Intelligence

Informed Search
• Informed Search
• Heuristics
• Greedy Search
• A* Search
Informed Search

3
Search Problems
Search Problems
• A search problem consists of:

• A state space

• A successor function “N”, 1.0


(with actions, costs)

“E”, 1.0
• A start state and a goal test

• A solution is a sequence of actions (a plan) which


transforms the start state to a goal state
Search Problems Are Models
Example: Traveling in Romania
• State space:
• Cities
• Successor function:
• Roads: Go to adjacent city with
cost = distance
• Start state:
• Arad
• Goal test:
• Is state == Bucharest?

• Solution?
What’s in a State Space?
The world state includes every last detail of the environment

A search state keeps only the details needed for planning (abstraction)

• Problem: Pathing • Problem: Eat-All-Dots


• States: (x,y) location • States: {(x,y), dot booleans}
• Actions: NSEW • Actions: NSEW
• Successor: update location • Successor: update location
only and possibly a dot boolean
• Goal test: is (x,y)=END • Goal test: dots all false
State Space Sizes?
• World state:
• Agent positions: 120
• Food count: 30
• Ghost positions: 12
• Agent facing: NSEW

• How many
• World states?
120x(230)x(122)x4
• States for pathing?
120
• States for eat-all-dots?
120x(230)
Safe Passage

• Problem: eat all dots while keeping the ghosts perma-scared


• What does the state space have to specify?
• (agent position, dot booleans, power pellet booleans, remaining scared time)
State Space Graphs and Search Trees
State Space Graphs
• State space graph: A mathematical
representation of a search problem
• Nodes are (abstracted) world configurations
• Arcs represent successors (action results)
• The goal test is a set of goal nodes (maybe only one)

• In a state space graph, each state occurs only


once!

• We can rarely build this full graph in memory


(it’s too big), but it’s a useful idea
State Space Graphs
• State space graph: A mathematical
representation of a search problem a G
• Nodes are (abstracted) world configurations b c
• Arcs represent successors (action results)
e
• The goal test is a set of goal nodes (maybe only one) d f
S h
• In a search graph, each state occurs only once!
p r
q

• We can rarely build this full graph in memory


(it’s too big), but it’s a useful idea Tiny search graph for a tiny
search problem
Search Trees
This is now / start
“N”, 1.0 “E”, 1.0

Possible futures

• A search tree:
• A “what if” tree of plans and their outcomes
• The start state is the root node
• Children correspond to successors
• Nodes show states, but correspond to PLANS that achieve those states
• For most problems, we can never actually build the whole tree
Tree Search vs Graph Search
function TREE_SEARCH(problem) returns a solution, or failure

initialize the frontier as a specific work list (stack, queue, priority queue)
add initial state of problem to frontier
loop do
if the frontier is empty then
return failure
choose a node and remove it from the frontier
if the node contains a goal state then
return the corresponding solution

for each resulting child from node


add child to the frontier
function GRAPH_SEARCH(problem) returns a solution, or failure
initialize the explored set to be empty
initialize the frontier as a specific work list (stack, queue, priority queue)
add initial state of problem to frontier
loop do
if the frontier is empty then
return failure
choose a node and remove it from the frontier
if the node contains a goal state then
return the corresponding solution
add the node state to the explored set
for each resulting child from node
if the child state is not already in the frontier or explored set then
add child to the frontier
Uniform Cost Search (UCS) Properties
• What nodes does UCS expand?
• Processes all nodes with cost less than cheapest solution!
• If that solution costs C* and arcs cost at least  , then the b c1
“effective depth” is roughly C*/ …
• Takes time O(bC*/) (exponential in effective depth) c2
C*/ “tiers”
c3
• How much space does the fringe take?
• Has roughly the last tier, so O(bC*/)

• Is it complete?
• Assuming best solution has a finite cost and minimum arc cost
is positive, yes!

• Is it optimal?
• Yes! (Proof next lecture via A*)
function UNIFORM-COST-SEARCH(problem) returns a solution, or failure
initialize the explored set to be empty
initialize the frontier as a priority queue using g(n) as the priority
add initial state of problem to frontier with priority g(S) = 0
loop do
if the frontier is empty then
return failure
choose a node and remove it from the frontier
if the node contains a goal state then
return the corresponding solution
add the node state to the explored set
for each resulting child from node
if the child state is not already in the frontier or explored set then
add child to the frontier
else if the child is already in the frontier with higher g(n) then
replace that frontier node with child
Search Heuristics
 A heuristic is:
 A function that estimates how close a state is to a goal
 Designed for a particular search problem
 Pathing?
 Examples: Manhattan distance, Euclidean distance for
pathing

10

5
11.2

You might also like