0% found this document useful (0 votes)
5 views32 pages

AI lect4

The document discusses problem solving through searching, outlining the components of a search problem, including state space, start state, and goal state. It details various uninformed search algorithms, such as breadth-first search and depth-first search, along with their advantages and disadvantages. Additionally, it covers performance metrics for search algorithms and introduces iterative deepening as a hybrid approach.

Uploaded by

Hafiz Mizfar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views32 pages

AI lect4

The document discusses problem solving through searching, outlining the components of a search problem, including state space, start state, and goal state. It details various uninformed search algorithms, such as breadth-first search and depth-first search, along with their advantages and disadvantages. Additionally, it covers performance metrics for search algorithms and introduces iterative deepening as a hybrid approach.

Uploaded by

Hafiz Mizfar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

WEEK 04

PROBLEM SOLVING BY SEARCHING


PROBLEM SOLVING - SEARCHING

• Most of the time, these agents perform some kind of search


algorithm in the background in order to achieve their tasks.
• A search problem consists of:

• A State Space. Set of all possible states where you can be.
• A Start State. The state from where the search begins.
• A Goal State. A function that looks at the current state returns
whether or not it is the goal state.
PRELIMINARIES
We need to define two things:

• Goal Formulation
 Define objectives

• Problem Formulation
 Define actions and states
PROBLEM FORMULATION

Four components:

1. The initial state


2. Actions (successor function)
3. Goal test
4. Path Cost
PROBLEM SOLVING BY SEARCHING

• The Solution to a search problem is a sequence of actions,


called the plan that transforms the start state to the goal
state.
• This plan is achieved through search algorithms.
TYPES OF SEARCH ALGORITHMS:
UNINFORMED SEARCH ALGORITHMS:

• Uninformed search is one in which the search systems do not use any clues about the
suitable area but it depend on the random nature of search.
• they begins the exploration of search space (all possible solutions) synchronously,
• The search operation begins from the initial state and providing all possible next
steps arrangement until goal is reached.
• These are mostly the simplest search strategies, but they may not be suitable for
complex paths
• These algorithms are necessary for solving basic tasks or providing simple processing
before passing on the data to more advanced search algorithms that incorporate
prioritized information.
UNINFORMED SEARCH ALGORITHMS:

• Following are the various types of uninformed search algorithms:


• Breadth-first Search
• Depth-first Search
• Depth-limited Search
• Iterative deepening depth-first search
• Uniform cost search
• Bidirectional Search
1. BREADTH-FIRST SEARCH:

• Breadth-first search is the most common search strategy for traversing a


tree or graph. This algorithm searches breadthwise in a tree or graph, so it
is called breadth-first search.
• BFS algorithm starts searching from the root node of the tree and expands
all successor node at the current level before moving to nodes of next
level.
• The breadth-first search algorithm is an example of a general-graph search
algorithm.
• Breadth-first search implemented using FIFO queue data structure.
EXAMPLE
OTHER EXAMPLES

Toy Problems:

 Vacuum World
 8-puzzle
 8-queens problem
BREADTH-FIRST SEARCH:

ADVANTAGES: DISADVANTAGES:

• BFS will provide a solution if any solution exists. • It requires lots of memory since each level of
• If there are more than one solutions for a given the tree must be saved into memory to
problem, then BFS will provide the minimal solution expand the next level.
which requires the least number of steps.
• It also helps in finding the shortest path in goal state,
• BFS needs lots of time if the solution is far
since it needs all nodes at the same hierarchical level away from the root node.
before making a move to nodes at lower levels. • It can be very inefficient approach for
• It is also very easy to comprehend with the help of searching through deeply layered spaces, as
this we can assign the higher rank among path types. it needs to thoroughly explore all nodes at
each level before moving on to the next
BREADTH-FIRST SEARCH:
BFS
VACCUM CLEANER
8-QUEENS PROBLEM
OTHER EXAMPLES

Real Problems

 Route-Finding Problem
 Robot Navigation
 Automatic Assembly Sequencing
 Protein Design
 Internet Searching
SOLUTIONS

• We search through a search tree


• We expand new nodes to grow the tree
• There are different search strategies
• Nodes contain the following:
 state
 parent node
 action
 path cost
 depth
SEARCH TREE

Initial state

Expanded nodes
PERFORMANCE

Four elements of performance:

• Completeness (guaranteed to find solution)


• Optimality (optimal solution?)
• Time Complexity
• Space Complexity
PERFORMANCE

Complexity requires three elements:

a. Branching factor b
b. Depth of the shallowest node d
c. Maximum length of any path m
PROBLEM SOLVING BY SEARCHING

• Introduction
• Solutions and Performance
• Uninformed Search Strategies
• Avoiding Repeated States
• Partial Information
• Summary
BREADTH-FIRST SEARCH

• Root is expanded first


• Then all successors at level 2.
• Then all successors at level 3, etc.

Properties:
 Complete (if b and d are finite)
 Optimal (if path cost increases with depth)
 Cost is O(bd+1)
SEARCH
UNIFORM-COST SEARCH

• Like breadth-first search


• Expand node with lowest path cost.

Properties:
 Complete (if b and d are finite)
 Optimal (if path cost increases with depth)
 Cost is O(b c*/e)
 Could be worse than breadth first search
SEARCH
DEPTH-FIRST SEARCH

• Expand the deepest node at the bottom


of the tree.
Backtracking even does
Properties: better spacewise: O(m)
 Incomplete
 suboptimal
Only store the nodes on
 Space complexity is only O(bm)
the current path including
their unexpanded sibling nodes
SEARCH
DEPTH-LIMITED

• Like depth-first search but with


depth limit L.

Properties:
 Incomplete (if L < d)
 nonoptimal (if L > d)
 Time complexity is O(bL)
 Space complexity is O(bL)
Parameters BFS DFS

Stands for BFS stands for Breadth First Search. DFS stands for Depth First Search.

BFS(Breadth First Search) uses Queue data DFS(Depth First Search) uses Stack data
Data Structure structure for finding the shortest path. structure.

DFS is also a traversal approach in which the


BFS is a traversal approach in which we first traverse begins at the root node and
Definition walk through all nodes on the same level
before moving on to the next level.
proceeds through the nodes as far as
possible until we reach the node with no
unvisited nearby nodes.

Conceptual Difference BFS builds the tree level by level. DFS builds the tree sub-tree by sub-tree.

It works on the concept of FIFO (First In First It works on the concept of LIFO (Last In First
Approach used Out). Out).

BFS is more suitable for searching vertices DFS is more suitable when there are
Suitable for closer to the given source. solutions away from source.

DFS is used in various applications such as


BFS is used in various applications such as
acyclic graphs and finding strongly
bipartite graphs, shortest paths, etc. If
connected components etc. There are many
Applications weight of every edge is same, then BFS
gives shortest pat from source to every
applications where both BFS and DFS can be
used like Topological Sorting, Cycle
other vertex.
Detection, etc.
ITERATIVE DEEPENING

• A combination of depth and breadth-first


search.
• Gradually increases the limit L

Properties:
 Complete (if b and d are finite)
 Optimal if path cost increases with depth
 Time complexity is O(bd)
SEARCH

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy