Introduction to AI Lecture 3: Uninformed Search - PowerPoint PPT Presentation

1 / 64
About This Presentation
Title:

Introduction to AI Lecture 3: Uninformed Search

Description:

Formulation makes a big difference! Examples: ... Given 4 and 3 liter jugs, a water pump, and a sink, ... State: (x,y) for liters in jugs 1 and 2, integers 0 to 4 ... – PowerPoint PPT presentation

Number of Views:320
Avg rating:3.0/5.0
Slides: 65
Provided by: Inderje9
Category:

less

Transcript and Presenter's Notes

Title: Introduction to AI Lecture 3: Uninformed Search


1
Introduction to AILecture 3 Uninformed Search
Problem solving by search definitions Graph
representation Graph properties and search
issues Uninformed search methods depth-first
search, breath-first, depth-limited search,
iterative deepening search, bi-directional
search. Blind Search
Heshaam Faili hfaili_at_ece.ut.ac.ir University of
Tehran
2
Problem Formulation
  • Goal formulation, based on the current situation
    and performance measure
  • Problem formulation is the process of deciding
    what actions and states to consider, given a
    goal.
  • an agent with several options can decide what to
    do by first examining different possible
    sequences of actions that lead to states of known
    value, and then choosing the best sequence.
  • This process of looking for such a sequence is
    called search.
  • search algorithm takes a problem as input and
    returns a solution in the form of an action
    sequence.
  • execution Once a solution is found, the actions
    it recommends can be carried out

3
Static, Observable, Discrete, deterministic
open-loop System when it is executing the
sequence it ignores its percepts
4
Problem solving by search
Represent the problem as STATES and OPERATORS
that transform one state into another state. A
solution to the problem is an OPERATOR SEQUENCE
that transforms the INITIAL STATE into a GOAL
STATE. Finding the sequence requires SEARCHING
the STATE SPACE by GENERATING the paths
connecting the two.
5
Search by generating states
Initial state
3
2
100
1
4
5
Goal state
6
Operations
1 --gt 2 1 --gt6 2 --gt 3
2 --gt 5 3 --gt 5 5 --gt 4
6
Basic concepts (1)
  • State finite representation of the world at a
    given time.
  • Operator(action formulation) a function that
    transforms a state into another (also
    called rule, transition, successor function,
    production, action)
  • Initial state world state at the beginning.
  • Goal state desired world state (can be several)
  • Goal test test to determine if the goal has been
    reached.

7
Basic concepts (2)
  • Reachable goal a state for which there exists
    a sequence of operators to reach it.
  • State space set of all reachable states from
    initial state (possibly infinite).
  • Cost function a function that assigns a cost
    to each operation.
  • Performance
  • cost of the final operator sequence (path cost)
  • cost of finding the sequence

8
Problem formulation
  • The first taks is to formulate the problem in
    terms of states and operators
  • Some problems can be naturally defined this way,
    others not!
  • Formulation makes a big difference!
  • Examples
  • Vacuum world, water jug problem, tic-tac-toe,
    8-puzzle, 8-queen problem, cryptoarithmetic
  • robot world, travelling salesman, part assembly

9
Vacuum World Example
  • States 222 8
  • Initial state any state
  • Successor function (operators) three actions
    (left, right, suck)
  • Goal Test ?
  • Path test each step cost is one ,

10
Vacuum World State Space
11
Example 1 water jug (1)
Given 4 and 3 liter jugs, a water pump, and a
sink, how do you get exactly two liters into the
4 liter jug?
4
3
Jug 2
Jug 1
Pump
Sink
  • State (x,y) for liters in jugs 1 and 2,
    integers 0 to 4
  • Operations empty jug, fill jug, pour water
    between jugs
  • Initial state (0,0) Goal state (2,n)

