0% found this document useful (0 votes)
4 views

IA-c03-NoAnim

The document provides an overview of various search algorithms in artificial intelligence, including uninformed searches like Breadth-First Search, Uniform Cost Search, and Depth-First Search, as well as informed searches such as Greedy Best First and A* Search. It discusses the evaluation criteria for these algorithms, including completeness, cost optimality, time complexity, and space complexity. Additionally, it covers the concept of heuristics and how they can be used to improve search efficiency.

Uploaded by

Davide Muresan
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)
4 views

IA-c03-NoAnim

The document provides an overview of various search algorithms in artificial intelligence, including uninformed searches like Breadth-First Search, Uniform Cost Search, and Depth-First Search, as well as informed searches such as Greedy Best First and A* Search. It discusses the evaluation criteria for these algorithms, including completeness, cost optimality, time complexity, and space complexity. Additionally, it covers the concept of heuristics and how they can be used to improve search efficiency.

Uploaded by

Davide Muresan
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/ 38

Artificial Intelligence

Radu Răzvan Slăvescu

Technical University of Cluj-Napoca


Department of Computer Science

(some slides adapted from A. Dragan, N. Kitaev, N. Lambert, S. Levine, S. Rao, S. Russell)
Outline

Uninformed Search
Breadth-First Search
Uniform Cost Search
Depth-First Search

Informed Search
Search problems
Partial search trees for Arad → Bucharest
Search problems

Partial sequence of search trees for Arad → Bucharest

Search tree in red, graph space in grey


General Search
Best First Search

Next, expand node n with the minimum value of function f (n).


General Search

Search data structures


I node.STATE: the state to which the node corresponds
I node.PARENT: the node in the tree that generated this
node
I node.ACTION: the action that was applied to the parent’s
state to generate this node
I node.PATH-COST, aka g(node): the total cost of the path
from the initial state to this node
General Search

Search data structures for the frontier


I IS-EMPTY(frontier): true iff there are no nodes in the
frontier
I POP(frontier) removes the top node from the frontier
and returns it
I TOP(frontier) returns (but does not remove) the top
node of the frontier
I ADD(node, frontier) inserts node into its proper
place in the queue

Queues used in different search algorithms


Priority queue / FIFO / LIFO
General Search

Criteria for evaluating search algorithms


I COMPLETENESS: does it a solution when there is one, and
report failure otherwise? (to do this, it must be systematic
in the way it explores an infinite space)
I COST OPTIMALITY: does it find a solution with the lowest
path cost of all solutions?
I TIME COMPLEXITY: How long / how many operations are
needed to find a solution?
I SPACE COMPLEXITY: How much memory is needed for
the search?
Breadth First Search

BFS on a tree

I Generate a node’s successors, then their successors etc.


