CE417: Introduction to Artificial Intelligence Sharif University of Technology Fall 2020 “Artificial Intelligence: A Modern Approach”, Chapter 3 Most slides have been adopted from Klein and Abdeel, CS188, UC Berkeley. Solving problems by searching: Uninformed Search Soleymani
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CE417: Introduction to Artificial Intelligence
Sharif University of Technology
Fall 2020
“Artificial Intelligence: A Modern Approach”, Chapter 3
Most slides have been adopted from Klein and Abdeel, CS188, UC Berkeley.
Solving problems by searching:
Uninformed Search
Soleymani
2
Outline
Search Problems
Uninformed Search Methods
Depth-First Search
Breadth-First Search
Uniform-Cost Search
3
Problem-Solving Agents
Problem Formulation: process of deciding what actionsand states to consider
States of the world
Actions as transitions between states
Goal Formulation: process of deciding what the next goalto be sought will be
Agent must find out how to act now and in the future toreach a goal state
Search: process of looking for solution (a sequence of actionsthat reaches the goal starting from initial state)
4
Problem-Solving Agents
A goal-based agent adopts a goal and aim at satisfying it
(as a simple version of intelligent agent maximizing a performance measure)
“How does an intelligent system formulate its problem as
a search problem”
Goal formulation: specifying a goal (or a set of goals) that agent
must reach
Problem formulation: abstraction (removing detail)
Retaining validity and ensuring that the abstract actions are easy to
perform
5
Vacuum world state space graph
States?
Actions?
Goal test?
Path cost?
dirt locations & robot location
Left, Right, Suck
no dirt at all locations
one per action
2 × 22 = 8States
6
Example: 8-puzzle
States?
Actions?
Goal test?
Path cost?
locations of eight tiles and blank in 9 squares
move blank left, right, up, down (within the board)
e.g., the above goal state
one per move
Note: optimal solution of n-Puzzle family is NP-complete
9!/2 = 181,440States
7
Example: 8-queens problem
Initial State?
States?
Actions?
Goal test?
Path cost?
any arrangement of 0-8 queens on the board is a state
no queens on the board
add a queen to the state (any empty square)
8 queens are on the board, none attacked
of no interest
64 × 63 ×⋯× 57≃ 1.8 × 1014 States
search cost vs. solution path cost
8
Example: 8-queens problem(other formulation)
Initial state?
States?
Actions?
Goal test?
Path cost?
any arrangement of k queens one per column in the leftmost k
columns with no queen attacking another
no queens on the board
add a queen to any square in the leftmost empty column such
that it is not attacked by any other queen
8 queens are on the board
of no interest
2,057 States
9
Example: Knuth problem
10
Knuth Conjecture: Starting with 4, a sequence of factorial,
square root, and floor operations will reach any desired
Overhead of IDS = (123,450 - 111,110)/111,110 = 11%
62
Cost-Sensitive Search
BFS finds the shortest path in terms of number of actions.It does not find the least-cost path. We will now covera similar algorithm which does find the least-cost path.
START
GOAL
d
b
pq
c
e
h
a
f
r
2
9 2
81
8
2
3
2
4
4
1
5
1
32
2
63
Uniform Cost Search
64
Uniform Cost Search
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
Strategy: expand a cheapest
node first:
frontier is a priority queue
(priority: cumulative cost)S
G
d
b
pq
c
e
h
a
f
r
3 9 1
16411
5
713
8
1011
17 11
0
6
39
1
1
2
8
82
15
1
2
Cost
contours
2
65
Uniform-Cost Search (UCS)
Expand node 𝑛 (in the frontier) with the lowest path cost 𝑔(𝑛) Extension of BFS that is proper for any step cost function
Implementation: Priority queue (ordered by path cost) for
frontier
Equivalent to breadth-first if all step costs are equal
Two differences
Goal test is applied when a node is selected for expansion
A test is added when a better path is found to a node currently on the frontier
66
80 + 97 + 101 < 99 + 211
…
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
“effective depth” is roughly C*/
Takes time O(bC*/) (exponential in effective depth)
How much space does the frontier 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!
b
C*/ “tiers”c 3
c 2
c 1
67
Uniform-cost search (proof of optimality)
Lemma: If UCS selects a node 𝑛 for expansion, the optimal
solution to that node has been found.
Proof by contradiction: Another frontier node 𝑛′ must exist on the
optimal path from initial node to 𝑛 (using graph separation property).
Moreover, based on definition of path cost (due to non-negative step
costs, paths never get shorter as nodes are added), we have 𝑔 𝑛′
≤ 𝑔 𝑛 and thus 𝑛′ would have been selected first.
⇒ Nodes are expanded in order of their optimal path cost.
68
Properties of uniform-cost search
Complete?
Yes, if step cost ≥ 𝜀 > 0 (to avoid infinite sequence of zero-costactions)
Time
Number of nodes with “𝑔 ≤ cost of optimal solution”, 𝑂(𝑏1+ Τ𝐶∗ 𝜀)where 𝐶∗ is the optimal solution cost
𝑂(𝑏𝑑+1) when all step costs are equal
Space
Number of nodes with 𝑔 ≤ cost of optimal solution,𝑂(𝑏1+ Τ𝐶∗ 𝜀)
Optimal?
Yes – nodes expanded in increasing order of 𝑔(𝑛)
Difficulty: many long paths of actions may exist with cost ≤ 𝐶∗
69
Uniform Cost Issues
Remember: UCS explores increasing costcontours
The good: UCS is complete and optimal!
The bad: Explores options in every “direction” No information about goal location
We’ll fix that soon!
Start Goal
…
c 3
c 2
c 1
70
The One Queue
All these search algorithms are the
same except for frontier strategies
Conceptually, all frontiers are priority
queues (i.e. collections of nodes with
attached priorities)
Practically, for DFS and BFS, you can
avoid the log(n) overhead from an
actual priority queue, by using stacks
and queues
Can even code one implementation
that takes a variable queuing object
71
Bidirectional search
Simultaneous forward and backward search (hoping that they
meet in the middle)
Idea: 𝑏𝑑/2 + 𝑏𝑑/2 is much less than 𝑏𝑑
“Do the frontiers of two searches intersect?” instead of goal test
First solution may not be optimal
Implementation
Hash table for frontiers in one of these two searches