PowerPoint CS570 Artificial Intelligence Solving Problems By Searching and by pengtt

VIEWS: 71 PAGES: 52

									CS570 Artificial Intelligence




Solving Problems By Searching and
 Constraint Satisfaction Problem


                            2001. 4. 18.


                          20015087 김한성
                          20013460 이은영
Overview

    Solving Problem by Searching
         Problem solving agents
         Problem types
         Problem formulation
         Example problems
         Searching Strategies(Basic search algorithms)
    Constraint Satisfaction Problem
         Introduction
         Solving Techniques
         Applications




April 18, 2001                                           Page 1
Problem-Solving Agents

    Problem-Solving Agents
         one kind of goal-based agent
         finding sequences of actions that lead to desirable
         states.
    Steps
         Goal Formulation
                 limiting the objectives
         Problem Formulation
                 deciding what actions and states to consider
         Search
                 looking for the possible action sequence
         Execution

April 18, 2001                                                  Page 2
Formulating Problem - Example

    The eight possible states of the simplified vacuum
    world
             1                  2



             3                  4



             5                  6



             7                  8



April 18, 2001                                      Page 3
Properties of environment


    Accessible vs. Inaccessible
    Deterministic vs. Nonderterministic
    Episodic vs. Nonepisodic
    Static vs. Dynamic
    Discrete vs. Continuaous




April 18, 2001                            Page 4
Knowledge and Problem Types (1)

      Single-state problem
      1.   accessible - the agent’s sensor knows
                 which state it is in.
      2.   deterministic - the agent knows
                 what each of its actions does
           Action sequence can be completely planned.
                 example: [Right, Suck]




  5                            6                  8




April 18, 2001                                          Page 5
Knowledge and Problem Types (2)

    Multiple-state problem
     1.   inaccessible
                 limited access to the world state
     2.   deterministic
          The agent must reason about sets of states that it
          mignt get to.
                 Example
           [Right, Suck, Left, Suck]          reach a Goal




April 18, 2001                                                 Page 6
Knowledge and Problem Types (3)

    Contingency problem
     1.   inaccessible
     2.   non-deterministic
          sensing during the execution phase.
          most of the real, physical world problems
                 Keep your eyes open while walking!
          The agent must calculate a whole tree of actions,
          rather than a single action sequence.



             1                          3




April 18, 2001                                                Page 7
Knowledge and Problem Types (4)

    Exploration problem
         unknown state space (no map, no sensor)
         The agent must experiment, gradually discovering
         what its actions do and what sorts of states exist.




April 18, 2001                                                 Page 8
single-state problem



       Well-defined Problems and Solutions

           Problem
                 a collection of information that the agent will use to
                 decide what to do
           the basic elements of a problem definition
                 initial state
                 operator (or successor function S)
                 goal test
                 path cost function(g)
                                                                   path
                                               state space




       April 18, 2001                                                Page 9
Problem-Solving Agents - Example

    A simplified road map of Romania
                 Oradea
                                                               Neamt

                                                                          Iasi
         Zerind



     Arad                 Sibiu                                                  Vaslui

                                            Fagaras


                                                                                   Hirsova
    Timisoara                     Rimnicu Vilcea
                                                                     Urziceni

                                                Pitesti
                 Lugoj
                                                              Bucharest
                 Mehadia
                                                                                          Eforie
                 Dobreta                                  Giurgiu
                                      Craiova

April 18, 2001                                                                       Page 10
Problem-Solving Agents – Example

    Situation
         On holiday in Romania: currently in Arad.
         Flight leaves tomorrow from Bucharest.
    Formulate goal:
         be in Bucharest             Abstraction

    Formulate problem:
         initial state: be in Arad
         state: various cities
         operators: driving between cities
    Find solution:
         sequence of cities, e.g., Arad, Sibiu, Fagaras,
         Bucharest

April 18, 2001                                             Page 11
Measuring Problem-Solving Performance

     Effectiveness of a search
          Does it find a solution at all?
          Is it a good solution (one with low path cost)?
          What is the search cost associated with the time and
          memory required to find a solution?
                  total cost = path cost + search cost




 April 18, 2001                                             Page 12
Example Problems

    Toy Problems
         concise and exact description
         abstract version of real problem


    Real-World Problem
         no single agreed-upon description




April 18, 2001                               Page 13
The 8-puzzle

    problem formulation
         State : the location of each of the eight tiles in one of
         the nine squares
         Operators: blank moves left, right, up, or down
         Goal test: state matches the right figure
         Path cost: each step costs 1, that is the length of the
         path

                 5    4                    1      2         3

                 6    1        8           8                4

                 7    3        2           7      6         5

                 Start state                   Goal state

April 18, 2001                                                  Page 14
The 8-queens problem(1)

    problem formulation
         Goal test: 8 queens on board, none attacked
         Path cost: zero


         States : any arrangement of 0 to 8 queens on board
         Operators : add a queen to any square


         States :arrangements of 0 to 8 queens with none
         attacked
         Operators :place a queen in the left-most empty
         column such that is not attacked by any other queen



April 18, 2001                                             Page 15
The 8-queens problem(2)




         States : arrangements of 8queens, one in each column
         Operators :move any attacked queen to another
         square in the same column




April 18, 2001                                           Page 16
Cryptarithmetic

    problem formulation
         State : a cryptarithmetic puzzle with some letters
         replaced by digits
         Operators: replace all occurrences of a letter with a
         digit not already appearing in the puzzle
         Goal test: puzzle contains only digits, and represents a
         correct sum
         Path cost: zero

                   FORTY        Solution: 29786       F=2, O=9, R=7, etc.
                 + TEN                       850
                 + TEN                       850
                 ------------             ---------
                    SIXTY                 31486


April 18, 2001                                                              Page 17
    The vaccum world

        problem formulation ( a single state problem)
             State : one of the eight states shown in Figure
             Operators: move left, move right, suck
             Goal test: no dirt left in any square
             Path cost: each action costs 1                      R
                     L
                                             R
                                             L
                                                                                   R
                         S               R       L               S
L
                             R                               R

                             L                               L

            S                        S               S               R    S
                     L
                                             R

                                             L

    April 18, 2001               S                       S               Page 18
Missionaries and cannibals

    problem formulation
         State : the number of missionaries, cannibals and
         boats on the bank of the river from which they
         started(3,3,1)
         Operators: either 1 missionary, 1 cannibal, 2
         missionaries, 2 cannibals, or one of each across in the
         boat.
         Goal test: 3 missionaries and 3 cannibals in the other
         side of the river (0,0,0)
         Path cost: the number of crossings




April 18, 2001                                               Page 19
Example Real-World Problems

    Route finding
    Touring and travelling salesperson problems
    VLSI layout
    Robot navigation
    Assembly sequencing




April 18, 2001                                    Page 20
Searching for Solutions

    Partial search tree for route finding from Arad to
    Bucharest.
                                                                      goal test
                                                         Arad
  (a) The initial state (search node)

                                                         Arad
                                                                 generating a new
  (b) After expanding Arad                                       state
                                        Sibiu        Timisoara       Zerind


                         choosing                        Arad
                         one
                         option
  (c) After expanding Sibiu             Sibiu        Timisoara       Zerind


                                                           Rimnicu
                       Sibiu   Timisoara        Oradea
                                                            Vilcea

April 18, 2001                                                                Page 21
Search Strategies

    Criteria
         Completeness
         Time complexity
         Space complexity
         Optimality
    Classification
         Uninformed search (= blind search)
                 have no information about the number of steps or
                 the path cost from the current state to the goal
         Informed search (= heuristic search)
                 have some information
                 example: Bucharest is southeast of Arad.

April 18, 2001                                               Page 22
                                                     Searching Strategies

Breadth-first Search




    Properties
         Complete: Yes (if b is finite)
         Time complexity: 1+b+b^2+…+b^d = O(b^d)
         Space complexity: O(b^d) (keeps every node in
         memory)
         Optimal: Yes (if cost=1 per step); not optimal in
         general
                 where b is branching factor and
                 d is the depth of the search tree

April 18, 2001                                                   Page 23
                                                                                   Searching Strategies

Uniform cost Search (1)

    Expand least-cost unexpanded node
         the breadth-first search is just uniform cost search
         with g(n)=DEPTH(n)

                                S
                                    0
                                                S

                   A                    A       B       C
                                            1       5       15
           1               10
                   B                                                  S
    S          5       5        G
                                                            A         B       C                 S
          15               5                                              5       15
                   C                                        G
                                                                 11                    A        B      C
                                                                                                           15
                                                                                       G        G
                                                                                           11    10

April 18, 2001                                                                                        Page 24
                         Searching Strategies

Depth-first Search (1)

    Depth-first Search




