Production Systems and Searching - PowerPoint PPT Presentation

1 / 51
About This Presentation
Title:

Production Systems and Searching

Description:

Water Jug Problem: A State Space Search ... There is a pump to fill the jugs with water. How can you get exactly 2 gallons of water into the 4-gallon jug? ... – PowerPoint PPT presentation

Number of Views:95
Avg rating:3.0/5.0
Slides: 52
Provided by: srgCs
Category:

less

Transcript and Presenter's Notes

Title: Production Systems and Searching


1
Production Systems and Searching
2
Solving Problems by Searching
  • To build a system to solve a particular problem
  • 1. Define the problem precisely.
  • 2. Analyze the problem.
  • 3. Isolate and represent the task knowledge
    needed to solve the problem.
  • Choose the best problem-solving technique and
    apply it to the problem.

3
Solving Problems by Searching
  • Why is search necessary?
  • No model of the world is complete, consistent,
    and computable. Any intelligent systems must
    encounter surprises.
  • Solutions cannot be entirely precomputed Many
    problems must be solved dynamically, starting
    from observed data.
  • Search provides flexibility to deal with a highly
    variable environment.
  • Search can handle local ambiguity in
    interpretation of perceptual data. Global
    constraints can provide unambiguous total
    interpretation.

4
Define the Problem As a State Space Search
  • Playing chess
  • Write a set of rules for each possible move
    (10120 possible moves).
  • Or.
  • Write a set of general rules for possible types
    of moves, I.E. Define the problem as moving
    around in a state space where each state
    corresponds to a legal position on the board.
    Start at initial state, then use a set of rules
    to move from one state to another, to try to end
    up at one of a set of final states.

5
Define the Problem As a State Space Search
  • State space representation corresponds to the
    structure of the problem
  • A. It allows for a formal definition of a
    problem as the need to convert a given situation
    into a desired situation using a set of
    permissible operators.
  • B. It permits definition of the process of
    solving the problem as combination of known
    techniques (each represented as a rule defining a
    single step in the space) and search, the general
    technique of exploring the space to try to find
    some path from the current state to a goal state.

6
Water Jug Problem A State Space Search
  • Water jug problem you are given two jugs with
    no measuring marks, a 4-gallon one and a 3-gallon
    one. There is a pump to fill the jugs with water.
    How can you get exactly 2 gallons of water into
    the 4-gallon jug?
  • State space set of ordered pairs of integers
    (x, y) such at x 0,1,2,3, or 4 for amount of
    water in 4-gallon jug, and y 0, 1, 2, or 3 for
    amount of water in the 3-gallon jug. The start
    state is (0,0). The goal state is (2,n) for any
    value of n. The operators are shown in list,
    represented as rules whose left sides are matched
    against the current state and whose right rules
    describe the new state that results from applying
    the rule. Explicit assumptions required we
    can fill a jug from the pump, we can pour water
    out of a jug onto the ground, we can pour water
    from one jug to the other, and there are no other
    measuring devices available.

7
Water Jug Problem A State Space Search
  • Control structure needed that loops through a
    cycle in which a rule whose left side matches the
    current state is chosen, an appropriate change is
    made to the state as described in the right side
    of the rule, and the resulting state is checked
    to see if it corresponds to a goal state.

8
Formal Description of a Problem
  • Define a state space that contains all the
    possible configurations of the relevant objects.
    Doesnt have to enumerate all states.
  • Specify one or more states within that space that
    describe possible states from which the the
    problem-solving can start. These states are
    called the initial states.
  • Specify one or more states that will be
    acceptable as solutions to the problem. These are
    called goal states.

9
Formal Description of a Problem (Contd)
  • 4. Specify a set of rules that describe the
    actions (operators) available.
  • What unstated assumptions are present in the
    informal problem description?
  • How general should the rules be?
  • How much of the work required to solve the
    problem should be precomputed and represented in
    the rules?
  • What is the goal test?
  • What is the path cost for each action?

10
Formal Description of a Problem (Contd)
  • Measure the performance.
  • Does it find a solution?
  • Is it a good solution with a low path cost?
  • What is the search cost wrt time and memory
    needs?
  • Total cost of a search is the sum of the path
    cost and the search cost.

11
State-space Representationand Production Systems
  • Select some way to represent states in the
    problem in an unambiguous way.
  • Formulate all actions that can be preformed in
    states
  • Including their preconditions and effects.
  • Production rules.
  • Represent the initial state (s).
  • Formulate precisely when a state satisfies the
    goal of our problem.
  • Activate the production rules on the initial
    state and its descendants, until a goal state is
    reached.

12
  • AI uses state space search to find solutions to
    problems
  • State space search uses state space graphs to
    represent problems
  • This representation may be used instead of or in
    addition to representation in predicate calculus
  • Graph theory allows us to analyze the structure
    and complexity of problems and search strategies

13
  • A graph is a set of nodes and a set of arcs that
    connect pairs of nodes
  • In state space search, a node in a graph
    represents a state of the world or a state in the
    solution of a problem
  • An arc represents a transition between states
  • A chess move (arc) changes the game board from
    one state to another
  • A robot arm moving a block (arc) changes the
    blocks world from one state to another
  • A rule (arc) like if its raining, take an
    umbrella, changes the state of the known world

14
BLIND Search Methods
  • Depth-first
  • Breadth-first
  • Non-deterministic search
  • Iterative deepening
  • Bi-directional search

15
Depth-first Search
  • Let L be a list of start states (the frontier) -
    initialised to root state
  • While L is not empty do
  • Let N be the first state in L
  • If N is a goal state then return success
  • Else remove N from front of L
  • Add all states reachable from N to the front
    of L
  • Return failure

16
Speed (Depth-first)
  • In the worst case
  • The (only) goal node may be on the right-most
    branch,

d
b
G
17
Memory (Depth-first)
  • Largest number of nodes in QUEUE is reached in
    bottom left-most node.
  • Example d 3, b 3

18
Breadth-first Algorithm
  • 1. QUEUE
  • 2. WHILE QUEUE is not empty
  • AND goal is not
    reached
  • DO remove the first path from the QUEUE
  • Create new paths (to all children)
  • Reject the new paths with loops
  • Add the new paths to back of QUEUE
  • 3. IF goal reached
  • THEN success
  • ELSE failure

19
Completeness (Breadth-first)
  • Would even remain complete without our
    loop-checking.
  • Note ALWAYS finds the shortest path.

20
Speed (Breadth-first)
  • If a goal node is found on depth m of the tree,
    all nodes up till that depth are created.

Thus O(bm) note depth-first would also visit
deeper nodes.
21
Memory (Breadth-first)
  • Largest number of nodes in QUEUE is reached on
    the level m of the goal node.

22
Assessing Search Performance
  • Both strategies are blind.
  • The list L contains all states generated but not
    yet expanded. On average, how long will L be?
  • If the length of L exceeds the available memory,
    the search fails, even though the goal is
    reachable.
  • Each "move" takes a finite amount of time to
    generate. On average, how many states will we
    expand?
  • For effective performance, we must be able to
    return an answer in good time.

23
Depth- and Breadth-first Comparison
  • Breadth-first and depth-first take, on average,
    approximately the same time
  • Depth-first requires considerably less space for
    large trees
  • Depth-first is even better if the first node is
    bottom left of the tree

24
Depth- and Breadth-first Comparison
  • Breadth-first is better if there is a node top
    right
  • Breadth-first will always find solution with
    smallest number of moves

25
Traveling Salesman Problem
  • List of cities to visit
  • Must visit all cities exactly once
  • The route to follow for the shortest possible
    round trip

26
Heuristic Search
  • A heuristic is a technique that improves the
    efficiency of a search process, possibly by
    sacrificing claims of completeness
  • Example Nearest Neighbor heuristic

27
Problem Characteristics
  • Is problem Decomposable into a set of nearly
    independent smaller or easier sub problems?
  • Can solution steps be ignored?
  • Universe predictable?
  • Is good solution obvious?
  • State or path?
  • Role of Knowledge
  • Interaction between user and computer