I BEST-FIRST-SEARCH with f (n)=node depth (# of actions)
Breadth First Search
BFS on a tree

I employs FIFO
I early goal test: check if the node is goal when generated
BFS

Evaluation
I COMPLETENESS: yes
I COST OPTIMALITY: yes, if all actions have the same cost
I TIME COMPLEXITY: 1 + b + b2 + · · · + bd = O(bd )
(b=# of successors of a node, d=depth of a solution)
I SPACE COMPLEXITY: O(bd ) (all nodes kept in memory)
Uniform Cost Search, aka Dijkstra’s
UCS algorithm

I BEST-FIRST-SEARCH with f (n)=PATH-COST


I spreads out in waves of uniform path-cost
I obvious choice when actions have different costs
Uniform Cost Search

When to stop?

I successors of Sibiu: Rimnicu Valcea (80), Fagaras (99)


I expand Rimnicu Valcea, get Pitesti (80+97=177)
I expand Fagaras, get Bucharest (99+211=310)
I go on, expand Pitesti, get Bucharest (80+97+101=278)
UCS

Evaluation
I COMPLETENESS: yes it is systematic
I COST OPTIMALITY: yes first solution has a cost at least
as low as any other node in the frontier

I TIME COMPLEXITY: O(b1+C / )
(C ∗ =cost of optimal solution, =lower bound of the cost of
each action)
I SPACE COMPLEXITY: same as for time
Depth First Search
DFS

Expand the deepest node in the frontier first (uses LIFO)


DFS

Evaluation
I COMPLETENESS: yes if finite state space; no for infinte of
cyclic state spaces
I COST OPTIMALITY: no the first solution found is not
always the cheapest
I SPACE COMPLEXITY: O(bm)
(b=branching factor, m=max depth of tree)
Depth-Limited (DLS) and Iterative Deepening Search
(IDS)
DLS

DLS: DFS with a limit l beyond which we do not expand


DLS

Evaluation
I TIME COMPLEXITY: O(bl )
(b=branching factor, l=depth limit)
I SPACE COMPLEXITY: O(bl)
I COMPLETENESS: No if l not carefully chosen

Choosing l: diameter of the state-space graph (e.g., 10 for


Romania)
Depth-Limited (DLS) and Iterative Deepening Search
(IDS)
IDS

IDS: DFS with increasing limit l, until failure is returned


Iterative Deepening Search
IDS
IDS

Evaluation
I SPACE COMPLEXITY: O(bd) if there is a solution, O(bm)
on finite state spaces with no solution
I TIME COMPLEXITY: O(bd ) if there is a solution, O(bm ) on
finite state spaces with no solution
N(IDS) = d ∗ B 1 + (d − 1) ∗ b2 + . . . bd
(in many cases, most of the nodes are in the bottom level)
I COMPLETENESS: yes
Bidirectional Search

Advance from both initial and goal state.

Use:
I two tables of reached states
I two frontiers and stop when they collide
Informed Search

Idea
Use domain specific info about how far we are from the goal.
h(n)=estimated cost of the cheapest path from the state at
node n to a goal state
Greedy Best First

Go closer to the goal!


f (n) = h(n)

Straight line distances to Bucharest from Arad


Arad 366 Mehadia 241
Bucharest 0 Neamt 234
Craiova 160 Oradea 380
Drobeta 242 Pitesti 100
Eforie 161 Rimnicu Vilcea 193
Fagaras 176 Sibiu 253
Giurgiu 77 Timisoara 329
Hirsova 151 Urziceni 80
Iasi 226 Vaslui 199
Lugoj 244 Zerind 374
Greedy Best First
Tracing greedy Best First Search
Greedy Best First

Evaluation
I COMPLETENESS: yes for finite state spaces, pause no
pause for infinte ones
I SPACE COMPLEXITY: O(|V |)
I TIME COMPLEXITY: O(|V |)
I COST OPTIMALITY: no
A* Search
Consider both proximity of goal (h) and cost so far (g)
f (n) = g(n) + h(n)
A* Search
Evaluation
I COMPLETENESS: yes
I COST OPTIMALITY: yes, if h is admissible: it never
overestimates the cost to reach goal (it is optimistic)
∀n, h(n) ≤ h∗ (n), h∗ (n) =real cost n → nearest goal
(we assume ∀ i, h(i) ≥ 0 and ∀ g goal(g) ⇒ h(g) = 0)

Stronger condition: h consistency: h is consistent if, for


every node n and every successor s of n generated by
action a, we have

h(n) ≤ c(n, a, s) + h(s) (aka triangle inequality)

Consistency ensures that the first time we reach a state, it


will be on an optimal path
A* Search

Search contour x: all nodes n inside x have f (n) ≤ x


A* Search

Approaches for the memory issue


I Beam search: keep in the frontier only the top k nodes
(with the best f scores) ⇒ search incomplete and
suboptimal; for carefully chosen k, near-optimal solutions
I Iterative Deepening A*: do not store all reached states in
memory; accept to visit some of them multiple times.
Cutoff value: the smallest f -cost of any node which
exceeded the cutoff on the prior iteration.
A* Search

Comparing heuristics

Two heuristics
h1 =number of misplaced tiles (blank not included),
e.g., h1 = 8
h2 =sum of Manhattan distances of tiles to their goal positions,
e.g, h2 = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 = 18
A* Search

Dominance
If ∀n, h2 (n) ≥ h1 (n), we say that h2 dominates h1 .

Comparing heuristics
If h2 dominates h1 , then A* using h2 will not expand more nodes
than A* using h1 (except in the case of breaking ties unluckily).
Inventing heuristics

Relaxing problems
Exact cost of an optimal solution of a relaxed problem is an
admissible heuristic for the original problem.

E.g., h1 : allow tile ”teleportation”


h2 : slide over occupied squares

Obs: we must be able to solve the relaxed problem without


search.
Inventing heuristics

Take max
If h1 , . . . , hm are heuristics, but none of them dominates any
other, we still can use : h(n) = max(h1 , . . . , hm )
Inventing heuristics

Compute the solution cost of a subproblem


E.g., move only tiles 1,2,3 and 4 to the final position (the cost is
a lower bound for the original problem)
Pattern database = store for the exact solution costs for every
possible subproblem instance and use it for lookup
Inventing heuristics

Use landmarks
Choose 10-20 landmark points among vertices and, foreach
landmark L and each other vertex v in the graph, compute and
store the exact cost of the optimal path from v to L, C ∗ (v , L).
Heuristics

Exercises
I Cannibals and missionaries problem: which of the
following heuristic is admissible:
h1 = # of people on the initial bank - 1
h2 = (# of people on the initial bank) / 2
I Knight on an infinite chess board: suggest a heuristic
I Go by car in a city from S to D in mimimum time: suggest a
heuristic
That’s all, folks!

Thanks for your attention...Questions?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy