Lect 2 Introduction to AI and SEARCH

Embed Size (px)

Citation preview

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    1/7

    Knowledge Based Systems ~ Wainaina Page of 7

    INTRODUCTION

    Intelligence

    Intelligence is the computational part of the ability to achieve goals in the world. Varying kindsand degrees of intelligence occur in people, many animals and some machines.

    Artificial Intelligence (A I)

    Artificial Intelligence is the development of systems that exhibit the characteristics we associatewith intelligence in human behavior: perception, natural language processing, reasoning,planning and problem solving, learning and adaptation, etc.

    Characteristics of A.I. Programsa) Symbolic ProcessingSymbolic processing is reasoning about objects represented by symbols, and their properties andrelationships, rather than numerical calculations. Generally A.I. programs primarily usesymbolicrepresentations: collections of symbols that represent:

    Objects. Properties of objects. Relationships among objects. Rules about classes of objects.

    b) Knowledge RepresentationKnowledge is the general principles that are stored in the program and used for reasoning aboutnovel situations. This knowledge is represented by some kind of data structures in the machine'smemory that reflect the complexity of the real world. Several kinds of knowledge need to berepresented:

    Factual Data:Known facts about the world. General Principles:For example, ``Every vehicle requires fuel.'' Hypothetical Data:The computer must consider hypotheticals in order to reason about

    the effects of actions being contemplated.

    c) SearchThis is a method for finding a solution to a problem when no direct method exists. Searchprograms find a solution for a problem by trying differentsequencesof actions(operators) untila solution is found.Search fits in nearly every area of A.I. in the following ways:

    Natural Language:A parser searches for the best ways of assigning structure andmeaning to sentences that are ambiguous.

    Planning:A planner searches for a sequence of actions that will accomplish a goal. Perception:The raw input is often ambiguous; the perception program searches for a

    consistent set of interpretations of parts of the input.

    Learning:A learning program searches for a compact description of a set of traininginstances.

    Expert Systems:Search finds rules applicable to the current problem.

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    2/7

    Knowledge Based Systems ~ Wainaina Page 2 of 7

    d) HeuristicsAre similar to rules of thumb where you need not rethink completely what to do every time asimilar problem is encountered.

    e) InferencingThis is a form of reasoning with facts and rules using heuristics or some search strategies.

    PROBLEM SOLVING TECHNIQUES IN ARTIFICIAL INTELLIGENCEProblems are tackled in AI using two main broad approaches namely:

    i) Search techniqueii) Modelling natural phenomena (e.g. evolution, and neural networks).

    I) NEURAL NETWORKSA neural network is used to model the human neuron. The neural network consists of a numberof nodes that are connected using links. Each link has a numeric weight that is associated with it.The learning occurs by adjusting the weights so that the inputs correspond to the outputs. A

    neural network unit consists of a linear input functionthat computes the sum of weighted inputs.It also has a non linear component called activation function that transforms the final inputvalues into a final activation value.

    Neural networks have been used in pronunciation in which text streams are mapped to phonemes(basic sound elements); handwritten text recognition; driving (ALVINN (1993)-learnt how tosteer a vehicle by observing the human driver.

    II)SEARCHING TECHNIQUESearching is the process of looking for the solution of a problem through a set of possibilities(state space). The solutionis a path from the current state to the goal state.

    Process of Searching

    Searching proceeds as follows:1. Check the current state;2. Execute allowable actions to move to the next state;3. Check if the new state is the solution state; if it is not then the new state becomes

    the current state and the process is repeated until a solution is found or the statespace is exhausted.

    Search problem

    The search problem consists of finding a solution plan, which is a path from the current state to

    the goal state.

    Representing search problems

    A search problem is represented using a directed graph. The states are represented as nodes whilethe allowed steps or actions are represented as arcs.

    Defining a search problem

    A search problem is defined by specifying:

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    3/7

    Knowledge Based Systems ~ Wainaina Page 3 of 7

    State space; Start node; Goal condition, and a test to check whether the goal condition is met; Rules giving how to change states.

    Example of a search case studyThree blocks A, B, C on a table are considered. A block can be grasped when there is no otherblock on top of it. Only one block can be moved at a time.

    Possible moves Put a block on table; Put a block on top of another block; Remove a block from the top of another and place on top of another block.

    Search Problem

    Initial state (current state)

    CA

    B

    Goal state (final state)

    A

    B

    C

    State space C BA A A A

    B BC BC C

    C BB B C CA AC ABC AB A

    B CAC AB

    A AB CC B

    The state space has 13 elements or nodes.

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    4/7

    Knowledge Based Systems ~ Wainaina Page 4 of 7

    The solution to our problem is any member of the set of all paths from original to goal state suchas the path indicated in bold.

    Search Strategies

    These are controls mechanisms used to direct the search and enable to select which operator to

    apply at each step, when there is more than one operator to be applied. Different search strategiesare evaluated in terms of four criteria:1. Completeness: is the strategy guaranteed to find a solution when there is one?2. Time complexity: how long does it take to find a solution?3. Space complexity: how much memory does it need to perform the search?4. Optimality:does the strategy find the highest quality solution when there are several differentsolutions?

    Example of a problem (2)

    The figure below contains a representation of a map. The nodes represent cities, and the linksrepresent direct road connections between cities. The number associated to a link represents the

    length of the corresponding road. The search problem is to find a path from a city S to a city G

    S

    A

    D

    B

    E

    C

    F

    G

    3

    4 4

    5 5

    42

    43

    Types of Searches

    There are two broad classes of searches:i) Uninformed search (blind / Exhaustive search)ii) Informed search (Heuristic/ Guided search)

    1) Uninformed search:This is a search that has no information about its domain. The only thing that a blind searchcan do is distinguish a non-goal state from a goal state. The following are the variousuniform search algorithms:

    i) Breadth-first search:- Looks for the goal node among all the nodes at a given levelbefore using the children of those nodes to push on as shown below

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    5/7

    Knowledge Based Systems ~ Wainaina Page 5 of 7

    S

    A D

    BE

    CF

    G

    D A

    E E BB

    A CECFBFD

    Breadth-first search of a path from node S to node G.

    Breadth first search can only be used for small problems. If we have larger problems tosolve then there are better blind search strategies that can be used (depth first search).

    ii) Depth-first search:- Looks for the goal node among all the children of the current nodebefore using the sibling of this node to push on as shown below

    S

    A

    B

    C

    G

    E

    FD

    Depth-first search of a path from node S to node G.

    2) Informed search: -This is a search that uses domain-dependant (heuristic) information in order to search thespace more efficiently. The idea behind aheuristicsearch is to explore the node that is mostlikelyto be nearest to a goal state. To do this, a heuristic function which tells us how close

    we are to a goal state is used. There is no guarantee that the heuristic function will return avalue that ensures that a particular node is closer to a goal state than any other node.Heuristic is used as an estimate, based on domain-specific information that is computablefrom the current state description, of how close we are to a goalThe following are the various heuristic search algorithms:

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    6/7

    Knowledge Based Systems ~ Wainaina Page 6 of 7

    i).Uniform-cost search:- Looks for the cheapest path from the start node to a goal node.i.e. this method always extends the cheapest path found so far. In this way it isguaranteed to find the cheapest path, if one exists.

    ii).Hill climbing:- Hill climbing is depth-first search with a heuristic measurement thatorders choices as nodes are expanded. It always selects the most promising successor ofthe node last expanded. For instance, one may consider that the most promisingsuccessor of a node is the one that has the shortest straight-line distance to the goal cityG. In figure below, the straight line distances between each city and G is indicated insquare brackets.

    S

    A

    D

    B

    E

    C

    F

    G

    3

    4 4

    5 5

    42

    4

    3

    [8]

    [8.5] [6]

    [6] [3]

    [3]

    [10]

    The hill climbing search from S to G proceeds as follows:

    S

    A

    A

    G

    E

    FB

    88.5

    8.5 6

    6 3

    D

    iii).Greedy Search: - The node closest to the goal state, as determined by an evaluationfunction f(n) = h(n), is expanded first. Generally it selects node to expand that isbelieved to be closest (hence it's "greedy") to a goal node (i.e., smallestfvalue).A Heuristic Function (h(n)) is a function that calculates the cost of reaching the goal

    state from the node n.

    iv).The search algorithm A*: - is a refinement of the greedy search due to the fact that it isneither optimal nor complete. The goal of the A* algorithm is to find a minimal cost-path joining the start node and a goal node. It uses the following evaluation function toestimate the promise of a node n:

    f*(n) = g*(n) + h*(n)

  • 8/13/2019 Lect 2 Introduction to AI and SEARCH

    7/7

    Knowledge Based Systems ~ Wainaina Page 7 of 7

    where:g*(n) estimates the minimum cost of a path from the start node to node n;h*(n) estimates the minimum cost from node n to a goal.

    The node chosen for expansion is the one for which f* is minimum.

    Notice that A* is very similar to the uniform-cost search, except that it uses a differentfunction (which is a heuristic function) to estimate the promise of a node.In fact, A* reduces to uniform-cost search if h*(n) is always considered to be 0.

    Example

    Use A* algorithm to find the path from city S to city G by using the following functions:

    S

    A

    D

    B

    E

    C

    F

    G

    3

    4 4

    5 5

    42

    43

    [8]

    [8.5] [6]

    [6] [3]

    [3]

    [10]

    In the above figure, the value of h* for each node is represented in square brackets. Thatis, h*(D) = 8.

    Solution:

    S

    A D

    B E

    C F

    G

    D A

    E B

    h*(A)=8.5

    4

    4 5 5 2

    4 5 5 4

    18 17

    3

    13

    14

    step 1

    f*(A)=3+8.5 12

    13

    step 2 step 3

    17.5 12

    13

    step 4step 5

    step 6

    11.5

    3g*(A)=3

    h*(D)=8f*(D)=4+8

    g*(D)=4

    7+6 9+8.5 6+68+8=16

    11+6 10+3

    A* search of a path from S to G.