12
Water jug Successor functions
a move
1. (x, y x lt 4) (4, y) Fill 4 2. (x, y y
lt 3) (x, 3) Fill 3 3. (x, y x gt 0) (0,
y) Dump 4 4. (x, y y gt 0) (x, 0) Dump
3 5. (x, y xy gt4 and ygt0) (4, y - (4 - x))
Pour from 3 to 4 until 4 is full 6. (x, y
xy gt3 and xgt0) (x - (3 - y), 3) Pour
from 4 to 3 until 3 is full 7. (x, y xy lt4
and ygt0) (xy, 0) Pour all water
from 3 to 4
b move
13
Water Jug Problem one solution
Gallons in y 0 3 0 3 2 2 0
Trasition Rule
2 fill 3
7 pour from 3 to 4
2 fill 3
5 pour from 3 to 4 until 4 is
full
3 dump 4
7 pour from 3 to 4
14
Example 2 Cryptoarithmetic
Assign numbers to letters so that the sum is
correct
F O R T Y T E N T E N S I X T Y
2 9 7 8 6 8 5 0 8 5 0 3 1 4 8 6
Solution F2, O9 R7, T8 Y6, E5 N0, I1 X4
  • State a matrix, with letters and numbers
  • Operations replace all occurrences of a letter
    with a digit not already there
  • Goal test only digits, sum is correct

15
Example 3 8-puzzle
  • State a matrix, with letters and numbers
  • Operation exchange tile with adjacent empty
    space
  • Goal test state matches final state cost is
    of moves

16
Example 4 8-queens
  • State any arrangement of up to 8 queens on the
    board
  • Operation add a queen (incremental), move a
    queen (fix-it)
  • Goal test no queen is attacked
  • Improvements only non-attacked states, place in
    leftmost non-attacked position (2057
    possibilities instead of 648)

17
Some of Real Problems
  • route-finding problem
  • Touring problems
  • traveling salesperson problem
  • VLSI layout
  • Robot navigation
  • Automatic assembly sequencing
  • protein design
  • In- Internet searching,

18
Graph representation
  • Nodes represent states
    G(V,E)
  • Directed edges represent operation applications
    -- labels indicate operation applied
  • Initial, goal states are start and end nodes
  • Edge weight cost of applying an operator
  • Search find a path from start to end node
  • Graph is generated dynamically as we search

19
Graph characteristics
  • A tree, directed acyclic graph, or graph with
    cycles -- depends on state repetitions
  • Number of states (n)
  • size of problem space, possibly infinite
  • Branching factor (b)
  • of operations that can be applied at each
    state
  • maximum number of outgoing edges
  • Depth level (d)
  • number of edges from the initial state
  • the depth of the shallowest goal node
  • Max path (m)
  • maximum length of any path in the state Space

20
Water jug problem tree

b
a
(0,0)
(0,3)
(4,0)
b
a
(4,3)
(4,3)
(0,0)
(3,0)
(0,0)
(1,3)
(0,3)
(1,0)
(4,0)
(4,3)
(2,0)
(2,3)
21
Water jug problem graph
(0,0)
(4,0)
(0,3)
(1,3)
(4,3)
(3,0)
22
Data Structures
  • State structure with world parameters
  • Node
  • state, depth level
  • of predecesors, list of ingoing edges
  • of successors, list of outgoing edges
  • Edge from and to state, operation number, cost
  • Operation from state, to state, matching
    function
  • Hash table of operations
  • Queue to keep states to be expanded

23
Tree Search
24
(No Transcript)
25
Search issues graph generation
  • Tree vs. graph
  • how to handle state repetitions?
  • what to do with infinite branches?
  • How to select the next state to expand
  • uninformed vs. informed heuristic search
  • Direction of expansion
  • from start to goal, from goal to start, both.
  • Efficiency
  • What is the most efficient way to search?

26
Measuring problem-solving performance
  • Completeness
  • guarantees to find a solution if a solution
    exists, or return fail if none exists
  • Time complexity
  • of operations applied in the search
  • Space complexity
  • of nodes stored during the search
  • Optimality
  • Does the strategy find the highest-quality?

27
Measuring problem-solving performance
  • Search Cost
  • Time Memory
  • Path Cost
  • Total cost Search Cost Path Cost