28
Production System Characteristics
  • A monotonic production system is a production
    system in which the application of a rule never
    prevents the later application of a rule that
    could also have been applied at the time the
    first rule was selected
  • A partially Commutative system has the property
    that if the application of a particular sequence
    of rules transforms state x into state y then any
    permutation of those rules also does so

29
Informed Search
  • Improving search by counting the cost of each
    move (i.E. The cost from the start)
  • Hill-climbing
  • Best-first

30
Informed Search
  • Improving search by estimating the cost of
    getting to the goal
  • Greedy search methods
  • A - an optimal search strategy

31
Hill Climbing Search
  • Similar to depth-first, but now ordering the
    children of the current node by their cost from
    start - nearest first.
  • Let L be a list of start states (the frontier) -
    initialised to root state.
  • While L is not empty do.
  • Let N be the first state in L.
  • If N is a goal state then return success.
  • Else remove N from front of L.
  • Obtain C, all states reachable from N.
  • Order C by cost from start to get
    C1.
  • Add C1 to the front of L.
  • Return failure.

32
Best-first Search
  • Similar to hill-climbing, but now inserting the
    children into the list in order of cost.
  • Let L be a list of start states (the frontier) -
    initialised to root state.
  • While L is not empty do.
  • Let N be the first state in L.
  • If N is a goal state then return success.
  • Else remove N from front of L.
  • Obtain C, all states reachable from N.
  • Insert C into L in order of cost
    from the start.
  • Return failure.

33
Estimating the Remaining Cost
  • Hill-climbing and best-first search still have
    problems
  • Hill-climbing is still just depth-first search,
    and often gets lost searching branches which will
    never lead to the goal.
  • Best-first is a combination of depth-first and
    breadth-first, but still prefers states which are
    closest to the start state, without concern for
    how close they are to the goal.

34
Estimating the Remaining Cost
  • What we need to do is incorporate an estimate of
    how expensive it will be to get to the goal from
    a new state, and use that to decide on the order
    in which we expand states.

35
Estimating the Remaining Cost
  • This estimate is called a heuristic.
  • A large part of the art of applying search
    methods to problems is devising appropriate
    heuristics.

36
Greedy Hill-climbing Search
  • Similar to hill-climbing, but now ordering the
    children by their estimated cost of getting to
    the goal.
  • Let L be a list of start states (the frontier) -
    initialised to root state.
  • While L is not empty do.
  • Let N be the first state in L.
  • If N is a goal state then return success.
  • Else remove N from front of L.
  • Obtain C, all states reachable from N.
  • Order C by estimated cost of
    getting to the goal to get C1.
  • Add C1 to the front of L.
  • Return failure.

37
Greedy Best-first Search
  • Similar to best-first, but now ordering all
    states by the estimated cost of getting to the
    goal.
  • Let L be a list of start states (the frontier) -
    initialised to root state.
  • While L is not empty do.
  • Let N be the first state in L.
  • If N is a goal state then return success.
  • Else remove N from front of L.
  • Obtain C, all states reachable from N.
  • Insert C into L in order of
    estimated distance from the goal.
  • Return failure.

38
Combining the Informed Methods
  • Greedy search methods can be misled by the
    heuristic.
  • The main problem is that they forget the work
    they have done to get to the current state, and
    are only able to look ahead.
  • What we need to do is combine the two methods.

39
Combining the Informed Methods
  • Let g(n) be the true cost of getting from the
    start to the state N.
  • Let h(n) be the true cheapest cost of getting to
    the goal from the state N.

40
Combining the Informed Methods
  • Let h'(n) be the estimated cost of getting to the
    goal from the state N.
  • Then f(n) g(n) h'(n) is our estimate of the
    cheapest path from the start to the goal which
    visits N.

