(Radhika) presentation on chapter 2 ai

Radhika Srinivasan
Radhika SrinivasanTata Consultancy Services
CHAPTER - 2


      Problem Spaces and
      P roblem Solving by
           Searching
                  Presented By :
                  Radhika Srinivasan PG
                  Roll No : 45
What we will learn today …




 What is Problem Spaces?
 How to Search to get solutions?
 Using Different searching algorithms i.e.
  basically used in AI
 Some Toy problems and Real world problems
Introduction


     Now, we’ll study about what are the kinds of problems
    where the AI is concerned and the technique that is
    used to solve those problems.
       There are 4 things concerned to solve a particular
    problem.
   Define the problem precisely.
   Analyze the problem.
   Isolate and represent the task knowledge i.e. required
    to solve the problem.
   Finally, choose the best problem solving technique and
    apply to the particular problem.
Areas


  Problem Solving
-Puzzles
-Play games, e.g chess
-Symbolic integration of mathematical formulas.
-Some programs can improve their performance with
   experience
 Logical reasoning

– Prove assertions (theorems) by manipulating a database
   of facts
Areas


  Language
– Understanding of natural language
– Translation
– E.g. Spelling checker
 Programming

– Write computer programs based on a description
 Systems and languages

– Time-sharing, list processing, and interactive debugging
   were developed in the AI research
What is problem space ?


 Problem space is a set of states and the connections
  between to represent the problem. Problem space graph
  is used to represent a problem space. In the graph, the
  states are represented by nodes of the graph, and the
  operators by edges between nodes.
 For simplicity they are often represented as trees,
  where the initial state is the root of the tree. The cost of
  the simplification is that any state that can be reached
  by two different paths will be represented by duplicate
  nodes thereby increasing the tree size. The benefit of
  using tree is that the absence of cycles greatly
  simplifies many search algorithms.
Search


  State Space and Problem Reduction
– State space
 An operator produces exactly one new state

– Problem reduction
 An operator produces a set of sub problems, each of
   which have to be solved.
- E.g.
       Tower of Hanoi
Search - problem representation


 State space graph
 It is represented like nodes and edges where initial
  state to the goal state. It can also represent as tree
  graph.
Search Strategy


   A strategy is defined by picking the order of node
    expansion. Strategy is evaluated among the following
    dimensions.
   Completeness- does it always find a solution if one
    exists?
   Time complexity- no. of nodes generated.
   Space complexity- max no. of nodes in memory.
   Optimality- does it always find least cost solution?
   Time and space is measured in ‘b’ – max branching
    factor of search tree. ‘d’- depth of least cost solution.
    ‘m’ – max depth of the state space may be (infinite)
Which are the Search Types ?


  Blind search algorithms are as follows:
 In blind search the number of nodes can be

   extremely large, The order of expanding the nodes is
   arbitrary
  - Breadth First Search
  - Depth First Search
 Heuristic search

  - Ordered Search
  - A* An optimal search
 Consider State space graph as general graph i.e. nodes
   and points. Graphs can be directed undirected or mixed
   graph.
Breadth-First Search


 Breadth First Search (BFS) searches breadth-wise in
  the problem space. Breadth-First search is like
  traversing a tree where each node is a state which may
  a be a potential candidate for solution.
 Breadth first search expands nodes from the root of the
  tree and then generates one level of the tree at a time
  until a solution is found. It is very easily implemented
  by maintaining a queue of nodes.
 Initially the queue contains just the root. In each
  iteration, node at the head of the queue is removed and
  then expanded. The generated child nodes are then
  added to the tail of the queue.
ALGORITHM: BREADTH-FIRST SEARCH



 Create a variable called NODE-LIST and set it to the
  initial state.
 Loop until the goal state is found or NODE-LIST is
  empty.
   • Remove the first element, say E, from the NODE-
      LIST. If NODE-LIST was empty then quit.
   • For each way that each rule can match the state
      described in E do:
 - Apply the rule to generate a new state.
  - If the new state is the goal state, quit and return this
  state.
  - Otherwise add this state to the end of NODE-LIST
Advantages : BFS




 Breadth first search will never get trapped exploring the
  useless path forever.
 If there is a solution, BFS will definitely find it out.
 If there is more than one solution then BFS can find the
  minimal one that requires less number of steps.