28
Factors that affect search efficiency
1. More start or goal states? Move towards the
larger set
G
I
G
G
I
I
G
I
29
Factors that affect search efficiency
2. Branching factor move in the direction with
the lower branching factor
G
I
I
G
30
Uninformed search methods
  • No a-priori knowledge on which node is best to
    expand (ex crypto-arithmetic problem)
  • Depth-first search (DFS)
  • Breath-first search (BFS)
  • Uniform cost method
  • Depth-limited search
  • Iterative deepening search
  • Bidirectional search

31
A graph search problem...
4
4
A
B
C
3
S
G
5
5
G
4
3
D
E
F
2
4
32
becomes a tree
S
C
E
E
B
B
F
11
D
F
B
F
C
E
A
C
G
14
17
15
15
13
G
C
G
F
19
19
17
G
25
33
Breath-first search
Expand the tree in successive layers, uniformly
looking at all nodes at level n before
progressing to level n1
function Breath-First-Search(problem) returns
solution nodes Make-Queue(Make-Node(Initial-
State(problem)) loop do if nodes is empty then
return failure node Remove-Front (nodes)
if Goal-Testproblem applied to State(node)
succeeds then return node new-nodes
Expand (node, Operatorsproblem)) nodes
Insert-At-End-of-Queue(new-nodes) end
34
Breath-first search
S
A
D
B
D
A
E
C
E
E
B
B
F
11
D
F
B
F
C
E
A
C
G
14
17
15
15
13
G
C
G
F
19
19
17
G
25
35
BFS, example
36
BFS performance
37
Uniform Cost search
  • Breadth-first search is optimal when all step
    costs are equal
  • Uniform Cost function an algorithm that is
    optimal with any step cost function.
  • expands the node n with the lowest path cost.
  • Uniform-cost search does not care about the
    number of steps a path has, but only about their
    total cost.
  • Infinite loop if there is zero-cost action(NoOP
    action)

38
Uniform Cost search
  • Complete Optimal if every step is greater than
    or equal to some small positive constant ?
  • Worst-case time space complexity is
  • C is cost of optimal solution

39
Depth first search
Dive into the search tree as far as you can,
backing up only when there is no way to proceed
function Depth-First-Search(problem) returns
solution nodes Make-Queue(Make-Node(Initial-
State(problem)) loop do if nodes is empty then
return failure node Remove-Front (nodes)
if Goal-Testproblem applied to State(node)
succeeds then return node new-nodes
Expand (node, Operarorsproblem)) nodes
Insert-At-Front-of-Queue(new-nodes) end
40
Depth-first search
S
A
D
B
D
A
E
C
E
E
B
B
F
11
D
F
B
F
C
E
A
C
G
14
17
15
15
13
G
C
G
F
19
19
17
G
25
41
(No Transcript)
42
Backtracking search
  • A variant of depth-first search called
    backtracking search uses still less memory.
  • only one successor is generated at a time rather
    than all successors
  • Memory O(m) compare to DFS O(bm)
  • Not optimal

43
Depth-limited search
  • Like DFS, but the search is limited to a
    predefined depth (L).
  • The depth of each state is recorded as it is
    generated. When picking the next state to
    expand, only those with depth less or equal than
    the current depth are expanded.
  • Once all the nodes of a given depth are explored,
    the current depth is incremented.
  • Complete if Lgtd
  • Time Complexity O(bL)
  • Space complexity O(bL)
  • L ? DFS

44
Depth-limited search
S
depth 3
3
A
D
6
B
D
A
E
C
E
E
B
B
F
11
D
F
B
F
C
E
A
C
G
14
17
15
15
13
G
C
G
F
19
19
17
G
25
45
Limit can be based on knowledge of problem
  • L can be determined based on the problem.
  • Routing in Romania with 20 cities has L 19
  • But each cites can be reached via 9 cities L
    9 (Diameter)

46
IDS Iterative deepening search
  • Problem what is a good depth limit?
  • Answer make it adaptive!
  • Generate solutions at depth 1, 2, .