April 18, 2001                       Page 25
                                                      Searching Strategies

Depth-first Search (2)

    Properties
         Space complexity: O(bm)
                 i.e., linear space
         Time complexity: O(b^m)
                 where m is the maximum depth
         Complete, Optimal : No
                 fails in infinite-depth spaces, spaces with loops
                 Modify to avoid repeated states along path
                 → complete in finite spaces




April 18, 2001                                                    Page 26
                                              Searching Strategies

Depth-limited Search

    Depth-first search with depth limit l
    Properties
         Complete: Yes
         Time complexity: O(b^l)
                 where l is the depth limit
         Space complexity: O(bl)
         Optimal: No




April 18, 2001                                            Page 27
                                           Searching Strategies

Iterative Deepening Search (1)

    Choose the best depth limit by trying all possible
    depth limit




April 18, 2001                                         Page 28
                            Searching Strategies

Iterative Deepening Search (1)

    Limit=0
    Limit=1


    Limit=2




    Limit=3


                                   …



April 18, 2001                          Page 29
                                                Searching Strategies

Iterative Deepening Search (2)

    Choose the best depth limit by trying all possible depth
    limit
    Breadth-first search + Depth-first search
    Properties
         Optimal , Complete: Yes
         Time complexity:
     (d+1)*b^0+d*b+(d-1)*b^2+…+1*b^d = O(b^d)
         Space complexity: O(bd)




April 18, 2001                                              Page 30
                                                 Searching Strategies

Bidirectional Search (1)

    Simultaneously search
         forward from the initial state
         backward from the goal
         stop when the two searches meet in the middle.




                     Start                Goal




April 18, 2001                                               Page 31
                                                    Searching Strategies

Bidirectional Search (2)

    Several issues
         Operators are reversible.
         Many goal states  multiple state search


    Properties
         Complete: Yes
         Time complexity: O(2b^(d/2)) = O(b^(d/2))
         Space complexity: O(b^(d/2))
         Optimal: Yes, if step cost = 1
                 Can be modified to explore uniform-cost tree




April 18, 2001                                                  Page 32
                                                                    Searching Strategies

  Comparison Search Strategies

      Evaluation of search strategies.
            b is the branching factor;
            d is the depth of solution;
            m is the maximum depth of the search tree;
            l is the depth limit.

               Breadth-   Uniform-                   Depth-          Iterative Bidirectional
Criterion                            Depth-First
                 First      Cost                     Limited        Deepening (if applicable)

  Time             b^d      b^d         b^m             b^l            b^d       b^(d/2)

 Space             b^d      b^d         bm               bl             bd       b^(d/2)

Optimal?           Yes      Yes          No             No             Yes          Yes

Complete?          Yes      Yes          No        Yes, if l   ≥d      Yes          Yes


  April 18, 2001                                                                 Page 33
Avoiding Repeated States

    Three ways to deal with repeated states
         Do not return to the state you just came from.
         Do not create paths with cycles in them.
         Do not generate any state that was ever generated
         before.




April 18, 2001                                            Page 34
Overview – CSP

    Constraint Satisfaction Problem
    The Solution of CSP
    Solving Techniques
         Consistency techniques
         Search
         Example
    Applications




April 18, 2001                        Page 35
Constraint Satisfaction Problem(1)

    CSP : A special kind of problem that satisfies some
    additional structural properties beyond the basic
    requirements for problems in general
    CSP is defined as
         a set of variables X = { x1 , x2 , x3 … xn }
         for each variable, xi , a finite domain Di
                 Discrete or continuous
         a set of constraints restricting the values that the
         variables can simultaneously take
                 Unary Constraints
                 Binary Constraints
                 High order Constraints
                 Absolute constraints vs. preference constraints

April 18, 2001                                                  Page 36
Constraint Satisfaction Problem(2)

    Example : 8 queens problem
         Variables : the locations of each of the eight queens
         Domains : squares on the board
         Constraints : no two queens can be in the same row,
         column, or diagonal
                 V1: the row that the           Q
                  first queen occupies              Q
                 V2: the row that the               Q
                  first queen occupies
                 Domain : {1,2,3,…,8}
                 Constraints :
                 {(1,3),(1,4),…(2,4),(2,5),…}

April 18, 2001                                             Page 37
The Solution of CSP


    If use DFS in 8 queens problem : Search space will
    be 88
         Too huge!
    In CSP, the goal test is decomposed into a set of
    constraints on variables rather than being a “black
    box”.
    Solutions : specifying values for all the variables
    such that the constraints are satisfied




