+ All Categories
Home > Documents > 0fe61lecture1

0fe61lecture1

Date post: 09-Apr-2018
Category:
Upload: piyush-datir
View: 215 times
Download: 0 times
Share this document with a friend

of 60

Transcript
  • 8/7/2019 0fe61lecture1

    1/60

    To build a system to solve a problem

    Define the problem precisely. This definition mustinclude precise specification of what the initialsituation(s) will be as well as what final situation

    constitute acceptable solution to the problem. Analyze the problem. A few very important featurescan have an immense impact on the appropriatenessof various possible techniques for solving the problem.

    Isolate and represent the task knowledge that isnecessary to solve the problem

    Choose the best problem-solving technique and applyit to the particular problem.

  • 8/7/2019 0fe61lecture1

    2/60

    2

    Water Jug Problem

    3 liters 4 liters

    x, y real numbers

    x integers between 0 and 4

    x, y between 0 and 4

  • 8/7/2019 0fe61lecture1

    3/60

    3

    Water Jugs cont.

    Rules : x0 (pour d ltr water out of the 3 ltr jug)

    ( Dump 4 liters )

    ( Dump 3 liters )

    | x+y >= 4

    | x+y >= 3

    | x+y

  • 8/7/2019 0fe61lecture1

    4/60

    Defining the problem as a state space

    search

    Basic Search Problem

    Given [S,s,O,G)

    S- is the implicitly specify set of states s is the start state

    O is the set of state transition operators

    G is the set of goal states

  • 8/7/2019 0fe61lecture1

    5/60

    Defining the problem as a state space

    search

    State Space - Define a state space that contains allthe possible configuration of the relevant objects.

    Start Space - Specify one or more states within

    that space describe possible situation from whichthe problem-solving process may start.

    Goal State - Specify one or more states would beacceptable as solutions to the problem.

    Operators Specify a set of rules that describethe actions available.

  • 8/7/2019 0fe61lecture1

    6/60

    6

    Examples of Problems

    Toy Problems :

    Water jug.

    Missionaries and Cannibals.

    8 Queens. 8 Puzzle. Real Problems :

    Schedules. Traveling Salesman.

    Robot navigation. Language Analysis (Parsers, Grammars). VLSI design

  • 8/7/2019 0fe61lecture1

    7/60

    Production System

    Since search forms the core of many

    intelligent processes, it is useful to structure AI

    programs in a way that facilitates describing

    and performing the search process.

    Production systems provide such structures

  • 8/7/2019 0fe61lecture1

    8/60

    8

    Production

    1. DATA initial database.

    2. Until DATA satisfies termination conditiondo:

    3. begin:

    Select some rule, R, in the set of rules that canbe applied to DATA.

    DATA result of applying R to DATA.4. end.

  • 8/7/2019 0fe61lecture1

    9/60

    A Production system

    A set of rules, each consisting of a left side (a pattern) thatdetermines the applicability of the rule and a right side thatdescribes the operation to be performed.

    One or more knowledge/database that contain whatever

    information is appropriate for the particular task. Somepart of the database may be permanent, while other partsof it may pertain only to the solution of the currentproblem.

    A control strategy that specifies the order in which the rules

    will be compared to the database and a way of resolvingthe conflicts that arise when several rules match at once.

    A rule applier.

  • 8/7/2019 0fe61lecture1

    10/60

    10

    Search Through State-Space

    Initial state

    Goal state

  • 8/7/2019 0fe61lecture1

    11/60

    Control strategies

    How to decide which rule to apply next duringthe process of searching for a solution to aproblem.

    As it is going to affect that how quicklyproblem is solved or even whether problem isfinally solved.

    Good control strategy The first requirement is that it cause motion

    The second requirement is that it be systematic

  • 8/7/2019 0fe61lecture1

    12/60

    Good Control strategy Cause Motion

    Water jug problem. Suppose we implemented the simple

    control strategy of starting each time at the top of the list

    of rules and choosing the first applicable one. If we didthat we, we would never solve the problem. We would

    continue indefinitely filling the 4- gallon jug with water.

    Good strategy is that it be systematic.

    The requirement that a control strategy be be systematiccorresponds to the need for global motion (over the

    course of several steps) as well as local motion (over the

    course of a single step)

  • 8/7/2019 0fe61lecture1

    13/60

    copyright 2005 all rightsreserved

    L. Manevitz Lecture 2 13

    Control via Search Techniques

    Uninformed :

    Breadth First.

    Depth First. Backtracking.

    Informed Heuristic :

    Hill Climbing. Best First, A*.

  • 8/7/2019 0fe61lecture1

    14/60

    Breadth- First search

    Create a variable called NODE-LIST and set it to theinitial state

    Until a goal state is found or NODE-LIST is empty do

    A) remove the first element from NODE_LIST and call it E,If NODE-LIST was empty, quit

    B) For each way that each rule can match the statedescribed in E do

    Apply the rule to generate a new state

    If the new state is a goal state, quit and return this state Otherwise, as the new state to the end of NODE-LIST

    Which data structure should it use for NODE-LIST?

  • 8/7/2019 0fe61lecture1

    15/60

    15

    Breadth First cont.

  • 8/7/2019 0fe61lecture1

    16/60

    16

    Breadth First

    b = branching factor d=depth

    1 + b + b + + b

    Time Complexity O(b )

    Space Complexity O(b )

    2 d

    d

    d

  • 8/7/2019 0fe61lecture1

    17/60

    Depth First Search

    If the initial state is a goal state, quit and returnsuccess.

    Otherwise, do the following until success or

    failure is signaled Generate a successor, E, of the initial state. If there are

    no more successors, signal failure.

    Call Depth-First Search with as the initial state

    If success is returned, signal success. Otherwisecontinue in this loop.

    Which data structure should it use ?

  • 8/7/2019 0fe61lecture1

    18/60

    18

    Depth First cont.

  • 8/7/2019 0fe61lecture1

    19/60

    Combinatorial Explosion

    To solve a problem there can be too many

    combination for a small set of possibilities,

    Eg Travelling Sales Problem even for 10 cities!10 possibilities. 3628800.

    Branch and bound strategies

  • 8/7/2019 0fe61lecture1

    20/60

    For real world problems, it is often hard to measure

    precisely the value of a particular solution.

    Rarely do we actually need the optimum solution; a

    good approximation usually serve very well.

    In fact, there is some evidence that people, when

    they solve problems, are not optimizers but rather

    are satisfiers.

    They seek solution that satisfies some set of

    requirements and as soon as they find one they quit.

    Eg. finding the parking space.

  • 8/7/2019 0fe61lecture1

    21/60

    Heuristic Search

    A heuristic is a technique that improves theefficiency of a search process, possibly by sacrificing

    claims of completeness. A good general purpose heuristic that is useful for a

    variety of combinatorial problem is the nearestneighbor heuristic.

  • 8/7/2019 0fe61lecture1

    22/60

    Applying nearest neighbour heuristic

    on travelling sales man problem

    Applying it to Traveling salesman Probelm Arbitrarily select a starting city

    To select the next city, look at all cities not yet visited and

    select the one closest to the current city . Go to it. Repeat step 2 until all cities have been visited.

    This procedure executes in time proportional to N2.a significant improvement over !N.

  • 8/7/2019 0fe61lecture1

    23/60

    A heuristic function is a function that maps from problem

    state descriptions to measures of desirability, usually

    represented as numbers.

    Which aspects of the problem state are considered, how those aspects are evaluated

    and the weights given to individual aspects are chosen in such

    a way that the value of the heuristic function at a given node

    in the search process gives as good estimate as possible of

    whether that node is on the desired path to a solution.

    The purpose of a heuristic function is to guide the search

    process in the most profitable direction by suggesting which

    path to follow first when more than one is available.

  • 8/7/2019 0fe61lecture1

    24/60

    Problem Characteristics

  • 8/7/2019 0fe61lecture1

    25/60

    Is the problem decomposable into a set

    independent smaller or easier subprogram.

    At each step, it checks to see whether the problem itis working on is immediately solvable. If so then the

    answer is returned directly.

    Otherwise, the integrator checks to see whether it

    can be decomposed into smaller problem.

  • 8/7/2019 0fe61lecture1

    26/60

    Can solution step be ignored or undone?

    Suppose we are trying to prove a mathematical

    theorem, if we realize that the lemma is no help at

    all, everything we need to know is still true, we can

    just proceed as we should have in the first place. In 8 puzzle problem after sliding a number, can we

    slide another number in place of first without

    backtrack?

    In a chess game, can a person after taking a move

    backtrack to original move?

  • 8/7/2019 0fe61lecture1

    27/60

    Problems are

    Ignorable

    Recoverable

    irrecoverable

  • 8/7/2019 0fe61lecture1

    28/60

    Is the universe predictable

    Certain-outcome problem (8 puzzle)-

    Every time we make a move, we know exactly what will

    happen.

    We can use planning to avoid having undo actualmoves, although it will be necessary to backtrack past

    those moves one at a time during planning process.

    Uncertain outcome problem (chess, bridge)

  • 8/7/2019 0fe61lecture1

    29/60

    Is good solution Absolute or relative?

    Consider the problem of answer questions based ona database of simple facts Marcus was a man.

    Marcus was pompeian.

    Marcus was born in 40 AD. All men are mortal.

    All pompeians died when the volcano erupted in 79 AD

    No mortal lives longer than 150 years.

    It is now 2010 AD. Suppose the question is is marcus alive?

    Consider the travelling sales man problem. There canbe any path problem or best path problem.

  • 8/7/2019 0fe61lecture1

    30/60

    Is the solution a state or path?

    Finding a consistent interpretation for the sentence

    The bank president ate a dish of pasta salad with the

    fork.

    There are several components of this sentence,

    which in isolation may have more than one

    interpretation.

    But the component must form a coherent whole andso they constrain each others interpretation.

  • 8/7/2019 0fe61lecture1

    31/60

    Is the solution a state or path?

    The word bank may refer either to a financial institution orto a side of a river.

    The word dish is the object of the verb eat. It is possible thata dish was eaten. But more likely that the pasta salad in the

    dish was eaten. Pasta salad is a salad containing pasta. But there are other

    ways meaning can be formed from pairs of nouns.

    The phrase with the fork could modify several parts of thesentence. In this case it modifies the verb eat. But if thephrase had been with vegetables then the modificationwould be different.

    What in case of water jug problem.

  • 8/7/2019 0fe61lecture1

    32/60

    What is the role of knowledge?

    Does the chess require knowledge? If require

    than how much?

    Consider the problem of scanning daily newspaper to decide the reason for inflation and

    how it can be tackled?

  • 8/7/2019 0fe61lecture1

    33/60

    Does the task require interaction with

    a person?

    Consider the problem of proving mathematicaltheorems.

    Solitary Problems the computer is given a problem

    description and produces and answer with noimmediate communication and with no demand foran explanation?

    Conversational problem there is intermediate

    communication between a person and computer,either to provide additional assistance to thecomputer or to provide additional information theuser or both.

  • 8/7/2019 0fe61lecture1

    34/60

    Heuristic Search Techniques

    Generate & Test

    Hill Climbing

    Best First Search Problem Reduction

    Constraint Satisfaction

  • 8/7/2019 0fe61lecture1

    35/60

    Generate-and-Test

    Algorithm

    Generate a possible solution. For some problem, this means

    generating a particular point in the problem state space.

    Test to see if this is actually a solution by computing the chosen point

    or the endpoint of chosen path to the set of acceptable goal states.

    If a solution has been found quit. Otherwise return to step 1.

    It is an exhaustive search of the problem space.

    It is also known as British Museum Algorithm.

  • 8/7/2019 0fe61lecture1

    36/60

    Hill Climbing

    Simple Hill Climbing

    Evaluate the initial state, If it is also a goal state, then return it and

    quit. Otherwise continue with the initial state as the current state.

    Loop until a solution is found or until there are no new operator left to

    be applied in the current state Select an operator that has not yet been applied to the current state and

    apply it to produce a new state.

    Evaluate the new state

    If it is a goal state, then return it and quit

    If it is a goal state but it is better than the current state, then make it thecurrent state.

    If it is not better than the current state, then continue in the loop.

  • 8/7/2019 0fe61lecture1

    37/60

    The key difference between this algorithm and

    the Generate-and-Test is the use of an

    evaluation function as a way to inject task

    specific knowledge into control process.

  • 8/7/2019 0fe61lecture1

    38/60

    Hill Climbing

    Steepest-Ascent Hill Climbing

    Evaluate the initial state. If it is also a goal state, then return it and

    quit. Otherwise, continue with the initial state as the current state.

    Loop until a solution is found or until a complete iteration produces no

    change to current state. Let succ be a state such that any possible successor of the current state

    will be better than succ.

    For each operator that applied to the current state do:

    Apply the operator and generate a new state.

    Evaluate the new state. If it is a goal state, then return it and quit. If notcompare it to succ. If it is better, then set succ to this state. If it is not better,

    leave succ alone.

    If succ is better than current state, set current state to succ.

  • 8/7/2019 0fe61lecture1

    39/60

    To apply steepest-ascent hill climbing, we mustconsider all perturbation of the initial state andchoose the best.

    Both basic and steepest-ascent hill climbing may failto find a solution.

    Either algorithm may terminate not by finding a goalstate but by getting to a state from which no better

    states can be generated. This will happen if the program has reached either alocal maximum, a plateau or a ridge.

  • 8/7/2019 0fe61lecture1

    40/60

    A Local maximum is a state that is better than

    all its neighbors but is not better than some

    other states farther away.

    A plateau is a flat area of the search space in

    which a whole set of neighboring state have

    the same value. On a plateau, it is not possible

    to determine best direction in which to moveby making local comparisons.

  • 8/7/2019 0fe61lecture1

    41/60

    A ridge is a special kind of local maximum. It is an area of the search spacethat is higher then surrounding area and that itself has a slope.

    Each point on a ridge looks to the algorithm like a local maximum, eventhough the point is part of a curve leading to a better optimum

    Ways of dealing with these problems

    Backtrack Backtrack to some earlier node and try going in a different direction.

    To implement this, maintain a list of paths almost taken and go back to one of themif the path that was taken leads to a dead end. Good for local maximum

    Make a big jump in some direction to try to get to new section of the searchspace. Good for plateau.

    Apply two or more rules before doing the test. This corresponds to moving in

    several direction at once. Good for dealing with ridges

  • 8/7/2019 0fe61lecture1

    42/60

    Best First Search

    Or Graphs At each step best first search process (BFS), we select the

    most promising of the nodes we have generated so far.

    This is done by applying an appropriate heuristic function

    each of them. expand the chosen node by using the rules to generate its

    successors.

    If one of them is a solution, we can quit.

    If not, all those new nodes are added to the set of nodes

    generated so far. Again the most promising node is selected and the process

    continues.

  • 8/7/2019 0fe61lecture1

    43/60

    To implement such a graph-search procedure, will

    need to use two list of node

    OPEN Nodes that have been generated and have had the

    heuristic function applied to them but which have not yetbeen examined. OPEN is actually a priority queue in which

    the elements with the highest priority are those with the

    most promising value of the heuristic function.

    CLOSED nodes that have been examined. We need to

    keep these nodes in memory if want to search graph

    rather than a tree, since whenever a new node is

    generated, we need to check whether it has been

    generated before.

  • 8/7/2019 0fe61lecture1

    44/60

    Algorithm

    Start with open containing the initial state.

    Until a goal is found or there are no nodes left on open do:

    Pick the best node on open Generate its successor

    For each successor do

    If it has not been generated before, evaluate it, add it to open and

    record its parent.

    If it has been generated before, change the parent if this new path isbetter than the previous one. In that case, update the cost of getting

    to this node and to any successors that this node may already have.

  • 8/7/2019 0fe61lecture1

    45/60

    A

    B (3) C (5) D (1)

    A

    B (3) C (5) D

    E (4) F (6)

    A

    B C D

    E FG (6)H(5)

    A

    B C D

    E FG H

    I(2) J(1)

    A

  • 8/7/2019 0fe61lecture1

    46/60

    g a measure of the cost of getting from initial state to the

    current node. G is not an estimate of anything but it is exact

    sum of the costs of applying each of the rules that were

    applied along the best path to the node.

    The function h is an estimate of the additional cost of getting

    from the current node to a goal state. This is the place where

    knowledge of problem domain exploited

    f, represent an estimate of the cost of getting from the initial

    state to a goal state along the path that generated the currentnode.

  • 8/7/2019 0fe61lecture1

    47/60

    A* Algorithm

    Start with OPEN containing only the initial node. Set that

    nodes g value to 0, its h value to whatever it is, and its f

    value to h+ g. Set Closed to the empty list.

    Until a goal node is found repeat

    If there are no nodes on open, report failure

    Otherwise, pick the node on OPEN with the lowest f value. Call it

    BESTNODE. Remove it from OPEN. Place it on CLOSED.

    Check if best node is goal state, if so then report and exit.

    Otherwise generate the successor of BESTNODE (but do not setBESTNODE to point to them yet).

  • 8/7/2019 0fe61lecture1

    48/60

    For Each successor

    Set successor to point back to BESTNODE.

    Computer g(Successor) = g(BESTNODE) + the cost of getting from

    BESTNODE to successor.

    Check if successor is the as any node on open (i.e. already generatedbut not processed) then call that node OLD.

    Check whether it is cheaper to get to OLD via its current parent or to

    SUCCESSOR via BESTNODE by comparing their g values.

    If OLD is cheaper, then we need do nothing. If SUCCESSOR is cheaper,

    then reset OLDs parent link to point to BESTNODE, record the newcheaper path in g(OLD), and update f(OLD).

  • 8/7/2019 0fe61lecture1

    49/60

    If SUCCESSOR was not on OPEN, See If It is on

    CLOSED. If so, call the node on CLOSED as OLD and

    add OLD to the list of BESTNODE succesor.

    Check to se if the new path or the old path is betteras previous and set the parent link and g & f values

    appropriately.

    If we have just found a better path to OLD, we must

    propagate the improvement to OLDs Successors.

  • 8/7/2019 0fe61lecture1

    50/60

    If successor was not already on either OPEN or

    CLOSED, then put it on open and add it to the

    list of BESTNODEs successors.

    Compute

    f(successor)=g(successor)+h(successor)

  • 8/7/2019 0fe61lecture1

    51/60

    Function g lets us choose which node to expand next on thebasis not only of how good the node itself look, but also onthe basis of how good the path to the node was.

    If we case about the path consideration of g is important.

    If we only care about getting to a solution somehow, we candefine g always to be 0.

    If we want to find a path involving the fewest number of steps, then we set the cost of going from a node to itssuccessor as a constant, usually 1.

    If we want to find the cheapest path and some operator costmore than others, then we set the cost of going from a nodeto another to reflect those costs, then we set the cost of goingfrom one node to another to relect those costs.

  • 8/7/2019 0fe61lecture1

    52/60

    If h is a perfect estimator of h, then A* will converge

    immediately to the goal with no search.

    If value of h is always 0, then search will be

    controlled by g. If value of g is 0 then search is random

    If the value of g is always 1, the search will Breadth first

    search.

    If we can maintain that h never overestimates h,then A* algorithm is guaranteed to find that h an

    optimal path to a goal, if one exists.

  • 8/7/2019 0fe61lecture1

    53/60

    This implementation is for graph.

    If can be simplified to apply to trees by not

    bothering to check whether a new node is

    already on OPEN or CLOSEd. This makes it

    faster to generate node.

  • 8/7/2019 0fe61lecture1

    54/60

    Problem Reduction

    AND-OR Graphs

    It is useful for representing the solution of problems that can be solved by decomposing

    them into a set of smaller problem, all of whichmust then be solved.

    This decomposition, or reduction, generates arcthat we call AND arcs.

    One AND arc may point to any number of successor nodes, all of which must be solved inorder for the arc to point to a solution.

  • 8/7/2019 0fe61lecture1

    55/60

    Goal : Acquire TV Set

    Goal: Steal TV Set Goal : Earn Some Money Goal : Buy TV Set

  • 8/7/2019 0fe61lecture1

    56/60

  • 8/7/2019 0fe61lecture1

    57/60

    Change the f estimate of the newly expanded nodeto reflect the new information provided by itssuccessors.

    Propagate this change backward through the graph.

    If any node contains a successor arc whosedescendants are all solved, label the node itself asSOLVED.

    At each node that is visited while going up the graph,

    decide which of its successor arcs is the mostpromising and mark it as part of the current bestpath. This may cause the current best path tochange.

  • 8/7/2019 0fe61lecture1

    58/60

  • 8/7/2019 0fe61lecture1

    59/60

    59

    Points to Consider when Representing

    Problems

    Decomposable ?

    Can partial steps be ignored or undone ?

    Predictable ?

    A

    A

    B

    CB

    C

    Theorem proving vs. chess

  • 8/7/2019 0fe61lecture1

    60/60

    Points to Consider when Representing

    Problems cont.

    Is good solution easily recognizable ?

    Is Knowledge Base consistent ?

    How much Knowledge is needed ?

    Traveling Salesman

    Big Data Base and limitations of logic

    Chess, Newspaper-Understanding