Report1f

download Report1f

of 12

Transcript of Report1f

  • 7/27/2019 Report1f

    1/12

    Department of Computer Science andEngineering

    National Institute of Technology

    Karnataka, Surathkal

    Informed and Uninformed Search

    Week 1 Assignment

    for

    Artificial Intelligence and Expert Systems

    Elective - CO421

    Author:

    Sriniketh Vijayaraghavan10CO867th Semester, CSENITK, Surathkal

    Supervisor:

    K. Vinay KumarAssociate Professor

    Dept. of CSENITK, Surathkal

    Bangalore

    July 31, 2013

  • 7/27/2019 Report1f

    2/12

    Contents

    1 Introduction 3

    2 Uninformed Search 4

    2.1 Breadth First Search . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 Depth First Search . . . . . . . . . . . . . . . . . . . . . . . . . . 42.3 Iterative Deepening . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    3 Informed Search 6

    3.1 A* Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Iterative Deepening A* . . . . . . . . . . . . . . . . . . . . . . . . 63.3 Recursive Best First Search . . . . . . . . . . . . . . . . . . . . . 7

    4 Implementation 8

    4.1 Depth-First Search . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2 Breadth-First Search . . . . . . . . . . . . . . . . . . . . . . . . . 104.3 A* Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    1

  • 7/27/2019 Report1f

    3/12

    List of Figures

    1 Visual Representation of the Caenorhabditis elegans . . . . . . . 32 The order in which nodes are expanded in breadth-first search. . 43 The order in which nodes are expanded in depth-first search . . . 54 Visual Representation of the Neural Network . . . . . . . . . . . 85 Visual Representation of the DFS tree created . . . . . . . . . . 96 Visual Representation of the BFS tree created . . . . . . . . . . . 107 Visual Representation of the A* network created . . . . . . . . . 11

    2

  • 7/27/2019 Report1f

    4/12

    1 Introduction

    We study in this assignment the types of informed and uninformed searches. Toillustrate and visualize the effectiveness of informed searches over uninformedsearches, we take a dataset of a Neural network of the nematode Caenorhabditiselegans, compiled by Duncan Watts and Steven Strogatz from original experi-mental data by White et al.

    We perform the searches on this data by finding the longest path from the startnode and allow the sample search mechanisms to illustrate the advantages ofan informed search such as the A* as compared to the uninformed ones such asthe Depth First Search.

    Figure 1: Visual Representation of the Caenorhabditis elegans

    3

  • 7/27/2019 Report1f

    5/12

    2 Uninformed Search

    Uninformed search strategies do not take into account the location of the goal.Intuitively, these algorithms ignore where they are going until they find a goaland report success.

    2.1 Breadth First Search

    Uninformed searches perform operations on nodes without any special knowl-edge about the problem domain. The simplest of the uninformed searches is theBreadth First Search(BFS). It starts at a designated start node, then applies allpossible operations to its immediate successors and so on.

    Each application of a successor function to a node is called expanding the node.The uniform cost search is a variant of the BFS where the nodes are expandedoutwards along contours of equal cost rather than contours of equal depth aswe can observe in Figure 2. Nodes at each level are traversed before moving onto the next level

    It is a complete search and reaches the goal state if the goal b is finite.

    It takes time,1 + b + b2... + bd + (bd+1 b) = O(bd+1)

    The space required isO

    (bd+1

    ) as it needs to keeps all the fringe nodes in memory.

    Figure 2: The order in which nodes are expanded in breadth-first search.

    2.2 Depth First Search

    Implementing the frontier as a stack results in paths being pursued in a depth-first manner - searching one path to its completion before trying an alternativepath.

    4

  • 7/27/2019 Report1f

    6/12

    This method is said to involve backtracking: The algorithm selects a first al-

    ternative at each node, and it backtracks to the next alternative when it haspursued all of the paths from the first selection. Some paths may be infinitewhen the graph has cycles or infinitely many nodes, in which case a depth-firstsearch may never stop.

    It is not a complete search as it fails in the case of infinite-depth spaces, al-though it can be modified to avoid repeated states along a path. The timetaken is measured with respect to the maximum depth m and is O(bm).

    The space required however is only O(bm), i.e. only linear space is required tostore the nodes. We can see in Figure 3 how the gray nodes are traversed beforeother nodes which are higher up in the hierarchy.

    Figure 3: The order in which nodes are expanded in depth-first search

    2.3 Iterative Deepening

    To avoid the infinite depth problem of DFS, we can decide to only search untildepth L, i.e. we dont expand beyond depth L. This inherits the memoryadvantage of Depth-First search.

    Number of nodes generated in a depth-limited search to depth d with branchingfactor b:

    NIDS = (d + 1)b0 + db1 + (d 1)b2 + ... + 2bd1 + bd = O(bd)

    It is a complete search and the time taken is,

    (d + 1)b0 + db1 + ... + bd = O(bd)

    The space taken is O(bd)

    5

  • 7/27/2019 Report1f

    7/12

    3 Informed Search

    Informed searches do not proceed uniformly outward from the start node, in-stead it proceeds preferentially through nodes that heuristic, problem specificinformation indicates might be on the best path to a goal.These processes arecalled heuristic or best first searches.

    3.1 A* Algorithm

    For each node n, let h(n) be the heuristic factor, or an estimate of h(n), whereh(n) is the cost of the optimal path from n to the goal, g(n) be the depth factor,the cost of the lowest cost path found by A* so far up to node n.

    So, in algorithm A* we use,f = g + h

    where f is an estimate of f(n), the cost of the lowest-cost path to a goalconstrained to go through n.

    The number of nodes expanded in A* can be given as folows,

    N =(Bd 1)B

    (B 1)

    There are 3 important factors affecting the efficiency of A*, they are,

    The cost (length) of the path found.

    The number of nodes expanded

    The computational effort required to compute h

    3.2 Iterative Deepening A*

    This method is similar to the iterative deepening method discussed earlier. Weadd to this the benefits of a heuristic search. First we establish a cut off equalto,

    f(n0) = g(n0) + h

    (n0)

    We expand the nodes in a depth first fashion-backtracking whenever the f valueof a successor exceeds the cut-off value. If the DFS terminates at a goal node,

    then we know that the optimal path has been found.Intuitively it is easy to see that the IDA* algorithm always finds the minimumcost path to the goal.

    6

  • 7/27/2019 Report1f

    8/12

    3.3 Recursive Best First Search

    RBFS uses more memory than IDA* but generates fewer nodes than IDA* does.When a node n is expanded, RBFS computes the f values of the successors ofn and recomputes f values ofn and all ofns ancestors in the search tree. Thisrecomputation process is called backing up the f values.The backed up value f(m), of a node m in the search tree with successors miis,

    f(m) = minmi

    f(mi)

    where f(mi) is the backed up value of the node mi.

    7

  • 7/27/2019 Report1f

    9/12

    4 Implementation

    We take a neural network whose data was collected by Duncan Watts and StevenStrogatz - Famous for their Watts-Strogatz Network Model. The network con-tains 297 nodes and 2148 edges. That is it is a densely connected graph and weperform analysis on it by using 3 graph traversal methods.

    2 uninformed methods - Breadth First and Depth First search and 1 informedsearch - the A* algorithm.

    Figure 4: Visual Representation of the Neural Network

    This is the plot of the entire graph to illustrate how densely connected it is.

    Number of nodes in the network = 297

    Total Number of Edges = 2148

    Node furthest from Node 0 = Node 295

    8

  • 7/27/2019 Report1f

    10/12

    4.1 Depth-First Search

    Figure 5: Visual Representation of the DFS tree created

    Number of nodes in the DFS Tree = 297

    Total Number of Edges = 296

    DFS Path length from node 0 to node 295 = 190

    Time taken to run DFS = 0.04143

    9

  • 7/27/2019 Report1f

    11/12

    4.2 Breadth-First Search

    Figure 6: Visual Representation of the BFS tree created

    Number of nodes in the BFS Tree = 297

    Total Number of Edges = 296

    BFS Path length from node 0 to node 295 = 190

    Time taken to run BFS = 0.0402

    10

  • 7/27/2019 Report1f

    12/12

    4.3 A* Algorithm

    Figure 7: Visual Representation of the A* network created

    Number of nodes in the BFS Tree = 297

    Total Number of Edges = 5

    BFS Path length from node 0 to node 295 = 5

    Time taken to run BFS = 1.408

    A* path from 0 to 295 = [0,6,25,190,295]

    11