function Iterative-Deepening-Search(problem)
returns solution nodes Make-Queue(Make-Node(
Initial-State(problem) for depth 0 to
infinity if Depth-Limited-Search(problem,
depth) succeeds then return its
result end return failure
47
Iterative deepening search
S
S
S
A
D
Limit 0
Limit 1
S
S
S
A
D
A
D
B
D
A
E
Limit 2
48
IDS properties
  • Like depth-first search, its memory requirements
    are O(bd)
  • Like breadth-first search, it is complete when
    the branching factor is finite and optimal when
    the path cost is a nondecreasing function of the
    depth of the node.

49
Iterative search is not as wasteful as it might
seem
  • The root subtree is computed every time instead
    of storing it!
  • BFS b b2 bd (bd1 b) O(bd1)
  • Repeating the search takes (d1)1 (d)b (d
    - 1)b2 (1)bd O(bd)
  • IDS is faster than BFS
  • For b 10 and d 5 the number of nodes
    searched in DFS is 111,111 regular vs. 123,456
    repeated (only 11 more) !!

50
(No Transcript)
51
Bidirectional search
Expand nodes from the start and goal state
simultaneously. Check at each stage if the nodes
of one have been generated by the other. If
so, the path concatenation is the solution
  • The operators must be reversible
  • single start, single goal
  • Efficient check for identical states
  • Type of search that happens in each half

52
Bidirectional search
53
Bidirectional search
  • Search can be done by checking each node in both
    queues
  • Complexity O(bd/2) O(bd/2) O(bd/2)
  • E.g. d6, b10 and both sides are BFS
  • 22,200 node generation compare to 11,110,000 node
    in BFS
  • One of the queue should stay in memory and
    membership checking is done by hashing (O(1)) so,
    Space complexity O(bd/2)
  • Actions should be reversible
  • What is the goal if you have multiple goals ,
    generate a dummy goal and link all other goals to
    this node

54
Bidirectional search
S
Forward
Backwards
A
D
B
D
A
E
C
E
E
B
B
F
11
D
F
B
F
C
E
A
C
G
14
17
15
15
13
G
C
G
F
19
19
17
G
25
55
Comparing search strategies
56
Repeated states
  • Repeated states can the source of great
    inefficiency identical subtrees will be explored
    many times!

How much effort to invest in detecting
repetitions?
57
Repeated states, Example
d State Vs 2d
2d2 state with d step Vs 4d D20 800 Vs 1012
58
Repeated states
  • Using more memory in order to check repeated
    state
  • Algorithms that forget their history are doomed
    to repeat it.
  • Maintain Close-List beside Open-List(fringe)

59
Graph Search Vs Tree Search
60
Strategies for repeated states
  • Do not expand the state that was just generated
  • constant time, prevents cycles of length one,
    ie., A,B,A,B.
  • Do not expand states that appear in the path
  • depth of node, prevents some cycles of the type
    A,B,C,D,A
  • Do not expand states that were expanded before
  • can be expensive! Use hash table to avoid
    looking at all nodes every time.

61
Searching in Partial Information
  • Different types of incompleteness lead to three
    distinct problem types
  • Sensorless problems (conformant) If the agent
    has no sonsors at all
  • Contingency problem if the environment if
    partially observable or if action are uncertain
    (adversarial)
  • Exploration problems When the states and actions
    of the environment are unknown.

62
Sensorless problems
  • No sensor
  • Initial State(1,2,3,4,5,6,7,8)
  • After action Right the state (2,4,6,8)
  • After action Suck the state (4, 8)
  • After action Left the state (3,7)
  • After action Suck the state (8)
  • Answer Right,Suck,Left,Suck coerce the world
    into state 7 without any sensor
  • Belief State Such state that agent belief to be
    there
  • In observable Belief state correspond to one
    physical state
  • For S physical State 2S belief state

63
Summary uninformed search
  • Problem formulation and representation is key!
  • Implementation as expanding directed graph of
    states and transitions
  • Appropriate for problems where no solution is
    known and many combinations must be tried
  • Problem space is of exponential size in the
    number of world states -- NP-hard problems
  • Fails due to lack of space and/or time.

64
?
Write a Comment
User Comments (0)
About PowerShow.com