artificial intelligence chap2-2

Upload: jesse-sanders

Post on 14-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Artificial Intelligence Chap2-2

    1/147

    Artificial IntelligenceProblem solving by searching

    CSC 361

    Prof. Mohamed Batouche

    Computer Science DepartmentCCIS King Saud University

    Riyadh, Saudi Arabia

    [email protected]

  • 7/27/2019 Artificial Intelligence Chap2-2

    2/147

    Problem Solving by Searching

    Search Methods :Uninformed (Blind) search

  • 7/27/2019 Artificial Intelligence Chap2-2

    3/147

    3

    Search Methods Once we have defined the problem space (state representation, the initial state, the

    goal state and operators) is all done?

    Lets consider the River Problem:

    A farmer wishes to carry a wolf, a duck and corn across a river, from the south to thenorth shore. The farmer is the proud owner of a small rowing boat called Bountywhich he feels is easily up to the job. Unfortunately the boat is only large enough tocarry at most the farmer and one other item. Worse again, if left unattended the wolfwill eat the duck and the duck will eat the corn.

    How can the farmer safely transport the wolf, the duck and the corn to the oppositeshore?

    Farmer, Wolf,

    Duck and Corn

    boat

    River

  • 7/27/2019 Artificial Intelligence Chap2-2

    4/147

    4

    Search Methods The River Problem:

    F=Farmer W=Wolf D=Duck C=Corn /=River

    How can the farmer safely transport the wolf, the duck andthe corn to the opposite shore?

    FWCD/-

    -/FWCD

  • 7/27/2019 Artificial Intelligence Chap2-2

    5/147

    5

    Search Methods Problem formulation: State representation: location of farmer and items in both sides of river

    [items in South shore / items in North shore] : (FWDC/-, FD/WC, C/FWD )

    Initial State: farmer, wolf, duck and corn in the south shoreFWDC/-

    Goal State: farmer, duck and corn in the north shore-/FWDC

    Operators: the farmer takes in the boat at most one item from one side tothe other side

    (F-Takes-W, F-Takes-D, F-Takes-C, F-Takes-Self [himself only])

    Path cost: the number of crossings

  • 7/27/2019 Artificial Intelligence Chap2-2

    6/147

    6

    Search Methods

    State space:A problem is solved by moving from the initial state to the goal state by applying validoperators in sequence. Thus the state space is the set of states reachable from a particularinitial state.

    F W D C

    W D C

    F

    D C

    F W

    W C

    F D

    W D

    F C

    F W C

    D

    F W D C

    W

    F D C

    F W C

    D

    W C

    F D

    C

    F W D

    F C

    W D

    F D C

    W

    D

    F W C

    F W D

    C

    F W

    D C

    F W C

    D

    W D

    F C

    W

    F D C

    C

    F W D

    D C

    F W

    D

    F W C

    F D C

    W

    F W D

    C

    F D

    W C

    F W D C

    D

    F W C

    Initial state

    Goal state

    Deadends

    Illegal states

    repeatedstate intermediate state

  • 7/27/2019 Artificial Intelligence Chap2-2

    7/147

    7

    Search Methods Searching for a solution:We start with the initial state andkeep using the operators toexpand the parent nodes till we

    find a goal state.

    but the search space might belarge

    really large

    So we need some systematic wayto search.

    F W D C

    WD C

    F

    D C

    F W

    W C

    F D

    WD

    F C

    F W C

    D

    F W D C

    W

    F D C

    F W C

    D

    W C

    F D

    C

    F WD

    F C

    W D

    F D C

    W

    D

    F W C

    F W D

    C

    F W

    D C

    F W C

    D

    WD

    F C

    W

    F D C

    C

    F W D

    D C

    F W

    D

    F W C

    F D C

    W

    F WD

    C

    F D

    W C

    F W D C

    D

    F W C

  • 7/27/2019 Artificial Intelligence Chap2-2

    8/147

    8

    Search Methods Problem solution:

    A problem solution is simply the setof operators (actions) needed to

    reach the goal state from the initialstate:

    F-Takes-D, F-Takes-Self, F-Takes-W,

    F-Takes-D, F-Takes-C, F-Takes-Self,

    F-Takes-D.

    F W D C

    WD C

    F

    D C

    F W

    W C

    F D

    WD

    F C

    F W C

    D

    F W D C

    W

    F D C

    F W C

    D

    W C

    F D

    C

    F WD

    F C

    W D

    F D C

    W

    D

    F W C

    F W D

    C

    F W

    D C

    F W C

    D

    WD

    F C

    W

    F D C

    C

    F W D

    D C

    F W

    D

    F W C

    F D C

    W

    F WD

    C

    F D

    W C

    F W D C

    D

    F W C

  • 7/27/2019 Artificial Intelligence Chap2-2

    9/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    10/147

    Problem Solving by searching

    Basic Search Algorithms

  • 7/27/2019 Artificial Intelligence Chap2-2

    11/147

    11

    Basic Search Algorithms uninformed( Blind) search: breadth-first, depth-first,

    depth limited, iterative deepening, and bidirectional search

    informed (Heuristic) search: search is guided by anevaluation function: Greedy best-first, A*, IDA*, and beamsearch

    optimization in which the search is to find an optimal value

    of an objective function: hill climbing, simulated annealing,genetic algorithms, Ant Colony Optimization

    Game playing, an adversarial search: minimax algorithm,alpha-beta pruning

  • 7/27/2019 Artificial Intelligence Chap2-2

    12/147

    12

    What Criteria are used to Compare

    different search techniques ?As we are going to consider different techniques to search theproblem space, we need to consider what criteria we will use tocompare them.

    Completeness: Is the technique guaranteed to find an answer(if there is one).

    Optimality/Admissibility : does it always find a least-costsolution?- an admissible algorithm will find a solution with minimum cost

    Time Complexity: How long does it take to find a solution.

    Space Complexity: How much memory does it take to find asolution.

  • 7/27/2019 Artificial Intelligence Chap2-2

    13/147

    13

    Time and Space Complexity ?Time and space complexity are measured in terms of:

    The average number of new nodes we create when expanding

    a new node is the (effective) branching factor b.

    The (maximum) branching factor b is defined as the maximumnodes created when a new node is expanded.

    The length of a path to a goal is the depth d.

    The maximum length of any path in the state space m.

  • 7/27/2019 Artificial Intelligence Chap2-2

    14/147

    14

    Branching factors for some

    problems The eight puzzle has a (effective)

    branching factor of 2.13, so a search treeat depth 20 has about 3.7 million nodes:O(bd)

    Rubiks cube has a (effective) branchingfactor of 13.34. There are901,083,404,981,813,616 different states.The average depth of a solution is about18.

    Chess has a branching factor of about 35,there are about 10120 states (there areabout 1079 electrons in the universe).

    2 1 34 7 65 8

  • 7/27/2019 Artificial Intelligence Chap2-2

    15/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    16/147

    16

    The state Space

  • 7/27/2019 Artificial Intelligence Chap2-2

    17/147

    17

    Generic Search Algorithms

    Basic Idea: Off-line exploration of state space bygenerating successors of already-explored states (alsoknown as expanding states).

    Function GENERAL-SEARCH (problem, strategy)

    returns a solution or failure

    Initialize the search tree using the initial state of problem

    loop do

    ifthere are no candidates for expansion, then return failureChoose a leaf node for expansion according tostrategy

    if node contains goal state then returnsolution

    else expand node and add resulting nodes to search tree.

    end

  • 7/27/2019 Artificial Intelligence Chap2-2

    18/147

    18

    Representing Search

    Arad

    Zerind Sibiu Timisoara

    Oradea Fagaras Rimnicu VilceaArad

    Sibiu Bucharest

  • 7/27/2019 Artificial Intelligence Chap2-2

    19/147

    19

    Solution

  • 7/27/2019 Artificial Intelligence Chap2-2

    20/147

    20

    Implementation of GenericSearch Algorithm

    function general-search(problem, QUEUEING-FUNCTION)

    nodes = MAKE-QUEUE(MAKE-NODE(problem.INITIAL-STATE))

    loop do

    ifEMPTY(nodes) then return "failure"

    node = REMOVE-FRONT(nodes)

    ifproblem.GOAL-TEST(node.STATE) succeeds then return solution(node)

    nodes = QUEUEING-FUNCTION(nodes, EXPAND(node, problem.OPERATORS))

    end

    A nice fact about this search algorithm is that we can use a single algorithm to do

    many kinds of search. The only difference is in how the nodes are placed in the

    queue.The choice of queuing function is the main feature.

  • 7/27/2019 Artificial Intelligence Chap2-2

    21/147

    21

    Key Issues of State-Spacesearch algorithm

    Search process constructs a search tree root is the start node leaf nodes are:

    unexpanded nodes (in the nodes list)

    dead ends (nodes that arent goals and have no successors becauseno operators were applicable)

    Loops in a graph may cause a search tree to be infinite even if thestate space is small

    changing definition of how nodes are added to list leads to a differentsearch strategy

    Solution desired may be: just the goal state a path from start to goal state (e.g., 8-puzzle)

  • 7/27/2019 Artificial Intelligence Chap2-2

    22/147

    22

    Uninformed search strategies(Blind search)

    Uninformed (blind) strategies use only the information available inthe problem definition. These strategies order nodes withoutusing any domain specific information

    Contrary to Informed search techniques which might haveadditional information (e.g. a compass).

    Breadth-first search Uniform-cost search

    Depth-first search Depth-limited search Iterative deepening search Bidirectional search

  • 7/27/2019 Artificial Intelligence Chap2-2

    23/147

    Basic Search AlgorithmsUninformed Search

    Breadth First Search (BFS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    24/147

    24

    Breadth First Search (BFS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    25/147

    25

    Breadth First Search (BFS)

    Complete? Yes.

    Optimal? Yes, if path cost is nondecreasing function of depth

    Time Complexity: O(bd)

    Space Complexity: O(bd

    ), note that every node in the fringe is kept in the queue.

    Main idea: Expand all nodes at depth (i) before expanding nodes at depth (i + 1)

    Level-order Traversal.

    Implementation: Use of a First-In-First-Out queue (FIFO). Nodes visited first

    are expanded first. Enqueue nodes in FIFO (first-in, first-out) order.

  • 7/27/2019 Artificial Intelligence Chap2-2

    26/147

    26

    Breadth First Search

    QUEUING-FN:- successors added to endof queue Arad

    Zerind Sibiu Timisoara

    Oradea Fagaras Rimnicu VilceaAradArad Oradea Arad Lugoj

    Shallow nodes are expanded before deeper nodes.

  • 7/27/2019 Artificial Intelligence Chap2-2

    27/147

    Basic Search AlgorithmsUninformed Search

    Uniform Cost Search (UCS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    28/147

    28

    Uniform Cost Search (UCS)

    25

    1 7

    4 5

    [5] [2]

    [9][3]

    [7] [8]

    1 4

    [9][6]

    [x] = g(n)

    path cost of node n

    Goal state

  • 7/27/2019 Artificial Intelligence Chap2-2

    29/147

    29

    Uniform Cost Search (UCS)

    25

    [5] [2]

  • 7/27/2019 Artificial Intelligence Chap2-2

    30/147

    30

    Uniform Cost Search (UCS)

    25

    1 7

    [5] [2]

    [9][3]

  • 7/27/2019 Artificial Intelligence Chap2-2

    31/147

    31

    Uniform Cost Search (UCS)

    25

    1 7

    4 5

    [5] [2]

    [9][3]

    [7] [8]

  • 7/27/2019 Artificial Intelligence Chap2-2

    32/147

    32

    Uniform Cost Search (UCS)

    25

    1 7

    4 5

    [5] [2]

    [9][3]

    [7] [8]

    1 4

    [9][6]

  • 7/27/2019 Artificial Intelligence Chap2-2

    33/147

    33

    Uniform Cost Search (UCS)

    25

    1 7

    4 5

    [5] [2]

    [9][3]

    [7] [8]

    1 4

    [9]

    Goal state

    path cost

    g(n)=[6]

  • 7/27/2019 Artificial Intelligence Chap2-2

    34/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    35/147

    35

    Uniform Cost Search (UCS)

    In case of equal step costs, Breadth First search findsthe optimal solution.

    For any step-cost function, Uniform Cost searchexpands the node n with the lowest path cost.

    UCS takes into account the total cost: g(n).

    UCS is guided by path costs rather than depths.Nodes are ordered according to their path cost.

  • 7/27/2019 Artificial Intelligence Chap2-2

    36/147

    36

    Uniform Cost Search (UCS)

    Main idea: Expand the cheapest node. Where the cost is the path cost g(n).

    Implementation:

    Enqueue nodes in order of cost g(n).QUEUING-FN:- insert in order of increasing path cost.

    Enqueue new node at the appropriate position in the queue so that wedequeue the cheapest node.

    Complete? Yes. Optimal? Yes, if path cost is nondecreasing function of depth

    Time Complexity: O(bd)

    Space Complexity: O(bd), note that every node in the fringe keep in the queue.

  • 7/27/2019 Artificial Intelligence Chap2-2

    37/147

    Basic Search AlgorithmsUninformed Search

    Depth First Search (DFS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    38/147

    38

    Depth First Search (DFS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    39/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    40/147

    40

    Depth First Search

  • 7/27/2019 Artificial Intelligence Chap2-2

    41/147

    41

    Depth-First Search (DFS)

    QUEUING-FN:- insert successors atfront of queue

    Arad

    Zerind Sibiu Timisoara

    Arad Oradea

    Zerind Sibiu Timisoara

  • 7/27/2019 Artificial Intelligence Chap2-2

    42/147

    Basic Search AlgorithmsUninformed Search

    Depth-Limited Search (DLS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    43/147

    43

    Depth-Limited Search (DLS)

    Depth Bound = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    44/147

    44

    Depth-Limited Search (DLS)

    It is simply DFS with a depth bound.

    Searching is not permitted beyond the depth bound.

    Works well if we know what the depth of the solution is.

    Termination is guaranteed.

    If the solution is beneath the depth bound, the search

    cannot find the goal (hence this search algorithm isincomplete).

    Otherwise use Iterative deepening search (IDS).

  • 7/27/2019 Artificial Intelligence Chap2-2

    45/147

    45

    Depth-Limited Search (DLS)

    Main idea: Expand node at the deepest level, but limit depth to L.

    Implementation:Enqueue nodes in LIFO (last-in, first-out) order. But limit depth to L

    Complete? Yes if there is a goal state at a depth less than L

    Optimal? No

    Time Complexity: O(bL), where L is the cutoff.

    Space Complexity: O(bL), where L is the cutoff.

  • 7/27/2019 Artificial Intelligence Chap2-2

    46/147

    Basic Search AlgorithmsUninformed Search

    Iterative Deepening Search (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    47/147

    47

    Iterative Deepening Search (IDS)

    function ITERATIVE-DEEPENING-SEARCH():

    for depth = 0 to infinity do

    ifDEPTH-LIMITED-SEARCH(depth) succeeds

    then return its result

    end

    return failure

  • 7/27/2019 Artificial Intelligence Chap2-2

    48/147

    48

    Iterative Deepening Search (IDS)

    Key idea: Iterative deepening search (IDS) applies DLS repeatedlywith increasing depth. It terminates when a solution is found or nosolutions exists.

    IDS combines the benefits of BFS and DFS: Like DFS the memoryrequirements are very modest (O(bd)). Like BFS, it is completewhen the branching factor is finite.

    The total number of generated nodes is :

    N(IDS)=(d)b +(d-1) b2++(1)bd

    In general, iterative deepening is the preferred uninformed searchmethod when there is a large search space and the depth of the

    solution is not known.

  • 7/27/2019 Artificial Intelligence Chap2-2

    49/147

    49

    Iterative Deepening Search (IDS)

    L = 0

    L = 1

    L = 2

    L = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    50/147

    50

    Iterative Deepening Search (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    51/147

    51

    Iterative Deepening Search (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    52/147

    Basic Search AlgorithmsUninformed Search

    Bi-Directional Search (BDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    53/147

    53

    Bi-directional Search (BDS)

    Main idea: Start searching fromboth the initial state and the goalstate, meet in the middle.

    Complete? Yes

    Optimal? Yes

    Time Complexity: O(bd/2), whered is the depth of the solution.

    Space Complexity: O(bd/2), whered is the depth of the solution.

  • 7/27/2019 Artificial Intelligence Chap2-2

    54/147

    Basic Search Algorithms

    Comparison of search algorithms

    C i f h

  • 7/27/2019 Artificial Intelligence Chap2-2

    55/147

    55

    Comparison of searchalgorithms

    b: Branching factord: Depth of solutionm: Maximum depth

    l : Depth Limit

  • 7/27/2019 Artificial Intelligence Chap2-2

    56/147

    Blind Search Algorithms

    Tree Search:

    BFS, DFS, DLS, IDS

  • 7/27/2019 Artificial Intelligence Chap2-2

    57/147

    Basic Search Algorithms

    Breadth First Search

    BFS

  • 7/27/2019 Artificial Intelligence Chap2-2

    58/147

    58

    Breadth First Search Application1:

    Given the following state space (tree search), give the sequenceof visited nodes when using BFS (assume that the nodeOis thegoal state):

    A

    B C ED

    F G H I J

    K L

    O

    M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    59/147

    59

    Breadth First Search A,

    A

    B C ED

  • 7/27/2019 Artificial Intelligence Chap2-2

    60/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    61/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    62/147

    62

    Breadth First Search A,

    B,C,D

    A

    B C ED

    F G H I J

  • 7/27/2019 Artificial Intelligence Chap2-2

    63/147

    63

    Breadth First Search A,

    B,C,D,E

    A

    B C ED

    F G H I J

  • 7/27/2019 Artificial Intelligence Chap2-2

    64/147

    64

    Breadth First Search A,

    B,C,D,E,

    F,

    A

    B C ED

    F G H I J

  • 7/27/2019 Artificial Intelligence Chap2-2

    65/147

    65

    Breadth First Search A,

    B,C,D,E,

    F,G

    A

    B C ED

    F G H I J

    K L

  • 7/27/2019 Artificial Intelligence Chap2-2

    66/147

    66

    Breadth First Search A,

    B,C,D,E,

    F,G,H

    A

    B C ED

    F G H I J

    K L

  • 7/27/2019 Artificial Intelligence Chap2-2

    67/147

    67

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I

    A

    B C ED

    F G H I J

    K L M

  • 7/27/2019 Artificial Intelligence Chap2-2

    68/147

    68

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I,J,

    A

    B C ED

    F G H I J

    K L M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    69/147

    69

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I,J,

    K, A

    B C ED

    F G H I J

    K L M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    70/147

    70

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I,J,

    K,L A

    B C ED

    F G H I J

    K L

    O

    M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    71/147

    71

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I,J,

    K,L, M, A

    B C ED

    F G H I J

    K L

    O

    M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    72/147

    72

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I,J,

    K,L, M,N, A

    B C ED

    F G H I J

    K L

    O

    M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    73/147

    73

    Breadth First Search A,

    B,C,D,E,

    F,G,H,I,J,

    K,L, M,N,

    Goal state: O

    A

    B C ED

    F G H I J

    K L

    O

    M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    74/147

    74

    Breadth First Search The returned solution is the sequence of operators in the path:

    A, B, G, L, O

    A

    B C ED

    F G H I J

    K L

    O

    M N

  • 7/27/2019 Artificial Intelligence Chap2-2

    75/147

    Basic Search Algorithms

    Depth First Search

    DFS

  • 7/27/2019 Artificial Intelligence Chap2-2

    76/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    77/147

    77

    Depth First Search A,

    A

    B C ED

  • 7/27/2019 Artificial Intelligence Chap2-2

    78/147

    78

    Depth First Search A,B,

    A

    B C ED

    F G

  • 7/27/2019 Artificial Intelligence Chap2-2

    79/147

    79

    Depth First Search A,B,F,

    A

    B C ED

    F G

  • 7/27/2019 Artificial Intelligence Chap2-2

    80/147

    80

    Depth First Search A,B,F,

    G,

    A

    B C ED

    F G

    K L

  • 7/27/2019 Artificial Intelligence Chap2-2

    81/147

    81

    Depth First Search A,B,F,

    G,K,

    A

    B C ED

    F G

    K L

  • 7/27/2019 Artificial Intelligence Chap2-2

    82/147

    82

    Depth First Search A,B,F,

    G,K,

    L,

    A

    B C ED

    F G

    K L

    O

  • 7/27/2019 Artificial Intelligence Chap2-2

    83/147

    83

    Depth First Search A,B,F,

    G,K,

    L, O: Goal State

    A

    B C ED

    F G

    K L

    O

  • 7/27/2019 Artificial Intelligence Chap2-2

    84/147

    84

    Depth First SearchThe returned solution is the sequence of operators in the path:

    A, B, G, L, O

    A

    B C ED

    F G

    K L

    O

  • 7/27/2019 Artificial Intelligence Chap2-2

    85/147

    Basic Search Algorithms

    Depth-Limited Search

    DLS

  • 7/27/2019 Artificial Intelligence Chap2-2

    86/147

    86

    Depth-Limited Search (DLS) Application3:

    Given the following state space (tree search), give the sequenceof visited nodes when using DLS (Limit = 2):

    A

    B C ED

    F G H I J

    K L

    O

    M N

    Limit = 0

    Limit = 1

    Limit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    87/147

    87

    Depth-Limited Search (DLS) A,

    A

    B C ED

    Limit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    88/147

    88

    Depth-Limited Search (DLS) A,B,

    A

    B C ED

    F GLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    89/147

    89

    Depth-Limited Search (DLS) A,B,F,

    A

    B C ED

    F GLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    90/147

    90

    Depth-Limited Search (DLS) A,B,F,

    G,

    A

    B C ED

    F GLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    91/147

    91

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,

    A

    B C ED

    F G HLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    92/147

    92

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,H,

    A

    B C ED

    F G HLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    93/147

    93

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,H,

    D, A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    94/147

    94

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,H,

    D,I A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    95/147

    95

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,H,

    D,I

    J,

    A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    96/147

    96

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,H,

    D,I

    J, E

    A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    97/147

    97

    Depth-Limited Search (DLS) A,B,F,

    G,

    C,H,

    D,I

    J, E, Failure

    A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    98/147

    98

    Depth-Limited Search (DLS) DLS algorithm returns Failure (no solution)

    The reason is that the goal is beyond the limit (Limit =2): thegoal depth is (d=4)

    A

    B C ED

    F G H I J

    K L

    O

    M N

    Limit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    99/147

    Basic Search Algorithms

    Iterative Deepening Search

    IDS

  • 7/27/2019 Artificial Intelligence Chap2-2

    100/147

    100

    Iterative Deepening Search (IDS) Application4:

    Given the following state space (tree search), give the sequenceof visited nodes when using IDS:

    A

    B C ED

    F G H I J

    K L

    O

    M N

    Limit = 0

    Limit = 1

    Limit = 2

    Limit = 3

    Limit = 4

  • 7/27/2019 Artificial Intelligence Chap2-2

    101/147

    Iterative Deepening Search(IDS)

    DLS with bound = 0

  • 7/27/2019 Artificial Intelligence Chap2-2

    102/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    103/147

    103

    Iterative Deepening Search (IDS) A, Failure

    ALimit = 0

  • 7/27/2019 Artificial Intelligence Chap2-2

    104/147

    Iterative Deepening Search(IDS)

    DLS with bound = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    105/147

    105

    Iterative Deepening Search (IDS) A,

    A

    B C EDLimit = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    106/147

    106

    Iterative Deepening Search (IDS) A,B,

    A

    B C EDLimit = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    107/147

    107

    Iterative Deepening Search (IDS) A,B,

    C,

    A

    B C EDLimit = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    108/147

    108

    Iterative Deepening Search (IDS) A,B,

    C,

    D,

    A

    B C EDLimit = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    109/147

    109

    Iterative Deepening Search (IDS) A,B

    C,

    D,

    E, A

    B C EDLimit = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    110/147

    110

    Iterative Deepening Search (IDS) A,B,

    C,

    D,

    E, Failure A

    B C EDLimit = 1

  • 7/27/2019 Artificial Intelligence Chap2-2

    111/147

    111

    Iterative Deepening Search (IDS) A,

    A

    B C ED

    Limit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    112/147

    112

    Iterative Deepening Search (IDS) A,B,

    A

    B C ED

    F GLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    113/147

    113

    Iterative Deepening Search (IDS) A,B,F,

    A

    B C ED

    F GLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    114/147

    114

    Iterative Deepening Search (IDS) A,B,F,

    G,

    A

    B C ED

    F GLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    115/147

    115

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,

    A

    B C ED

    F G HLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    116/147

    116

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,H,

    A

    B C ED

    F G HLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    117/147

    117

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,H,

    D, A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    118/147

    118

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,H,

    D,I A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    119/147

    119

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,H,

    D,I

    J,

    A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    120/147

    120

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,H,

    D,I

    J, E

    A

    B C ED

    F G H I JLimit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    121/147

    121

    Iterative Deepening Search (IDS) A,B,F,

    G,

    C,H,

    D,I

    J, E, Failure

    A

    B C ED

    F G H I J

    K L

    O

    M N

    Limit = 2

  • 7/27/2019 Artificial Intelligence Chap2-2

    122/147

    Iterative Deepening Search(IDS)

    DLS with bound = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    123/147

    123

    Iterative Deepening Search (IDS) A,

    A

    B C ED

    Limit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    124/147

    124

    Iterative Deepening Search (IDS) A,B,

    A

    B C ED

    F G

    Limit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    125/147

    125

    Iterative Deepening Search (IDS) A,B,F,

    A

    B C ED

    F G

    Limit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    126/147

    126

    Iterative Deepening Search (IDS) A,B,F,

    G,

    A

    B C ED

    F G

    K LLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    127/147

    127

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    A

    B C ED

    F G

    K LLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    128/147

    128

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    A

    B C ED

    F G

    K LLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    129/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    130/147

    130

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H, A

    B C ED

    F G H

    K LLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    131/147

    131

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H,

    D,

    A

    B C ED

    F G H I J

    K LLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    132/147

    132

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H,

    D,I,

    A

    B C ED

    F G H I J

    K L MLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    133/147

    133

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H,

    D,I,M,

    A

    B C ED

    F G H I J

    K L MLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    134/147

    134

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H,

    D,I,M, J,

    A

    B C ED

    F G H I J

    K L M NLimit = 3

    h ( )

  • 7/27/2019 Artificial Intelligence Chap2-2

    135/147

    135

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H,

    D,I,M, J,N,

    A

    B C ED

    F G H I J

    K L M NLimit = 3

    i i S h ( S)

  • 7/27/2019 Artificial Intelligence Chap2-2

    136/147

    136

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    C,H,

    D,I,M, J,N,

    E,

    A

    B C ED

    F G H I J

    K L M NLimit = 3

  • 7/27/2019 Artificial Intelligence Chap2-2

    137/147

  • 7/27/2019 Artificial Intelligence Chap2-2

    138/147

    Iterative Deepening Search(IDS)

    DLS with bound = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    139/147

    139

    Iterative Deepening Search (IDS) A,

    A

    B C ED

    Limit = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    140/147

    140

    Iterative Deepening Search (IDS) A,B,

    A

    B C ED

    F G

    Limit = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    141/147

    141

    Iterative Deepening Search (IDS) A,B,F,

    A

    B C ED

    F G

    Limit = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    142/147

    142

    Iterative Deepening Search (IDS) A,B,F,

    G,

    A

    B C ED

    F G

    K L

    Limit = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    143/147

    143

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    A

    B C ED

    F G

    K L

    Limit = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    144/147

    144

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L,

    A

    B C ED

    F G

    K L

    OLimit = 4

    It ti D i S h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    145/147

    145

    Iterative Deepening Search (IDS) A,B,F,

    G,K,

    L, O:Goal State

    A

    B C ED

    F G

    K L

    OLimit = 4

    Ite ti e Deepening Se h (IDS)

  • 7/27/2019 Artificial Intelligence Chap2-2

    146/147

    146

    Iterative Deepening Search (IDS)The returned solution is the sequence of operators in the path:

    A, B, G, L, O

    A

    B C ED

    F G

    K L

    O

    Summary

  • 7/27/2019 Artificial Intelligence Chap2-2

    147/147

    Summary

    Search: process of constructing sequences of actions that achieve a goal given aproblem.

    The studied methods assume that the environment is observable, deterministic,static and completely known.

    Goal formulation is the first step in solving problems by searching. It facilitatesproblem formulation.

    Formulating a problem requires specifying four components: Initial states,operators, goal test and path cost function. Environment is represented as astate space.

    A solution is a path from the initial state to a goal state.

    Search algorithms are judged on the basis of completeness, optimality, timecomplexity and space complexity.

    Several search strategies: BFS, DFS, DLS, IDS,