Disadvantages :BFS


 The main drawback of Breadth first search is its
  memory requirement. Since each level of the tree must
  be saved in order to generate the next level, and the
  amount of memory is proportional to the number of
  nodes stored, the space complexity of BFS is O(bd).
 As a result, BFS is severely space-bound in practice so
  will exhaust the memory available on typical computers
  in a matter of minutes.
 If the solution is farther away from the root, breath first
  search will consume lot of time.
DEPTH FIRST SEARCH



 Depth First Search (DFS) searches deeper into the
  problem space.
 BFS always generates successor of the deepest
  unexpanded node.
 Depth First Search uses last-in first-out stack for
  keeping the unexpanded nodes.
 More commonly, depth-first search is implemented
  recursively, with the recursion stack taking the place of
  an explicit node stack.
ALGORITHM: DEPTH FIRST SEARCH


 If the initial state is a goal state, quit and return
  success.
 Otherwise, loop until success or failure is signalled.
  a) Generate a state, say E, and let it be the successor
  of the initial state. If there is no successor, signal
  failure.
  b) Call Depth-First Search with E as the initial state.
  c) If success is returned, signal success. Otherwise
  continue in this loop.
ADVANTAGES


 The advantage of depth-first Search is that memory
  requirement is only linear with respect to the search
  graph.
 The time complexity of a depth-first Search to depth d
  is O(b^d) since it generates the same set of nodes
  as BFS.
 If depth-first search finds solution without exploring
  much in a path then the time and space it takes will be
  very less.
DISADVANTAGES


 There is a possibility that it may go down the left-most
  path forever. Even a finite graph can generate an
  infinite tree.
 Depth-First Search is not guaranteed to find the
  solution.
 And there is no guarantee to find a minimal solution, if
  more than one solution exists.
Bidirectional Search


  The algorithms so far use forward reasoning, i.e.
   moving from the start node towards a goal node. some
   cases we could use backward reasoning, i.e. moving
   from the goal state to the start state.
 Forward and backward reasoning can be combined into
   a technique called bidirectional search.
  - One starting from the initial state and searching
   forward
 - One starting from the goal state and searching
   backward The search terminates when the two graphs
   intersect
Problems in Real World


   There are some toy searching that we’ll see
    this technique are used to solve some real world
    problems like:
   Route finding.(computer networks, airline travel
    planning system)
   Layout problems (VLSI layout, furniture layout,
    packaging)
   Assembly sequencing.(Assembly of electrical motors)
   Task Scheduling.(Time tables, manufacturing)
Water Jug Problem


 Consider the following problem:
          A Water Jug Problem: You are given two jugs, a
  4-gallon one and a 3-gallon one, a pump which has
  unlimited water which you can use to fill the jug, and
  the ground on which water may be poured. Neither jug
  has any measuring markings on it. How can you get
  exactly 2 gallons of water in the 4-gallon jug?
 State Representation and Initial State –

       We will represent a state of the problem as a tuple
  (x, y) where x represents the amount of water in the 4-
  gallon jug and y represents the amount of water in the
  3-gallon jug. Goal state as (2,y).
Production Rules


   (x,y)If x<4 -> (4,y)
   (x,y)If y<3 ->(x,3)
   (x,y)If x>0 ->(x-d,y)
   (x,y)If y>0 ->(x,y-d)
   (x,y)If x>0 ->(0,y)
   (x,y)If y>0 ->(x,0)
   (x,y)If(x+y>=4 and y>0) ->(4,y-(4-x))
   (x,y)If (x+y>=3 and x>0) ->(x-(3-y),3)
   (x,y)If(x+y<=4 and y>0) ->(x+y,0)
   (x,y)If (x+y<=3 and x>0) ->(0,x+y)
   (0,2)->(2,0)
Solution


               4 Gallon Jug   3 Gallon Jug

                     0             0          pump
                     4             0

                     1             3

                     1             0
4 Gallon jug         0             1         3 Gallon jug
                     4             1

                     2             3
Search Tree : Water Jug Problem



                        (0,0)


        (4,0)                           (0,3)



(4,3)   (0,0)   (1,3)           (4,3)   (0,0)   (3,0)
8 Puzzle Problem




   1    3        5   1   2        3

   2    7        4   4   5        6

   6             8   7   8



   Start State       Goal State
8 Puzzle Problem


  State space (S)
  Location of each of the 8 tiles(and the blank tile)
 Start State (s)

  Starting configuration
 Operators(O)

   Four Operators : Right, Left, Up, Down
 Goals(G)

   one of the goal configuration
8 Queen Problem


  Problem: Place 8 queens on a chess board so that none
   of them attack each other
 Formulation- I

 - A state is an arrangement of 0 to 8 queens on the
   board
 - Operators add a queen to any square.
 This formulation is not a systematic way to find the
   solution, it takes a long time to get the solution.
8 Queen Problem


    Formulation – II
    - A state is an arrangement of 0-8 queen with no one
     attacked.
    - Operators place a queen in the left most empty
     column.
    - More systematic than formulation-I
8 Queen Problem


    Formulation –III
     - A state is an arrangement of 8 queens on in each
     column.
    -Operators move an attacked queen to another square
     in the same column.
    -Keep on shuffling the queen until the goal is reached.
    - This formulation is more systematic hence , it is also
     called as Iterative Formulation.
8 Queen Problem : Solution
Missionaries and Cannibals


   Three missionaries and three cannibals find themselves
    on a side of river. They agreed to get to the other side
    of river. But missionaries are afraid of being eaten by
    cannibals so, the missionaries want to manage the trip
    in such a way that no. of missionaries on either side of
    the river is never less than the no. of cannibals on the
    same side. The boat is able to hold only 2 people at a
    time.
Missionaries and Cannibals


   State(#m,#c,1/0)
    #m – number of missionaries on first bank
    #c – number of cannibals on first bank

 The last bit indicate whether the boat is in the first
  bank.
 Operators

   • Boat carries (1,0) or (0,1) or (1,1) or (2,0) or (0,2)
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai
1 de 34

Recomendados

Informed and Uninformed search Strategies por
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search StrategiesAmey Kerkar
49.4K visualizações76 slides
Artificial Intelligence -- Search Algorithms por
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms Syed Ahmed
4.3K visualizações110 slides
Ai 8 puzzle problem por
Ai 8 puzzle problemAi 8 puzzle problem
Ai 8 puzzle problemSanad Bhowmik
2.4K visualizações13 slides
AI Lecture 3 (solving problems by searching) por
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)Tajim Md. Niamat Ullah Akhund
3.9K visualizações71 slides
Adversarial search por
Adversarial searchAdversarial search
Adversarial searchNilu Desai
4.2K visualizações39 slides
Uninformed Search technique por
Uninformed Search techniqueUninformed Search technique
Uninformed Search techniqueKapil Dahal
5.1K visualizações28 slides

Mais conteúdo relacionado

Mais procurados

Truth management system por
Truth  management systemTruth  management system
Truth management systemMohammad Kamrul Hasan
13.7K visualizações41 slides
A* Algorithm por
A* AlgorithmA* Algorithm
A* AlgorithmDr. C.V. Suresh Babu
3.1K visualizações15 slides
AI Lecture 4 (informed search and exploration) por
AI Lecture 4 (informed search and exploration)AI Lecture 4 (informed search and exploration)
AI Lecture 4 (informed search and exploration)Tajim Md. Niamat Ullah Akhund
1.6K visualizações55 slides
Hill climbing algorithm por
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithmDr. C.V. Suresh Babu
2.9K visualizações14 slides
Artificial Intelligence Notes Unit 1 por
Artificial Intelligence Notes Unit 1 Artificial Intelligence Notes Unit 1
Artificial Intelligence Notes Unit 1 DigiGurukul
16.3K visualizações216 slides
Adversarial search por
Adversarial searchAdversarial search
Adversarial searchDheerendra k
1K visualizações24 slides

Mais procurados(20)

Truth management system por Mohammad Kamrul Hasan
Truth  management systemTruth  management system
Truth management system
Mohammad Kamrul Hasan13.7K visualizações
Hill climbing algorithm por Dr. C.V. Suresh Babu
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
Dr. C.V. Suresh Babu2.9K visualizações
Artificial Intelligence Notes Unit 1 por DigiGurukul
Artificial Intelligence Notes Unit 1 Artificial Intelligence Notes Unit 1
Artificial Intelligence Notes Unit 1
DigiGurukul16.3K visualizações
Adversarial search por Dheerendra k
Adversarial searchAdversarial search
Adversarial search
Dheerendra k1K visualizações
Uninformed search /Blind search in AI por Kirti Verma
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
Kirti Verma1.1K visualizações
5 csp por Mhd Sb
5 csp5 csp
5 csp
Mhd Sb16.1K visualizações
First order logic por Rushdi Shams
First order logicFirst order logic
First order logic
Rushdi Shams12.4K visualizações
Reinforcement learning 7313 por Slideshare
Reinforcement learning 7313Reinforcement learning 7313
Reinforcement learning 7313
Slideshare13.7K visualizações
Lecture 16 memory bounded search por Hema Kashyap
Lecture 16 memory bounded searchLecture 16 memory bounded search
Lecture 16 memory bounded search
Hema Kashyap6.4K visualizações
Heuristic search-in-artificial-intelligence por grinu
Heuristic search-in-artificial-intelligenceHeuristic search-in-artificial-intelligence
Heuristic search-in-artificial-intelligence
grinu3.7K visualizações
Constraint satisfaction problems (csp) por Archana432045
Constraint satisfaction problems (csp)   Constraint satisfaction problems (csp)
Constraint satisfaction problems (csp)
Archana432045470 visualizações
Lecture 26 local beam search por Hema Kashyap
Lecture 26 local beam searchLecture 26 local beam search
Lecture 26 local beam search
Hema Kashyap8.1K visualizações
AI local search por Renas Rekany
AI local searchAI local search
AI local search
Renas Rekany7.1K visualizações
Hill climbing por Mohammad Faizan
Hill climbingHill climbing
Hill climbing
Mohammad Faizan67.9K visualizações
Water jug problem ai part 6 por Kirti Verma
Water jug problem ai part 6Water jug problem ai part 6
Water jug problem ai part 6
Kirti Verma2.3K visualizações
State Space Search in ai por vikas dhakane
State Space Search in aiState Space Search in ai
State Space Search in ai
vikas dhakane602 visualizações
Production system in ai por sabin kafle
Production system in aiProduction system in ai
Production system in ai
sabin kafle5.2K visualizações
Time and Space Complexity.pdf por Ashutosh Satapathy
Time and Space Complexity.pdfTime and Space Complexity.pdf
Time and Space Complexity.pdf
Ashutosh Satapathy1.3K visualizações

Destaque

State space search por
State space search State space search
State space search Timothy Makgato
5K visualizações7 slides
State Space Search(2) por
State Space Search(2)State Space Search(2)
State Space Search(2)luzenith_g
8.2K visualizações15 slides
Problems problem spaces and search por
Problems problem spaces and searchProblems problem spaces and search
Problems problem spaces and searchAmey Kerkar
12.5K visualizações18 slides
Knowledge Representation & Reasoning por
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & ReasoningSajid Marwat
18.9K visualizações34 slides
Predicate Logic por
Predicate LogicPredicate Logic
Predicate Logicgiki67
42.1K visualizações71 slides
Frames por
FramesFrames
Framesamitp26
24K visualizações17 slides

Destaque(9)

State space search por Timothy Makgato
State space search State space search
State space search
Timothy Makgato5K visualizações
State Space Search(2) por luzenith_g
State Space Search(2)State Space Search(2)
State Space Search(2)
luzenith_g8.2K visualizações
Problems problem spaces and search por Amey Kerkar
Problems problem spaces and searchProblems problem spaces and search
Problems problem spaces and search
Amey Kerkar12.5K visualizações
Knowledge Representation & Reasoning por Sajid Marwat
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
Sajid Marwat18.9K visualizações
Predicate Logic por giki67
Predicate LogicPredicate Logic
Predicate Logic
giki6742.1K visualizações
Frames por amitp26
FramesFrames
Frames
amitp2624K visualizações
Knowledge representation and Predicate logic por Amey Kerkar
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
Amey Kerkar69.7K visualizações
Issues in knowledge representation por Sravanthi Emani
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representation
Sravanthi Emani60.1K visualizações
Heuristic Search Techniques {Artificial Intelligence} por FellowBuddy.com
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com32.6K visualizações

Similar a (Radhika) presentation on chapter 2 ai

