0% found this document useful (0 votes)
63 views25 pages

Artificial Intelligence: Informed Search

This document discusses informed search strategies for artificial intelligence, including greedy best-first search, uniform cost search (priority first search), and A* search. It explains that A* uses an admissible heuristic to order nodes in a priority queue by their f(n) value of g(n)+h(n) to ensure it is complete and optimal. The document provides examples of heuristics for the 8-puzzle problem and discusses how relaxed problems can generate admissible heuristics.

Uploaded by

Prasidha Prabhu
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)
63 views25 pages

Artificial Intelligence: Informed Search

This document discusses informed search strategies for artificial intelligence, including greedy best-first search, uniform cost search (priority first search), and A* search. It explains that A* uses an admissible heuristic to order nodes in a priority queue by their f(n) value of g(n)+h(n) to ensure it is complete and optimal. The document provides examples of heuristics for the 8-puzzle problem and discusses how relaxed problems can generate admissible heuristics.

Uploaded by

Prasidha Prabhu
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/ 25

Artificial Intelligence

Informed Search

B E (CSE) B Section, Semester 5


T. T. Mirnalinee
Department of Computer Science and Engineering
SSN College of Engineering
26th August 2020
Outline

• Heuristic Search
• Priority first search (PFS)
• Greedy Best-First Search
• A*
• Conditions for optimality
Introduction
Informed Search Strategies
• Greedy Best First Search
• A*
Explore the state with lowest f(n)
Uniform Cost Search (PFS) f(n)=g(n)
• Bag: Priority Queue
• Priority of a state s = Path cost from start state to s
• Explore the cheapest path first
• Complete and optimal – if there is a solution alg will find the solution,
if multiple solution is there, it will find the optimal solution
• Explores in every “direction” – but expect to focus towards the
solution
• Not in the direction of a goal
PFS Algorithm with Prioirty f(n)=g(n)
def Priority_First_Search (problem):
discovered = priority queue ordered by distance
explored = {}
add start node with distance = 0 to discovered
while discovered is not empty:
u = delete_min (discovered)
if u.state is goal: return Solution (u)
if u is not in explored:
add u to explored
for each v in Successors (u):
if v.state is in discovered with longer path:
replace that node with v
elif v is in explored with longer path
replace that node with v
else:
add v to discovered
return failure
PFS
Greedy BFS

Complete: No?
Optimal: No?
Time and space complexity :
exponential
A*
• Uniform-cost orders by backward path cost, g(n)
• Greedy orders by goal proximity, forward path cost, h(n)
• A* orders by the sum: f(n)=g(n)+h(n)
A* algorithm
def A* (problem):
discovered = priority queue ordered by f(n) = g(n) + h(n)
add start node with f(n) = h(n) to discovered
while discovered is not empty:
u = delete_min (discovered)
if u.state is goal: return Solution (u)
for each v in Successors (u):
g(v) = g(u) + c(u,v)
f(v) = g(v) + h(v)
if v.state is in discovered with longer path:
replace that node with v
else:
add v to discovered
return failure
Example
When should A* terminate
• When we test for goal state
• Entry to the discovered bag (add)
• Selecting a state from the discovered bag for exploration (remove)
Admissible heuristic

S -> G f(n)= 5
S -> A: 1+6 = 7, A - > G : 7+3 = 10
So to G is selected
But actual cost of S-A-G is 4 which is less than S -> G (5)
Thus it is not optimal, this is because the heuristic of A is
greater than the actual cost
Consistent Heuristic
A* is complete

• Shortest distance to a goal state, C∗


• Explored all nodes with f(n)<C∗
• May explore some of the nodes on the “goal contour”, f(n)=C∗ before
selecting a goal node.
• Completeness: finitely many nodes with g(n)≤C∗ Explores no node
with f(n)>C∗ - pruning (subset of entire state space is not at all
visited)
• Every node has finite no of successor , finite number of actions and all
actions have small positive cost
Time complexity
Memory-Bounded Heuristic Search

• Iterative Deepening A* (IDA*)


• Iterative Deepening: cutoff, g(n)
• f(n)=g(n)+h(n)
• In each iteration, use the next higher f-cost
• Recursive BFS
• BFS using linear space
• Like Recursive DFS

• BFS and A* space requirement is exponential with respect to depth d


Illustration

• 8-Puzzle has Exponential Number of States

• Branching factor ≈3
• Suppose goal state at depth, solution cost, d=22
• Tree search: 322=3.1×1010 states
• Graph search: 9!/2=181,440 states
• Smaller 170,000 times
• 15-puzzle, 1013 states
•h1= Number of mispplaced tiles, h1=8
•h2= Manhattan distance h2=3+1+2+2+2+3+3+2=18
• Number of nodes N
• Solution depth d
• Effective branching factor b∗ N+1=1+b∗+(b∗)2+…+(b∗)d
• Almost constant for hard problems
• Good heuristic, b∗≈1

Comparison of Search Costs and Effective
Branching Factors for 8-Puzzle
• A* with h1 (misplaced tiles)
• A* with h2 (Manhattan distance)
• Data averaged over 100 puzzles for each solution length d from 6 to
28.
• h2(n)≥h1(n), h2 dominates h1, efficient
• All nodes n generated have
f(n)<C∗
g(n)+h(n)<C∗
h(n)<C∗−g(n)
h1(n)≤h2(n)<C∗−g(n)
Generate Admissible Heuristics from Relaxed
Problems
• Relaxed problem, a problem with fewer restrictions on the actions
• Supergraph of the original state space because the removal of
restrictions creates added edges
• May have shortcuts, and hence cheaper solutions
• Cost of an cheapest solution to a relaxed problem is an admissible
heuristic for the original problem.
Relax 8-Puzzle

• Problem: A tile can move from square A to square B if A is horizontally


or vertically adjacent to B and B is blank,
• Relaxed problems:
• A tile can move from square A to square B if A is adjacent to B.
• A tile can move from square A to square B if B is blank.
• A tile can move from square A to square B.
Summary
• A* is complete if C* is optimal ie no of nodes satistying C* is finite
• A* expands no nodes with f(n) >c* (Implicit pruning)
• A* is optimal with admissible heuristic
• A* is optimally efficient ( No other algorithm is efficient than this)
• Time complecity – exponential
• Space complexity - exponential

You might also like