Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.

Slides:



Advertisements
Similar presentations
Artificial Intelligent
Advertisements

Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
Additional Topics ARTIFICIAL INTELLIGENCE
Review: Search problem formulation
Uninformed search strategies
January 26, 2003AI: Chapter 3: Solving Problems by Searching 1 Artificial Intelligence Chapter 3: Solving Problems by Searching Michael Scherger Department.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
Uninformed (also called blind) search algorithms) This Lecture Chapter Next Lecture Chapter (Please read lecture topic material before.
Properties of breadth-first search Complete? Yes (if b is finite) Time? 1+b+b 2 +b 3 +… +b d + b(b d -1) = O(b d+1 ) Space? O(b d+1 ) (keeps every node.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
Blind Search1 Solving problems by searching Chapter 3.
Search Strategies Reading: Russell’s Chapter 3 1.
May 12, 2013Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM.
1 Chapter 3 Solving Problems by Searching. 2 Outline Problem-solving agentsProblem-solving agents Problem typesProblem types Problem formulationProblem.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
1 Lecture 3: 18/4/1435 Uninformed search strategies Lecturer/ Kawther Abas 363CS – Artificial Intelligence.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
Artificial Intelligence for Games Uninformed search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.
Artificial Intelligence (CS 461D)
Search Strategies CPS4801. Uninformed Search Strategies Uninformed search strategies use only the information available in the problem definition Breadth-first.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
CS 380: Artificial Intelligence Lecture #3 William Regli.
Review: Search problem formulation
Searching the search space graph
1 Lecture 3 Uninformed Search. 2 Complexity Recap (app.A) We often want to characterize algorithms independent of their implementation. “This algorithm.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
1 Lecture 3 Uninformed Search
Lecture 3 Uninformed Search.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Problem Solving and Search Andrea Danyluk September 11, 2013.
Tree Searching Breadth First Search Dept First Search.
Search Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore, Svetlana Lazebnik,
Artificial Intelligence
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Lecture 3: Uninformed Search
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
SOLVING PROBLEMS BY SEARCHING Chapter 3 August 2008 Blind Search 1.
A General Introduction to Artificial Intelligence.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
Uninformed Search Methods
Implementation: General Tree Search
Fahiem Bacchus © 2005 University of Toronto 1 CSC384: Intro to Artificial Intelligence Search II ● Announcements.
Solving problems by searching A I C h a p t e r 3.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 CS121 – Winter 2003.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
Lecture 3 Problem Solving through search Uninformed Search
Lecture 3: Uninformed Search
Breadth First and Depth First
Uninformed Search Chapter 3.4.
Uninformed Search Strategies
Artificial Intelligence (CS 370D)
Solving problems by searching
Artificial Intelligence
Principles of Computing – UFCFA3-30-1
Search Strategies CMPT 420 / CMPG 720.
Presentation transcript:

Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology (CIIT) Islamabad, Pakistan.

Summary of Previous Lecture Problem solving by searching What is Search? Problem formulation Search Space Definitions Goal-formulation Searching for Solutions Visualize Search Space as a Graphs

Today’s Lecture Types of search Algorithms Uninformed Search Informed Search Breadth-first searching Depth-first search Compare breadth first and depth first

Today’s Lecture Types of search Algorithms Uninformed Search Informed Search Breadth-first searching Depth-first search

Two main types of search All search strategies are distinguished by the Order in which nodes are expanded 1.Uninformed search methods (Blind search) have access only to the problem definition. Breadth-first search Uniform-cost search Depth-first search Iterative deepening search Bidirectional search 2.Informed search methods may have access to a heuristic function h(n) that estimate the cost of a solution from n. Greedy best-first search A* search Recursive best-first search (RBFS) search

Uninformed Search Sometimes we may not get much relevant information to solve a problem. Suppose we lost our car key and we are not able to recall where we left, we have to search for the key with some information such as in which places we used to place it. It may be our pant pocket or may be the table drawer. If it is not there then we have to search the whole house to get it. The best solution would be to search in the places from the table to the wardrobe. Here we need to search blindly with less clue. This type of search is called uninformed search or blind search.

Uninformed Search and Exploration Blind search – BFS, DFS, uniform cost no notion concept of the “right direction” can only recognize goal once it’s achieved

Informed Search We can solve the problem in an efficient manner if we have relevant information, clues or hints. The clues that help solve the problem constitute heuristic information. Informed search is also called heuristic search. Instead of searching one path or many paths just like that informed search uses the given heuristic information to decide whether or not to explore the current state further.

Informed Search Add domain-specific information to select the best path along which to continue searching Define a heuristic function, h(n), that estimates the “goodness” of a node n. Specifically, h(n) = estimated cost (or distance) of minimal cost path from n to a goal state. The heuristic function is an estimate, based on domain-specific information that is computable from the current state description, of how close we are to a goal

Breadth-first search Breadth first search (BFS), as the name implies, searches from the initial state breadth-wise. That is it searches all the states in the tree level by level. Only after exploring all the states in one level it will jump to the next level. Once the solution is found the search stops. The breadth first search is guaranteed to find the solution if one exists.

Breadth-first search Expand shallowest unexpanded node Implementation:

Breadth-first search Expand shallowest unexpanded node Implementation:

Breadth-first search Expand shallowest unexpanded node Implementation:

Breadth-first search Expand shallowest unexpanded node

Breadth-first searching A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away For example, after searching A, then B, then C, the search proceeds with D, E, F, G Node are explored in the order A B C D E F G H I J K L M N O P Q J will be found before N LM N OP G Q H J IK FED BC A

Breadth-first search algorithm Nodes are lining up to be visited in open. closed keeps track of all the nodes visited already.

A trace of breadth-first algorithm | | | || | | | ||| |||| Items between red bars are siblings. B is not the goal. Put his children onto the queue. Put him in closed. He is done. goal is reached or open is empty.

Properties of breadth-first search Complete? Yes (if b is finite) Time? 1+b+b 2 +b 3 +… +b d + b(b d -1) = O(b d+1 ) Space? O(b d+1 ) (keeps every node in memory) Optimal? Yes (if cost = 1 per step) Space is the bigger problem (more than time)

Breadth-first search tree sample 0 expansion 1 expansion 2 expansions 3 expansions Branching factor: number of nodes generated by a node parent (we called here “b”)  Here after b=2

Breadth First Complexity  The root  generates (b) new nodes  Each of which  generates (b) more nodes  So, the maximum number of nodes expended before finding a solution at level “d”, it is : 1+b+b 2 +b 3 +….+b d  Complexity is exponential = O(b d )

Time and memory requirement in Breadth-first DepthNodesTimeMemory 011 millisec100 bytes sec11 Kb sec1 Mb minutes111 Mb hours11 Gb days1 Tb years111 Tb years Tb Assume branching factor b=10; 1000 nodes explored/sec and 100 bytes/node

Depth-first search Explore only one branch deeper till the solution is found or there is no new state to explore and then start searching the adjacent level. This technique is called depth first searh (DFS). By chance the solution exists in the first branch then depth first search can find the solution quickly. If the solution exists in some other branches farther away, there won't be much difference between depth first search and breadth first search

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first search Expand deepest unexpanded node Implementation:

Depth-first searching A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path For example, after searching A, then B, then D, the search backtracks and tries another path from B Node are explored in the order A B D E H L M N I O P C F G J K Q N will be found before J LM N OP G Q H J IK FED BC A

The depth-first search algorithm This is the only difference between depth-first and breadth-first.

A trace of depth-first algorithm top of stack

Snap shot at iteration 6 frontier visited

Properties of depth-first search Complete? No: fails in infinite-depth spaces, spaces with loops – Modify to avoid repeated states along path  complete in finite spaces Time? O(b m ): terrible if m is much larger than d – but if solutions are dense, may be much faster than breadth-first Space? O(bm), i.e., linear space! Optimal? No

Depth-first search tree sample 0 expansion 1 expansion 2 expansions 4 expansions Branching factor: number of nodes generated by a node parent (we called here “b”)  Here after b=2

Depth First Complexity  Let b: is the branching factor  Let d: maximum depth to find solution  So, the maximum number of nodes expended before finding a solution at level “m”, it is : 1+b+b+b+….+b (m times) Memory need = b*d  Complexity in worst case = O(b d ) as “Breadth-First”  Complexity in best case = O(b*d) which is excellent!

Time and memory requirement in Depth-first DepthNodes Time (best case) Memory 01 1 millisec 100 bytes sec 2 Kb sec 4 Kb 610 * sec 6 Kb 810 * sec 8 Kb 1010 * sec 10 Kb 1210 * sec 12 Kb 1410 * sec 14 Kb Assume branching factor b=10; 1000 nodes explored/sec and 100 bytes/node

Search sequences of depth-first and breadth-first Breadth first: A, B, C, … Depth first: 1, 2, 3, …

Comparing the ordering of search sequences Determine the order of nodes (states) to be examined Breadth-first search – When a state is examined, all of its children are examined, one after another – Explore the search space in a level-by-level fashion Depth-first search – When a state is examined, all of its children and their descendants are examined before any of its siblings – Go deeper into the search space where possible

Breadth-first search of the 8-puzzle  Cannot move blank downward  

Depth-first search of 8-puzzle with a depth bound of 5 Breadth-first took 46 nodes.

Summery of Today’s Lecture Types of search Algorithms Uninformed Search Informed Search Breadth-first searching Depth-first search Compare breadth first and depth first