ai lecture 5

Upload: shahzad-malik

Post on 07-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 AI Lecture 5

    1/28

    General problem solving

    and search methods

    Artificial Intelligence

  • 8/6/2019 AI Lecture 5

    2/28

    Contents

    5.1 Problem Solving by Search

    5.2 Search Strategies

    5.3 Blind Search 5.4 8-Puzzle Game

  • 8/6/2019 AI Lecture 5

    3/28

    5.1 Problem Solving by Search

    Problem: A problem can be considered to consist of a goal and a set of

    actions that can be taken to lead to the goal.

    Search:

    Search is a method that can be used by computers to examine a

    problem in order to find a goal.

    At any given time we consider the state of the search to

    represent where we have reached as a result of the actions we

    have applied so far. A problem can be considered to be a search because in order to

    solve the problem, we will search for a goal state.

    Problem solving ! Searching for a goal state

  • 8/6/2019 AI Lecture 5

    4/28

    5.1 Problem Solving by Search

    Data Driven or Goal driven search:

    Forward Chaining

    Backward Chaining

    Appr oaches: Top-Down Search:

    Starts from an initial state and uses actions to moveforward until a goal is reached. This is known as

    forward chaining search. Bottom-Up Search:

    Search starts at the goal and work back toward a startstate by seeing what moves could have led to the goalstate known as backward chaining search.

  • 8/6/2019 AI Lecture 5

    5/28

    5.2 Search Strategies

    Requirements of a good search strategy:1. It causes motion

    Otherwise, it will never lead to a solution.

    2. It is systematic

    Otherwise, it may use more steps than

    necessary.

    3. It is efficient

    Find a good, but not necessarily the best,

    answer.

  • 8/6/2019 AI Lecture 5

    6/28

    5.2 Search Strategies

    There are two search strategies

    Blind/uninformed search

    Informed/Heuristic search Any path/Non-optimal search

    Optimal Search

  • 8/6/2019 AI Lecture 5

    7/28

    A. Blind/uninformed search

    The uninformed orblind search is

    The search methodology having no additionalinformation about search states beyond that

    provided in the problem definitions. In thissearch total search space is looked forsolution

    Having no information about the numberof

    steps from the current state to the goal.

    Zer o information search

  • 8/6/2019 AI Lecture 5

    8/28

  • 8/6/2019 AI Lecture 5

    9/28

    B. Informed/Heuristic Search

    More efficient than uninformed search Heuristic:

    involving or serving as an aid to learning, discovery, orproblem-solving by experimental and especially trial-and-

    error methods.(Merriam-Websters dictionary)

    A Heuristic is an operationally-effective piece ofinformation on how to direct search in a problem

    space. Heuristics are only approximately correct. Theirpurpose is to minimize search on average.

    Heuristic technique improves the efficiencyof asearch process

  • 8/6/2019 AI Lecture 5

    10/28

    B. Informed/Heuristic Search

    Best-First Search an algorithm in which a

    node is selected for expansion based on an

    evaluation function f(n)

    Traditionally the node with the lowest evaluationfunction is selected

    Not an accurate nameexpanding the best node first

    would be a straight march to the goal.

    Choose the node that appears tobe the best A* (A star) is the most widely known form of Best-First

    search

  • 8/6/2019 AI Lecture 5

    11/28

    Example of Mouse and Cheese

    For example Suppose that cheese is fresh and it smells

    The mouse will use this smell as guide to guess theposition of the cheese

    Will choose the best from the alternative choices. As smell gets stronger he mouse knows that the cheeseis closer

    Hence the mouse is informed about the cheese and thusthe search is informed

    You might think that informed search is the bestsolution to the problem

    But its not true

    Mouse found the cheese but not from the bestoptimal path.

  • 8/6/2019 AI Lecture 5

    12/28

    B. Informed/Heuristic Search

    Any path/Non optimal search

    In this search we are concerned with finding

    any solution

    As we find the solution we stop the search

    There could have been a better path which

    might take lesser time

    Optimal path search We find the solution that are least costly

  • 8/6/2019 AI Lecture 5

    13/28

    5.3 Blind Search

    Breadth-first search Expand all the nodes of

    one level first.

    Depth-first search

    Expand one of the nodesat the deepest level.

  • 8/6/2019 AI Lecture 5

    14/28

    5.3 Blind Search

    Tree Search

    A tree search starts at the

    root and explores nodes from

    there, looking for a goal node

    For some problems, any goalnode is acceptable (N orJ);

    forother problems, you want

    a minimum-depth goal node,

    that is, a goal node nearestthe root (onlyJ)

    L M N O P

    G

    Q

    H JI K

    FED

    B C

    A

    Goal nodes

  • 8/6/2019 AI Lecture 5

    15/28

    Depth-first searching

    A depth-first search (DFS)explores a path all the wayto a leafbeforebacktracking and exploringanother path

    For example, aftersearching A, then B, thenD, the search backtracksand tries another path fromB

    Node are explored in theorderA B D E H L M N IO P C F G J K Q

    N will be found before J

    L M N O P

    G

    Q

    H JI K

    FED

    B C

    A

  • 8/6/2019 AI Lecture 5

    16/28

    Depth First Search

    1

    7

    8

    6

    5

    2

    3

    4

    SG

    SI

  • 8/6/2019 AI Lecture 5

    17/28

    Breadth-First Search

    1

    12

    111098765

    432

    SG

  • 8/6/2019 AI Lecture 5

    18/28

    Backwards Breadth-First

    Search9

    87654

    32

    1

    SI

    SG

  • 8/6/2019 AI Lecture 5

    19/28

    Bi-Directional

    Breadth-First Search1

    3 4

    8 9 10 11 12

    2

    13

    75 6

    SG

    SI

  • 8/6/2019 AI Lecture 5

    20/28

    Breadth-first searching

    A breadth-first search(BFS) explores nodesnearest the root beforeexploring nodes further

    away For example, aftersearching A, then B,then C, the searchproceeds with D, E, F, G

    Node are explored inthe orderA B C D E F GH I J K L M N O P Q

    J will be found before N

    L M N O P

    G

    Q

    H JI K

    FED

    B C

    A

  • 8/6/2019 AI Lecture 5

    21/28

    Depth- vs. breadth-first searching

    When a breadth-first search succeeds, it finds aminimum-depth (nearest the root) goal node

    When a depth-first search succeeds, the found

    goal node is not necessarily minimum depth

    For a large tree, breadth-first search memory

    requirements maybe excessive

    For a large tree, a depth-first search may take

    an excessively long time to find even a verynearby goal node

  • 8/6/2019 AI Lecture 5

    22/28

    Depth- vs. breadth-first searching

    Breadth-first is complete and optimal, but

    has high space complexity

    Bad when branching factor is high

    Depth-first is space efficient, but neither

    complete noroptimal

    Bad when search depth is infinite

    How can we combine the advantages (and

    avoid the disadvantages)of these two

    search techniques?

  • 8/6/2019 AI Lecture 5

    23/28

    Depth-limited searching

    Depth-first searches maybe performed with adepth limit:

    limit = 0;found = false;while (not found) {

    found = limitedDFS(root, limit, 0);limit = limit + 1;

    }

    This searches to depth 0 (root only), then if thatfails it searches to depth 1, then depth 2, etc.

    If a goal node is found, it is a nearest node and thepath to it is on the stack

  • 8/6/2019 AI Lecture 5

    24/28

    2424

    5.4 8-Puzzle Game

    An unsolved 8-Puzzle

  • 8/6/2019 AI Lecture 5

    25/28

    2525

    A Sample Search Tree

  • 8/6/2019 AI Lecture 5

    26/28

    2626

    A Sample

    Search Tree

  • 8/6/2019 AI Lecture 5

    27/28

    2727

    A Sample

    SearchTree

  • 8/6/2019 AI Lecture 5

    28/28

    2828

    A Sample

    Search Tree