04 problem solving

Upload: lamba5

Post on 02-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 04 Problem Solving

    1/112

    Introduction to Artificial Intelligence

    Problem Solving and Search

    Bernhard Beckert

    UNIVERSITT KOBLENZ-LANDAU

    Wintersemester 2003/2004

    B. Beckert: Einfhrung in die KI / KI fr IM p.1

  • 8/10/2019 04 Problem Solving

    2/112

    Outline

    Problem solving

    Problem types

    Problem formulation

    Example problems

    Basic search algorithms

    B. Beckert: Einfhrung in die KI / KI fr IM p.2

  • 8/10/2019 04 Problem Solving

    3/112

  • 8/10/2019 04 Problem Solving

    4/112

    Example: Travelling in Romania

    Scenario

    On holiday in Romania; currently in Arad

    Flight leaves tomorrow from Bucharest

    B. Beckert: Einfhrung in die KI / KI fr IM p.4

  • 8/10/2019 04 Problem Solving

    5/112

    Example: Travelling in Romania

    Scenario

    On holiday in Romania; currently in Arad

    Flight leaves tomorrow from Bucharest

    Goal

    Be in Bucharest

    B. Beckert: Einfhrung in die KI / KI fr IM p.4

  • 8/10/2019 04 Problem Solving

    6/112

    Example: Travelling in Romania

    Scenario

    On holiday in Romania; currently in Arad

    Flight leaves tomorrow from Bucharest

    Goal

    Be in Bucharest

    Formulate problem

    States: various cities

    Actions: drive between cities

    B. Beckert: Einfhrung in die KI / KI fr IM p.4

  • 8/10/2019 04 Problem Solving

    7/112

    Example: Travelling in Romania

    Scenario

    On holiday in Romania; currently in Arad

    Flight leaves tomorrow from Bucharest

    Goal

    Be in Bucharest

    Formulate problem

    States: various cities

    Actions: drive between cities

    Solution

    Appropriate sequence of citiese.g.: Arad, Sibiu, Fagaras, Bucharest

    B. Beckert: Einfhrung in die KI / KI fr IM p.4

  • 8/10/2019 04 Problem Solving

    8/112

    Example: Travelling in Romania

    Giurgiu

    Urziceni

    Hirsova

    Eforie

    Neamt

    Oradea

    Zerind

    Arad

    Timisoara

    Lugoj

    Mehadia

    Dobreta

    Craiova

    Sibiu Fagaras

    Pitesti

    Vaslui

    Iasi

    Rimnicu Vilcea

    Bucharest

    B. Beckert: Einfhrung in die KI / KI fr IM p.5

  • 8/10/2019 04 Problem Solving

    9/112

    Problem types

    Single-state problem

    observable (at least the initial state)

    deterministic

    static discrete

    Multiple-state problem

    partially observable (initial state not observable)

    deterministic

    static

    discrete

    Contingency problem

    partially observable (initial state not observable)

    non-deterministicB. Beckert: Einfhrung in die KI / KI fr IM p.6

  • 8/10/2019 04 Problem Solving

    10/112

    Example: vacuum-cleaner world

    Single-state

    Start in: 5

    Solution:

    1 2

    3 4

    5 6

    7 8

    B. Beckert: Einfhrung in die KI / KI fr IM p.7

  • 8/10/2019 04 Problem Solving

    11/112

    Example: vacuum-cleaner world

    Single-state

    Start in: 5

    Solution: [right,suck]

    1 2

    3 4

    5 6

    7 8

    B. Beckert: Einfhrung in die KI / KI fr IM p.7

  • 8/10/2019 04 Problem Solving

    12/112

    Example: vacuum-cleaner world

    Single-state

    Start in: 5

    Solution: [right,suck]

    Multiple-state

    Start in:{1,

    2,

    3,

    4,

    5,

    6,

    7,

    8}

    Solution:

    1 2

    3 4

    5 6

    7 8

    B. Beckert: Einfhrung in die KI / KI fr IM p.7

  • 8/10/2019 04 Problem Solving

    13/112

    Example: vacuum-cleaner world

    Single-state

    Start in: 5

    Solution: [right,suck]

    Multiple-state

    Start in:{1,

    2,

    3,

    4,

    5,

    6,

    7,

    8}

    Solution: [right,suck,left,suck]

    right {2,4,6,8}

    suck {4,8}

    left {3,7}

    suck {7}

    1 2

    3 4

    5 6

    7 8

    B. Beckert: Einfhrung in die KI / KI fr IM p.7

  • 8/10/2019 04 Problem Solving

    14/112

    Example: vacuum-cleaner world

    Contingency

    Murphys Law:

    suckcan dirty a clean carpet

    Local sensing:

    dirty/not dirtyat location only

    Start in:{1,3}

    Solution:

    1 2

    3 4

    5 6

    7 8

    B. Beckert: Einfhrung in die KI / KI fr IM p.8

  • 8/10/2019 04 Problem Solving

    15/112

    Example: vacuum-cleaner world

    Contingency

    Murphys Law:

    suckcan dirty a clean carpet

    Local sensing:

    dirty/not dirtyat location only

    Start in:{1,3}

    Solution: [suck,right,suck]

    suck {5,

    7}right {6,8}

    suck {6,8}

    Improvement: [suck,right, ifdirt thensuck]

    (decide whether in 6or 8using local sensing)

    1 2

    3 4

    5 6

    7 8

    B. Beckert: Einfhrung in die KI / KI fr IM p.8

  • 8/10/2019 04 Problem Solving

    16/112

    Single-state problem formulation

    Defined by the following four items

    1. Initial state

    Example: Arad

    2. Successor functionS

    Example: S(Arad) = { goZerind, Zerind, goSibiu, Sibiu, . . . }

    3. Goal test

    Example: x=Bucharest (explicit test)

    noDirt(x) (implicit test)

    4. Path cost (optional)

    Example: sum of distances, number of operators executed, etc.

    B. Beckert: Einfhrung in die KI / KI fr IM p.9

  • 8/10/2019 04 Problem Solving

    17/112

    Single-state problem formulation

    Solution

    A sequence of operators

    leading from the initial state to a goal state

    B. Beckert: Einfhrung in die KI / KI fr IM p.10

  • 8/10/2019 04 Problem Solving

    18/112

    Selecting a state space

    Abstraction

    Real world is absurdly complex

    State space must be abstracted for problem solving

    (Abstract) state

    Set of real states

    (Abstract) operator

    Complex combination of real actions

    Example:Arad Zerindrepresents complex set of possible routes

    (Abstract) solution

    Set of real paths that are solutions in the real world

    B. Beckert: Einfhrung in die KI / KI fr IM p.11

  • 8/10/2019 04 Problem Solving

    19/112

    Example: The 8-puzzle

    2

    Start State Goal State

    51 3

    4 6

    7 8

    5

    1

    2

    3

    4

    6

    7

    8

    5

    States

    Actions

    Goal test

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.12

  • 8/10/2019 04 Problem Solving

    20/112

    Example: The 8-puzzle

    2

    Start State Goal State

    51 3

    4 6

    7 8

    5

    1

    2

    3

    4

    6

    7

    8

    5

    States integer locations of tiles

    Actions

    Goal test

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.12

  • 8/10/2019 04 Problem Solving

    21/112

    Example: The 8-puzzle

    2

    Start State Goal State

    51 3

    4 6

    7 8

    5

    1

    2

    3

    4

    6

    7

    8

    5

    States integer locations of tiles

    Actions left,right,up,down

    Goal test

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.12

  • 8/10/2019 04 Problem Solving

    22/112

    Example: The 8-puzzle

    2

    Start State Goal State

    51 3

    4 6

    7 8

    5

    1

    2

    3

    4

    6

    7

    8

    5

    States integer locations of tiles

    Actions left,right,up,down

    Goal test = goal state?

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.12

  • 8/10/2019 04 Problem Solving

    23/112

    Example: The 8-puzzle

    2

    Start State Goal State

    51 3

    4 6

    7 8

    5

    1

    2

    3

    4

    6

    7

    8

    5

    States integer locations of tiles

    Actions left,right,up,down

    Goal test = goal state?

    Path cost 1per move

    B. Beckert: Einfhrung in die KI / KI fr IM p.12

  • 8/10/2019 04 Problem Solving

    24/112

    Example: Vacuum-cleaner

    R

    L

    S S

    S S

    R

    L

    R

    L

    R

    L

    S

    SS

    S

    L

    L

    LL R

    R

    R

    R

    States

    Actions

    Goal test

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.13

  • 8/10/2019 04 Problem Solving

    25/112

    Example: Vacuum-cleaner

    R

    L

    S S

    S S

    R

    L

    R

    L

    R

    L

    S

    SS

    S

    L

    L

    LL R

    R

    R

    R

    States integer dirt and robot locations

    Actions

    Goal test

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.13

  • 8/10/2019 04 Problem Solving

    26/112

    Example: Vacuum-cleaner

    R

    L

    S S

    S S

    R

    L

    R

    L

    R

    L

    S

    SS

    S

    L

    L

    LL R

    R

    R

    R

    States integer dirt and robot locations

    Actions left,right,suck,noOp

    Goal test

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.13

  • 8/10/2019 04 Problem Solving

    27/112

    Example: Vacuum-cleaner

    R

    L

    S S

    S S

    R

    L

    R

    L

    R

    L

    S

    SS

    S

    L

    L

    LL R

    R

    R

    R

    States integer dirt and robot locations

    Actions left,right,suck,noOp

    Goal test not dirty?

    Path cost

    B. Beckert: Einfhrung in die KI / KI fr IM p.13

    E l V l

  • 8/10/2019 04 Problem Solving

    28/112

    Example: Vacuum-cleaner

    R

    L

    S S

    S S

    R

    L

    R

    L

    R

    L

    S

    SS

    S

    L

    L

    LL R

    R

    R

    R

    States integer dirt and robot locations

    Actions left,right,suck,noOp

    Goal test not dirty?

    Path cost 1per operation (0fornoOp)

    B. Beckert: Einfhrung in die KI / KI fr IM p.13

    E l R b ti bl

  • 8/10/2019 04 Problem Solving

    29/112

    Example: Robotic assembly

    R

    RR

    P

    R R

    States

    Actions

    Goal test

    Path costB. Beckert: Einfhrung in die KI / KI fr IM p.14

    E l R b ti bl

  • 8/10/2019 04 Problem Solving

    30/112

    Example: Robotic assembly

    R

    RR

    P

    R R

    States real-valued coordinates of

    robot joint angles and parts of the object to be assembled

    Actions

    Goal test

    Path costB. Beckert: Einfhrung in die KI / KI fr IM p.14

    Example: Robotic assembly

  • 8/10/2019 04 Problem Solving

    31/112

    Example: Robotic assembly

    R

    RR

    P

    R R

    States real-valued coordinates of

    robot joint angles and parts of the object to be assembled

    Actions continuous motions of robot joints

    Goal test

    Path costB. Beckert: Einfhrung in die KI / KI fr IM p.14

    Example: Robotic assembly

  • 8/10/2019 04 Problem Solving

    32/112

    Example: Robotic assembly

    R

    RR

    P

    R R

    States real-valued coordinates of

    robot joint angles and parts of the object to be assembled

    Actions continuous motions of robot joints

    Goal test assembly complete?

    Path costB. Beckert: Einfhrung in die KI / KI fr IM p.14

    Example: Robotic assembly

  • 8/10/2019 04 Problem Solving

    33/112

    Example: Robotic assembly

    R

    RR

    P

    R R

    States real-valued coordinates of

    robot joint angles and parts of the object to be assembled

    Actions continuous motions of robot joints

    Goal test assembly complete?

    Path cost time to executeB. Beckert: Einfhrung in die KI / KI fr IM p.14

    Tree search algorithms

  • 8/10/2019 04 Problem Solving

    34/112

    Tree search algorithms

    Offline

    Simulated exploration of state space in a search tree

    by generating successors of already-explored states

    functionTREE-SEARCH( problem,strategy)returnsa solution or failure

    initialize the search tree using the initial state ofproblem

    loop do

    ifthere are no candidates for expansionthen returnfailure

    choose a leaf node for expansion according tostrategy

    ifthe node contains a goal statethenreturnthe corresponding solution

    else

    expand the node and add the resulting nodes to the search tree

    end

    B. Beckert: Einfhrung in die KI / KI fr IM p.15

  • 8/10/2019 04 Problem Solving

    35/112

    Tree search: Example

  • 8/10/2019 04 Problem Solving

    36/112

    Tree search: Example

    Rimnicu Vilcea LugojArad Fagaras Oradea AradArad Oradea

    Zerind

    Arad

    Sibiu Timisoara

    B. Beckert: Einfhrung in die KI / KI fr IM p.16

    Tree search: Example

  • 8/10/2019 04 Problem Solving

    37/112

    Tree search: Example

    Lugoj AradArad OradeaRimnicu Vilcea

    Zerind

    Arad

    Sibiu

    Arad Fagaras Oradea

    Timisoara

    B. Beckert: Einfhrung in die KI / KI fr IM p.16

  • 8/10/2019 04 Problem Solving

    38/112

    Implementation of search algorithms

  • 8/10/2019 04 Problem Solving

    39/112

    Implementation of search algorithms

    functionTREE-SEARCH( problem, fringe)returnsa solution or failure

    fringeINSERT(MAKE-NODE(INITIAL-STATE[problem]),fringe)

    loop do

    iffringeis emptythen returnfailure

    nodeREMOVE-FIRST(fringe)

    ifGOAL-TEST[problem] applied to STATE(node) succeedsthen

    returnnode

    else

    fringeINSERT-ALL(EXPAND(node,problem), fringe)

    end

    fringe queue of nodes not yet considered

    State gives the state that is represented bynode

    Expand creates new nodes by applying possible actions tonode

    B. Beckert: Einfhrung in die KI / KI fr IM p.18

    Search strategies

  • 8/10/2019 04 Problem Solving

    40/112

    Search strategies

    Strategy

    Defines theorderof node expansion

    Important properties of strategies

    completeness does it always find a solution if one exists?

    time complexity number of nodes generated/expanded

    space complexity maximum number of nodes in memoryoptimality does it always find a least-cost solution?

    Time and space complexity measured in terms of

    b maximum branching factor of the search tree

    d depth of a solution with minimal distance to root

    m maximum depth of the state space (may be )

    B. Beckert: Einfhrung in die KI / KI fr IM p.19

    Uninformed search strategies

  • 8/10/2019 04 Problem Solving

    41/112

    g

    Uninformed search

    Use only the information available in the problem definition

    Frequently used strategies

    Breadth-first search

    Uniform-cost search

    Depth-first search

    Depth-limited search

    Iterative deepening search

    B. Beckert: Einfhrung in die KI / KI fr IM p.20

    Breadth-first search

  • 8/10/2019 04 Problem Solving

    42/112

    Idea

    Expand shallowest unexpanded node

    Implementation

    fringeis a FIFO queue, i.e. successors go in at the end of the queue

    A

    B C

    D E F G

    B. Beckert: Einfhrung in die KI / KI fr IM p.21

    Breadth-first search

  • 8/10/2019 04 Problem Solving

    43/112

    Idea

    Expand shallowest unexpanded node

    Implementation

    fringeis a FIFO queue, i.e. successors go in at the end of the queue

    A

    B C

    D E F G

    B. Beckert: Einfhrung in die KI / KI fr IM p.21

    Breadth-first search

  • 8/10/2019 04 Problem Solving

    44/112

    Idea

    Expand shallowest unexpanded node

    Implementation

    fringeis a FIFO queue, i.e. successors go in at the end of the queue

    A

    B C

    D E F G

    B. Beckert: Einfhrung in die KI / KI fr IM p.21

  • 8/10/2019 04 Problem Solving

    45/112

  • 8/10/2019 04 Problem Solving

    46/112

    Breadth-first search: Example Romania

  • 8/10/2019 04 Problem Solving

    47/112

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.22

    Breadth-first search: Example Romania

  • 8/10/2019 04 Problem Solving

    48/112

    Arad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.22

    Breadth-first search: Example Romania

  • 8/10/2019 04 Problem Solving

    49/112

    Arad OradeaRimnicu

    VilceaFagaras Arad LugojArad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.22

    Breadth-first search: Properties

  • 8/10/2019 04 Problem Solving

    50/112

    Complete

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.23

    Breadth-first search: Properties

  • 8/10/2019 04 Problem Solving

    51/112

    Complete Yes (if bis finite)

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.23

    Breadth-first search: Properties

  • 8/10/2019 04 Problem Solving

    52/112

    Complete Yes (if bis finite)

    Time 1+ b + b2 + b3 + . . . + bd+ b(bd1) O(bd+1)

    i.e. exponential in d

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.23

    Breadth-first search: Properties

  • 8/10/2019 04 Problem Solving

    53/112

    Complete Yes (if bis finite)

    Time 1+ b + b2 + b3 + . . . + bd+ b(bd1) O(bd+1)

    i.e. exponential in d

    Space O(bd+1)

    keeps every node in memory

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.23

    Breadth-first search: Properties

  • 8/10/2019 04 Problem Solving

    54/112

    Complete Yes (if bis finite)

    Time 1+ b + b2 + b3 + . . . + bd+ b(bd1) O(bd+1)

    i.e. exponential in d

    Space O(bd+1)

    keeps every node in memory

    Optimal Yes (if cost = 1 per step), not optimal in general

    B. Beckert: Einfhrung in die KI / KI fr IM p.23

  • 8/10/2019 04 Problem Solving

    55/112

    Romania with step costs in km

  • 8/10/2019 04 Problem Solving

    56/112

    Bucharest

    Giurgiu

    Urziceni

    Hirsova

    Eforie

    Neamt

    Oradea

    Zerind

    Arad

    Timisoara

    Lugoj

    Mehadia

    Dobreta

    Craiova

    Sibiu

    Fagaras

    Pitesti

    Rimnicu Vilcea

    Vaslui

    Iasi

    Straightline distanceto Bucharest

    0

    160

    242161

    77

    151

    241

    366

    193

    178

    253

    32980

    199

    244

    380

    226

    234

    374

    98

    Giurgiu

    Urziceni

    Hirsova

    Eforie

    Neamt

    Oradea

    Zerind

    Arad

    Timisoara

    Lugoj

    Mehadia

    Dobreta

    Craiova

    Sibiu Fagaras

    Pitesti

    Vaslui

    Iasi

    Rimnicu Vilcea

    Bucharest

    71

    75

    118

    111

    70

    75

    120

    151

    140

    99

    80

    97

    101

    211

    138

    146 85

    90

    98

    142

    92

    87

    86

    B. Beckert: Einfhrung in die KI / KI fr IM p.24

    Uniform-cost search

  • 8/10/2019 04 Problem Solving

    57/112

    Idea

    Expand least-cost unexpanded node

    (costs added up over paths from root to leafs)

    Implementation

    fringeis queue ordered by increasing path cost

    Note

    Equivalent to depth-first search if all step costs are equal

    B. Beckert: Einfhrung in die KI / KI fr IM p.25

    Uniform-cost search

  • 8/10/2019 04 Problem Solving

    58/112

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.26

  • 8/10/2019 04 Problem Solving

    59/112

    Uniform-cost search

  • 8/10/2019 04 Problem Solving

    60/112

    Arad Oradea

    75 71

    Zerind Sibiu Timisoara

    75 140 118

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.26

    Uniform-cost search

  • 8/10/2019 04 Problem Solving

    61/112

    Arad Lugoj

    118 111

    Arad Oradea

    75 71

    Zerind Sibiu Timisoara

    75 140 118

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.26

    Uniform-cost search: Properties

  • 8/10/2019 04 Problem Solving

    62/112

    Complete

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.27

    Uniform-cost search: Properties

  • 8/10/2019 04 Problem Solving

    63/112

    Complete Yes (if step costs positive)

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.27

    Uniform-cost search: Properties

  • 8/10/2019 04 Problem Solving

    64/112

    Complete Yes (if step costs positive)

    Time # of nodes with past-cost less than that of optimal solution

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.27

    Uniform-cost search: Properties

  • 8/10/2019 04 Problem Solving

    65/112

    Complete Yes (if step costs positive)

    Time # of nodes with past-cost less than that of optimal solution

    Space # of nodes with past-cost less than that of optimal solution

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.27

    Uniform-cost search: Properties

  • 8/10/2019 04 Problem Solving

    66/112

    Complete Yes (if step costs positive)

    Time # of nodes with past-cost less than that of optimal solution

    Space # of nodes with past-cost less than that of optimal solution

    Optimal Yes

    B. Beckert: Einfhrung in die KI / KI fr IM p.27

    Depth-first search

  • 8/10/2019 04 Problem Solving

    67/112

    Idea

    Expand deepest unexpanded node

    Implementation

    fringeis a LIFO queue (a stack), i.e. successors go in at front of queue

    Note

    Depth-first search can perform infinite cyclic excursions

    Need a finite, non-cyclic search space (or repeated-state checking)

    B. Beckert: Einfhrung in die KI / KI fr IM p.28

    Depth-first search

  • 8/10/2019 04 Problem Solving

    68/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    69/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    70/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    71/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    72/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    73/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    74/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

  • 8/10/2019 04 Problem Solving

    75/112

    Depth-first search

  • 8/10/2019 04 Problem Solving

    76/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    77/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

    Depth-first search

  • 8/10/2019 04 Problem Solving

    78/112

    A

    B C

    D E F G

    H I J K L M N O

    B. Beckert: Einfhrung in die KI / KI fr IM p.29

  • 8/10/2019 04 Problem Solving

    79/112

  • 8/10/2019 04 Problem Solving

    80/112

    Depth-first search: Example Romania

  • 8/10/2019 04 Problem Solving

    81/112

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.30

    Depth-first search: Example Romania

  • 8/10/2019 04 Problem Solving

    82/112

    Arad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.30

    Depth-first search: Example Romania

  • 8/10/2019 04 Problem Solving

    83/112

    Zerind Sibiu Timisoara

    Arad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.30

  • 8/10/2019 04 Problem Solving

    84/112

    Depth-first search: Properties

  • 8/10/2019 04 Problem Solving

    85/112

    Complete Yes: if state space finite

    No: if state contains infinite paths or loops

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.31

    Depth-first search: Properties

  • 8/10/2019 04 Problem Solving

    86/112

    Complete Yes: if state space finite

    No: if state contains infinite paths or loops

    Time O(

    bm

    )

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.31

    Depth-first search: Properties

  • 8/10/2019 04 Problem Solving

    87/112

    Complete Yes: if state space finite

    No: if state contains infinite paths or loops

    Time O(

    bm

    )

    Space O(bm) (i.e. linear space)

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.31

    Depth-first search: Properties

    C

  • 8/10/2019 04 Problem Solving

    88/112

    Complete Yes: if state space finite

    No: if state contains infinite paths or loops

    Time O(bm)

    Space O(bm) (i.e. linear space)

    Optimal No

    B. Beckert: Einfhrung in die KI / KI fr IM p.31

    Depth-first search: Properties

    C l t Y if t t fi it

  • 8/10/2019 04 Problem Solving

    89/112

    Complete Yes: if state space finite

    No: if state contains infinite paths or loops

    Time O(bm)

    Space O(bm) (i.e. linear space)

    Optimal No

    Disadvantage

    Time terrible if mmuch larger than d

    Advantage

    Time may be much less than breadth-first search if solutions are dense

    B. Beckert: Einfhrung in die KI / KI fr IM p.31

    Iterative deepening search

  • 8/10/2019 04 Problem Solving

    90/112

    Depth-limited search

    Depth-first search with depth limit

    B. Beckert: Einfhrung in die KI / KI fr IM p.32

    Iterative deepening search

  • 8/10/2019 04 Problem Solving

    91/112

    Depth-limited search

    Depth-first search with depth limit

    Iterative deepening search

    Depth-limit search with ever increasing limits

    functionITERATIVE-DEEPENING-SEARCH( problem)returnsa solution or failure

    inputs: problem /* a problem */

    fordepth 0to do

    resultDEPTH-LIMITED-SEARCH( problem,depth)

    ifresult=cutoffthen returnresult

    end

    B. Beckert: Einfhrung in die KI / KI fr IM p.32

    Iterative deepening search with depth limit 0

  • 8/10/2019 04 Problem Solving

    92/112

    Limit = 0 A A

    B. Beckert: Einfhrung in die KI / KI fr IM p.33

    Iterative deepening search with depth limit 1

  • 8/10/2019 04 Problem Solving

    93/112

    Limit = 1 A

    B C

    A

    B C

    A

    B C

    A

    B C

    B. Beckert: Einfhrung in die KI / KI fr IM p.34

  • 8/10/2019 04 Problem Solving

    94/112

  • 8/10/2019 04 Problem Solving

    95/112

  • 8/10/2019 04 Problem Solving

    96/112

    Iterative deepening search: Example Romania with l = 1

  • 8/10/2019 04 Problem Solving

    97/112

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.38

  • 8/10/2019 04 Problem Solving

    98/112

    Iterative deepening search: Example Romania with l = 2

  • 8/10/2019 04 Problem Solving

    99/112

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.39

    Iterative deepening search: Example Romania with l = 2

  • 8/10/2019 04 Problem Solving

    100/112

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.39

    Iterative deepening search: Example Romania with l = 2

  • 8/10/2019 04 Problem Solving

    101/112

    Arad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.39

    Iterative deepening search: Example Romania with l = 2

  • 8/10/2019 04 Problem Solving

    102/112

    Arad Oradea RimnicuVilcea

    FagarasArad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.39

    Iterative deepening search: Example Romania with l = 2

  • 8/10/2019 04 Problem Solving

    103/112

    Arad LugojArad Oradea RimnicuVilceaFagarasArad Oradea

    Zerind Sibiu Timisoara

    Arad

    B. Beckert: Einfhrung in die KI / KI fr IM p.39

    Iterative deepening search: Properties

    Complete

  • 8/10/2019 04 Problem Solving

    104/112

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.40

    Iterative deepening search: Properties

    Complete Yes

  • 8/10/2019 04 Problem Solving

    105/112

    Time

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.40

    Iterative deepening search: Properties

    Complete Yes

  • 8/10/2019 04 Problem Solving

    106/112

    Time (d+1)b0 + db1 + (d1)b2 + . . . + bd O(bd+1)

    Space

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.40

    Iterative deepening search: Properties

    Complete Yes

  • 8/10/2019 04 Problem Solving

    107/112

    Time (d+1)b0 + db1 + (d1)b2 + . . . + bd O(bd+1)

    Space O(bd)

    Optimal

    B. Beckert: Einfhrung in die KI / KI fr IM p.40

    Iterative deepening search: Properties

    Complete Yes

  • 8/10/2019 04 Problem Solving

    108/112

    Time (d+1)b0 + db1 + (d1)b2 + . . . + bd O(bd+1)

    Space O(bd)

    Optimal Yes (if step cost = 1)

    B. Beckert: Einfhrung in die KI / KI fr IM p.40

    Iterative deepening search: Properties

    Complete Yes

  • 8/10/2019 04 Problem Solving

    109/112

    Time (d+1)b0 + db1 + (d1)b2 + . . . + bd O(bd+1)

    Space O(bd)

    Optimal Yes (if step cost = 1)

    (Depth-First) Iterative-Deepening Search often used in practice for

    search spaces of large, infinite, or unknown depth.

    B. Beckert: Einfhrung in die KI / KI fr IM p.40

    Comparison

    C it iBreadth-

    fi tUniform-

    t

    Depth-

    fi tIterative

    d i

  • 8/10/2019 04 Problem Solving

    110/112

    Criterion first cost first deepening

    Complete? Yes Yes No Yes

    Time bd+1 bd bm bd

    Space bd+1 bd bm bd

    Optimal? Yes Yes No Yes

    B. Beckert: Einfhrung in die KI / KI fr IM p.41

    Comparison

    Breadth-first search Iterative deepening search

  • 8/10/2019 04 Problem Solving

    111/112

    B. Beckert: Einfhrung in die KI / KI fr IM p.42

    Summary

    Problem formulation usually requires abstracting away real-world details

    t d fi t t th t f ibl b l d

  • 8/10/2019 04 Problem Solving

    112/112

    to define a state space that can feasibly be explored

    Variety of uninformed search strategies

    Iterative deepening search uses only linear space

    and not much more time than other uninformed algorithms

    B. Beckert: Einfhrung in die KI / KI fr IM p.43