April 18, 2001                                        Page 38
Solving Technology

    Consistency Techniques
    Systematic Search
         Generate-and-Test (GT)
                 Generate each possible combination of the
                 variables and then test to see if it satisfies all the
                 constraints.
                 The first combination that satisfies all the
                 constraints is the solution.
                 The number of combinations : the size of the
                 Cartesian product of all the variable domains
         Generator merged with tester
                 Look back schema
                 Look ahead schema


April 18, 2001                                                      Page 39
Consistency Techniques

    Removing inconsistent values from variable domain
    Graph representation - constraint graph
    Consistency Techniques are not complete


                        Consistent pairs
                           of values

           removed by
              AC        a              a
                        b              b
                        c              c
                        Vi            Vj
April 18, 2001                                   Page 40
Systematic Search (1)

    Generator merged with tester
         Look back schema
                 Backtracking, Backjumping, Backmarking,
                 Backchecking
         Look ahead schema
                 Forward checking (FC) , Look Ahead (LA)




April 18, 2001                                             Page 41
                                           Look Back Schema

Backtracking

    Incrementally extending a partial solution(DFS)
    When conflict occurs, choose another value for
    inconsistent variable
    Drawbacks
         Thrashing
         Redundant work
         Late detection of collision
         Exponential time complexity




April 18, 2001                                       Page 42
Example - Backtracking

    There is no legal position available on the next row on
    the board below
    As a result the queen on the
    fifth row will be removed and
    a new position for it will be sought. Q
    If all legal positions on the row             Q
    lead fail to a solution, the queen                    Q
                                              Q
    on the row above will be moved                    Q
    to a new legal position, and
    the search for a solution
    will proceed.


April 18, 2001                                                Page 43
                                              Look Back Schema

Backjumping

    Avoid trashing
    most recent conflicting variable instead of
    immediate past variable


             Q                    Q
                     Q                    Q
                             Q                Q
                 Q                    Q
                         Q              Q
                                  1 3 2 4 3 1 2 3




April 18, 2001                                         Page 44
                                                 Look Back Schema

Backchecking, Backmarking

    Avoid redundant work



            Q                    Q
                         Q                   Q
                 Q                   Q
                             Q                   Q
                     Q                   X




April 18, 2001                                            Page 45
Look Ahead Schema

    Prevent future conflict
    Examples of Look Ahead Schema
         Forward Checking
                 When an assignment, X/a occurs, temporally
                 delete all values from other variable domain
         Look Ahead




April 18, 2001                                                  Page 46
Example – Forward Checking




         Q                 Q
         X XQ              X   XQ
         X X X X Q         X   X X X Q
         X   X X X X       X   X X X X   X
         X   X   X X X     X     X X X   X X
         X X X   X X X X   X   X X Q X   X X X
         X   X   X   X X   X     X X X     X X
         X   X   X     X   X   X X X X   X   X




April 18, 2001                                   Page 47
  AC Look Ahead

      When a queen is placed on the board all squares that are
      threatened by that queen are marked to be ignored
      When considering where to place the next queen it uses
      Arc Consistency to ensure that there are legitimate
      positions for each pair of queens to be added, and marks
      any positions that fail the test to be ignored.

Q                                         Arc (Vi, Vj ) is arc
                      Q
                                          consistent if for every
X XQ                  X X   Q
                                          value x in the current
X X X X               X   X X X           domain of Vi there is some
X   X X X             X X   X   X         value y in the domain of Vj
X   X   X X           X     X X   X       such that Vi =x and Vj =y is
X   X     X X         X     X   X   X     permitted by the binary
X   X       X X       X     X     X       constraint between Vi and
X   X         X       X     X       X     Vj

  April 18, 2001                                             Page 48
   already instantiated variables   not yet instantiated variables
                                                                 partial look ahead
                                                                   full look ahead




   checked by
  backtracking
                 forward
                 checking


April 18, 2001                                                           Page 49
Systematic Search (2)

    Smart generator
         Heuristic Method
                 Hill-climbing
                 Min-conflict (MC)
                 Random walk
                 Tabu search




April 18, 2001                       Page 50
Application

    Traditional Operational Research (OR)
         Planning
         Scheduling
         Optimization
         NP-Hard




April 18, 2001                              Page 51

								
To top