Artificial intelligent Lec 3-ai chapter3-search por
Artificial intelligent Lec 3-ai chapter3-searchArtificial intelligent Lec 3-ai chapter3-search
Artificial intelligent Lec 3-ai chapter3-searchTaymoor Nazmy
56 visualizações53 slides
unit 2.pptx por
unit 2.pptxunit 2.pptx
unit 2.pptxGavy11
9 visualizações112 slides
Artificial Intelligence por
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceJay Nagar
1K visualizações19 slides
Lecture 2 por
Lecture 2Lecture 2
Lecture 2chandsek666
3.7K visualizações56 slides
Artificial Intelligence_Searching.pptx por
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxRatnakar Mikkili
9 visualizações18 slides
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch por
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearchJarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearchPalGov
537 visualizações87 slides

Similar a (Radhika) presentation on chapter 2 ai(20)

Artificial intelligent Lec 3-ai chapter3-search por Taymoor Nazmy
Artificial intelligent Lec 3-ai chapter3-searchArtificial intelligent Lec 3-ai chapter3-search
Artificial intelligent Lec 3-ai chapter3-search
Taymoor Nazmy56 visualizações
unit 2.pptx por Gavy11
unit 2.pptxunit 2.pptx
unit 2.pptx
Gavy119 visualizações
Artificial Intelligence por Jay Nagar
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Jay Nagar1K visualizações
Lecture 2 por chandsek666
Lecture 2Lecture 2
Lecture 2
chandsek6663.7K visualizações
Artificial Intelligence_Searching.pptx por Ratnakar Mikkili
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
Ratnakar Mikkili9 visualizações
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch por PalGov
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearchJarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
PalGov537 visualizações
SP14 CS188 Lecture 2 -- Uninformed Search.pptx por AnimeGuru1
SP14 CS188 Lecture 2 -- Uninformed Search.pptxSP14 CS188 Lecture 2 -- Uninformed Search.pptx
SP14 CS188 Lecture 2 -- Uninformed Search.pptx
AnimeGuru163 visualizações
Amit ppt por amitp26
Amit pptAmit ppt
Amit ppt
amitp267.9K visualizações
Problem space por harman_sekhon
Problem spaceProblem space
Problem space
harman_sekhon580 visualizações
Problem space por harman_sekhon
Problem spaceProblem space
Problem space
harman_sekhon850 visualizações
Problem space por harman_sekhon
Problem spaceProblem space
Problem space
harman_sekhon7.9K visualizações
l2.pptx por AnujaBeatriceB
l2.pptxl2.pptx
l2.pptx
AnujaBeatriceB2 visualizações
CptS 440 / 540 Artificial Intelligence por butest
CptS 440 / 540 Artificial IntelligenceCptS 440 / 540 Artificial Intelligence
CptS 440 / 540 Artificial Intelligence
butest1.1K visualizações
CS767_Lecture_02.pptx por ShujatHussainGadi
CS767_Lecture_02.pptxCS767_Lecture_02.pptx
CS767_Lecture_02.pptx
ShujatHussainGadi11 visualizações
State Space Representation and Search por Hitesh Mohapatra
State Space Representation and SearchState Space Representation and Search
State Space Representation and Search
Hitesh Mohapatra31.7K visualizações
AI_Session 11: searching with Non-Deterministic Actions and partial observati... por Asst.Prof. M.Gokilavani
AI_Session 11: searching with Non-Deterministic Actions and partial observati...AI_Session 11: searching with Non-Deterministic Actions and partial observati...
AI_Session 11: searching with Non-Deterministic Actions and partial observati...
Asst.Prof. M.Gokilavani1.5K visualizações
State space search and Problem Solving techniques por Kirti Verma
State space search and Problem Solving techniquesState space search and Problem Solving techniques
State space search and Problem Solving techniques
Kirti Verma1.2K visualizações