41
A Search
  • Similar to best-first, but now ordering all nodes
    by the estimated total cost of getting from start
    to goal.
  • Let L be a list of start states - initialised to
    root state.
  • While L is not empty do.
  • Let N be the first state in L.
  • If N is a goal state the return success.
  • Else remove N from front of L.
  • Obtain C, all states reachable from N.
  • Obtain total estimate for all
    states in C by adding cost from start to
    estimated cost to goal.
  • Insert C into L in order of
    estimated total cost.
  • Return failure.

42
A Finds the Cheapest Path
  • Theorem.
  • If h'(n) ? h(n) for all N, then A will always
    return the lowest cost path to the goal, i.E if
    the distance measure is an underestimate.
  • Proof
  • Let G be the lowest cost goal state.
  • Let G' be a higher cost goal state .
  • For all goal states, h(g) 0.
  • Lower cost means g(g) ? g(g'), so f(g) ? f(g').
  • Suppose A has G' at the front of its list L -
    i.E. G' is the state we will take next (and
    therefore choose a higher cost state).
  • Suppose G itself is in L.
  • If this were so, then G would be in front of G
    (since f(g)
  • So G cant be on L.

43
A Finds the Cheapest Path
Start
L (frontier)
N
G
G
44
A Finds the Cheapest Path
  • Proof (ctd.)
  • Let N be any state on the path to G.
  • For any states N and N.'
  • G(n) h(n) g(n') h(n') g(g) h(g).
  • F(n) g(n) h'(n) ? g(n) h(n)
    g(g) h(g) f(g).
  • H'(n) ? h(n).
  • H(g) 0.
  • So f(n) ? f(g).
  • But if G' is at the front of the list, then f(g')
    ? f(n).
  • Therefore f(g') ? f(g) - contradiction.
  • Therefore, A can never have G' at the front of
    its list.
  • Therefore, A can never return a higher cost
    goal.

45
The Benefits of A
  • A is complete
  • If every state has a finite number of successors
    and there is no path of infinite length but
    finite cost, then A will return a solution.
  • A is optimal
  • A will return the cheapest solution
  • A is optimally efficient
  • No other optimal search method which works by
    expanding a path from the start state is
    guaranteed to expand fewer states than A

46
But ...
  • A is not the answer to all search problems.
  • As the path to the best solution gets longer, A
    takes exponentially longer to get there.
  • A's memory requirement grows exponentially.
  • For many real problems, systematic search of this
    sort is infeasible. To make progress we need to
    consider non-systematic techniques, or, more
    fundamentally, we need to incorporate more
    knowledge and experience about the problem
    domain.

47
Knowledge Representation
48
Prepositional Calculus
  • The prepositional calculus is based on statements
    which have truth values ( true or false).
  • The calculus provides a means of determining the
    truth values associated with statements formed
    from atomic'' statements. An example
  • If p stands for fred is rich'' and q for fred
    is tall'' then we may form statements such as

49
  • Note that the first 4 are all binary connectives.
    They are sometimes referred to, respectively, as
    the symbols for disjunction, conjunction,
    implication and equivalence. Also not is unary
    and is the symbol for negation.
  • If prepositional logic is to provide us with the
    means to assess the truth value of compound
    statements from the truth values of the building
    blocks' then we need some rules for how to do
    this.
  • For example, the calculus states that p q is true
    if either p is true or q is true (or both are
    true). Similar rules apply for all the ways in
    which the building blocks can be combined.

50
First Order Predicate Calculus
  • The predicate calculus includes a wider range of
    entities. It permits the description of relations
    and the use of variables. It also requires an
    understanding of quantification.
  • The last two are known as quantifiers.
  • The non-logical constants include both the
    names' of entities that are related and the
    names' of the relations. For example, the
    constant dog might be a relation and the constant
    fido an entity.

51
  • Note that the word and'' used in the left hand
    column is used to suggest that we have more than
    one formula for combination ---and not
    necessarily a conjunction.
  • In the last two examples, dog(x)'' contains a
    variable which is said to be free while the X''
    in X.Dog(x)'' is bound.
  • Sentence.
  • ---A formula with no free variables is a
    sentence.
  • Two informal examples to illustrate
    quantification follow.
Write a Comment
User Comments (0)
About PowerShow.com