(Radhika) presentation on chapter 2 ai

  • 1. CHAPTER - 2 Problem Spaces and P roblem Solving by Searching Presented By : Radhika Srinivasan PG Roll No : 45
  • 2. What we will learn today …  What is Problem Spaces?  How to Search to get solutions?  Using Different searching algorithms i.e. basically used in AI  Some Toy problems and Real world problems
  • 3. Introduction Now, we’ll study about what are the kinds of problems where the AI is concerned and the technique that is used to solve those problems. There are 4 things concerned to solve a particular problem.  Define the problem precisely.  Analyze the problem.  Isolate and represent the task knowledge i.e. required to solve the problem.  Finally, choose the best problem solving technique and apply to the particular problem.
  • 4. Areas  Problem Solving -Puzzles -Play games, e.g chess -Symbolic integration of mathematical formulas. -Some programs can improve their performance with experience  Logical reasoning – Prove assertions (theorems) by manipulating a database of facts
  • 5. Areas  Language – Understanding of natural language – Translation – E.g. Spelling checker  Programming – Write computer programs based on a description  Systems and languages – Time-sharing, list processing, and interactive debugging were developed in the AI research
  • 6. What is problem space ?  Problem space is a set of states and the connections between to represent the problem. Problem space graph is used to represent a problem space. In the graph, the states are represented by nodes of the graph, and the operators by edges between nodes.  For simplicity they are often represented as trees, where the initial state is the root of the tree. The cost of the simplification is that any state that can be reached by two different paths will be represented by duplicate nodes thereby increasing the tree size. The benefit of using tree is that the absence of cycles greatly simplifies many search algorithms.
  • 7. Search  State Space and Problem Reduction – State space  An operator produces exactly one new state – Problem reduction  An operator produces a set of sub problems, each of which have to be solved. - E.g. Tower of Hanoi
  • 8. Search - problem representation  State space graph  It is represented like nodes and edges where initial state to the goal state. It can also represent as tree graph.
  • 9. Search Strategy  A strategy is defined by picking the order of node expansion. Strategy is evaluated among the following dimensions.  Completeness- does it always find a solution if one exists?  Time complexity- no. of nodes generated.  Space complexity- max no. of nodes in memory.  Optimality- does it always find least cost solution?  Time and space is measured in ‘b’ – max branching factor of search tree. ‘d’- depth of least cost solution. ‘m’ – max depth of the state space may be (infinite)
  • 10. Which are the Search Types ?  Blind search algorithms are as follows:  In blind search the number of nodes can be extremely large, The order of expanding the nodes is arbitrary - Breadth First Search - Depth First Search  Heuristic search - Ordered Search - A* An optimal search  Consider State space graph as general graph i.e. nodes and points. Graphs can be directed undirected or mixed graph.
  • 11. Breadth-First Search  Breadth First Search (BFS) searches breadth-wise in the problem space. Breadth-First search is like traversing a tree where each node is a state which may a be a potential candidate for solution.  Breadth first search expands nodes from the root of the tree and then generates one level of the tree at a time until a solution is found. It is very easily implemented by maintaining a queue of nodes.  Initially the queue contains just the root. In each iteration, node at the head of the queue is removed and then expanded. The generated child nodes are then added to the tail of the queue.
  • 12. ALGORITHM: BREADTH-FIRST SEARCH  Create a variable called NODE-LIST and set it to the initial state.  Loop until the goal state is found or NODE-LIST is empty. • Remove the first element, say E, from the NODE- LIST. If NODE-LIST was empty then quit. • For each way that each rule can match the state described in E do:  - Apply the rule to generate a new state. - If the new state is the goal state, quit and return this state. - Otherwise add this state to the end of NODE-LIST
  • 13. Advantages : BFS  Breadth first search will never get trapped exploring the useless path forever.  If there is a solution, BFS will definitely find it out.  If there is more than one solution then BFS can find the minimal one that requires less number of steps.
  • 14. Disadvantages :BFS  The main drawback of Breadth first search is its memory requirement. Since each level of the tree must be saved in order to generate the next level, and the amount of memory is proportional to the number of nodes stored, the space complexity of BFS is O(bd).  As a result, BFS is severely space-bound in practice so will exhaust the memory available on typical computers in a matter of minutes.  If the solution is farther away from the root, breath first search will consume lot of time.
  • 15. DEPTH FIRST SEARCH  Depth First Search (DFS) searches deeper into the problem space.  BFS always generates successor of the deepest unexpanded node.  Depth First Search uses last-in first-out stack for keeping the unexpanded nodes.  More commonly, depth-first search is implemented recursively, with the recursion stack taking the place of an explicit node stack.
  • 16. ALGORITHM: DEPTH FIRST SEARCH  If the initial state is a goal state, quit and return success.  Otherwise, loop until success or failure is signalled. a) Generate a state, say E, and let it be the successor of the initial state. If there is no successor, signal failure. b) Call Depth-First Search with E as the initial state. c) If success is returned, signal success. Otherwise continue in this loop.
  • 17. ADVANTAGES  The advantage of depth-first Search is that memory requirement is only linear with respect to the search graph.  The time complexity of a depth-first Search to depth d is O(b^d) since it generates the same set of nodes as BFS.  If depth-first search finds solution without exploring much in a path then the time and space it takes will be very less.
  • 18. DISADVANTAGES  There is a possibility that it may go down the left-most path forever. Even a finite graph can generate an infinite tree.  Depth-First Search is not guaranteed to find the solution.  And there is no guarantee to find a minimal solution, if more than one solution exists.
  • 19. Bidirectional Search  The algorithms so far use forward reasoning, i.e. moving from the start node towards a goal node. some cases we could use backward reasoning, i.e. moving from the goal state to the start state.  Forward and backward reasoning can be combined into a technique called bidirectional search. - One starting from the initial state and searching forward - One starting from the goal state and searching backward The search terminates when the two graphs intersect
  • 20. Problems in Real World  There are some toy searching that we’ll see this technique are used to solve some real world problems like:  Route finding.(computer networks, airline travel planning system)  Layout problems (VLSI layout, furniture layout, packaging)  Assembly sequencing.(Assembly of electrical motors)  Task Scheduling.(Time tables, manufacturing)
  • 21. Water Jug Problem  Consider the following problem: A Water Jug Problem: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which has unlimited water which you can use to fill the jug, and the ground on which water may be poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug?  State Representation and Initial State – We will represent a state of the problem as a tuple (x, y) where x represents the amount of water in the 4- gallon jug and y represents the amount of water in the 3-gallon jug. Goal state as (2,y).
  • 22. Production Rules  (x,y)If x<4 -> (4,y)  (x,y)If y<3 ->(x,3)  (x,y)If x>0 ->(x-d,y)  (x,y)If y>0 ->(x,y-d)  (x,y)If x>0 ->(0,y)  (x,y)If y>0 ->(x,0)  (x,y)If(x+y>=4 and y>0) ->(4,y-(4-x))  (x,y)If (x+y>=3 and x>0) ->(x-(3-y),3)  (x,y)If(x+y<=4 and y>0) ->(x+y,0)  (x,y)If (x+y<=3 and x>0) ->(0,x+y)  (0,2)->(2,0)
  • 23. Solution 4 Gallon Jug 3 Gallon Jug 0 0 pump 4 0 1 3 1 0 4 Gallon jug 0 1 3 Gallon jug 4 1 2 3
  • 24. Search Tree : Water Jug Problem (0,0) (4,0) (0,3) (4,3) (0,0) (1,3) (4,3) (0,0) (3,0)
  • 25. 8 Puzzle Problem 1 3 5 1 2 3 2 7 4 4 5 6 6 8 7 8 Start State Goal State
  • 26. 8 Puzzle Problem  State space (S) Location of each of the 8 tiles(and the blank tile)  Start State (s) Starting configuration  Operators(O) Four Operators : Right, Left, Up, Down  Goals(G) one of the goal configuration
  • 27. 8 Queen Problem  Problem: Place 8 queens on a chess board so that none of them attack each other  Formulation- I - A state is an arrangement of 0 to 8 queens on the board - Operators add a queen to any square.  This formulation is not a systematic way to find the solution, it takes a long time to get the solution.
  • 28. 8 Queen Problem  Formulation – II - A state is an arrangement of 0-8 queen with no one attacked. - Operators place a queen in the left most empty column. - More systematic than formulation-I
  • 29. 8 Queen Problem  Formulation –III - A state is an arrangement of 8 queens on in each column. -Operators move an attacked queen to another square in the same column. -Keep on shuffling the queen until the goal is reached. - This formulation is more systematic hence , it is also called as Iterative Formulation.
  • 30. 8 Queen Problem : Solution
  • 31. Missionaries and Cannibals  Three missionaries and three cannibals find themselves on a side of river. They agreed to get to the other side of river. But missionaries are afraid of being eaten by cannibals so, the missionaries want to manage the trip in such a way that no. of missionaries on either side of the river is never less than the no. of cannibals on the same side. The boat is able to hold only 2 people at a time.
  • 32. Missionaries and Cannibals  State(#m,#c,1/0) #m – number of missionaries on first bank #c – number of cannibals on first bank  The last bit indicate whether the boat is in the first bank.  Operators • Boat carries (1,0) or (0,1) or (1,1) or (2,0) or (0,2)