Uninformed Search

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

PROBLEM SOLVING AGENTS

STEPS FOLLOWED
▪ Goal Formulation:
⮚It is the first and simplest step in problem-solving.

⮚ It organizes the steps/sequence required to formulate one goal out of multiple goals as
well as actions to achieve that goal.

⮚Goal formulation is based on the current situation and the agent’s performance measure

▪ Problem Formulation:
⮚ It is the most important step of problem-solving which decides what actions should be
taken to achieve the formulated goal.

⮚ There are five components involved in problem formulation 3/21/2024 2


PROBLEM FORMULATION-
COMPONENTS
▪ Initial State: Starting state or initial step of the agent towards its goal.

▪ Actions: Description of the possible actions available to the agent.

▪ Transition Model: Describes what each action does.

▪ Goal Test: Determines if the given state is a goal state.

▪ Path cost: It assigns a numeric cost to each path that follows the goal. The problem-solving agent
selects a cost function, which reflects its performance measure.

▪ Optimal solution: Lowest path cost among all the solutions.


3/21/2024 3
HOLIDAY IN ROMANIA

Formulate Goal: be in Bucharest


Formulate Problem:
States: Various cities
Action: Drive between cities
Find Solution:
Sequence of cities.
Eg: Arad, Sibiu, Fagaras, Bucharest

3/21/2024 4
TWO TYPES OF PROBLEM
APPROACHES
▪ Toy Problem: It is a concise and exact description of the problem which is used by
the researchers to compare the performance of algorithms.

Eg: Number Slider Problem, N-Queens Problem

▪ Real-world Problem: It is real-world based problems which require solutions. Unlike


a toy problem, it does not depend on descriptions, but we can have a general
formulation of the problem.

Eg: Travelling Salesman Problem, VLSI Layout Problem


3/21/2024 5
EXAMPLE: N-QUEENS
PROBLEM
For this problem, there are two main kinds of formulation:
1. Incremental formulation: It starts from an empty state where the operator augments a queen at
each step.
Following steps are involved in this formulation:
▪ States: Arrangement of any 0 to 8 queens on the chessboard.
▪ Initial State: An empty chessboard
▪ Actions: Add a queen to any empty box.
▪ Transition model: Returns the chessboard with the queen added in a box.
▪ Goal test: Checks whether 8-queens are placed on the chessboard without any attack.
▪ Path cost: There is no need for path cost because only final states are counted.

In this formulation, there is approximately 1.8 x 1014 possible sequence to investigate.


3/21/2024 6
EXAMPLE: N-QUEENS
PROBLEM
2. Complete-state formulation: It starts with all the 8-queens on the chessboard and moves them
around, saving from the attacks.

Following steps are involved in this formulation

▪ States: Arrangement of all the 8 queens one per column with no queen attacking the other queen.

▪ Actions: Move the queen at the location where it is safe from the attacks.

This formulation is better than the incremental formulation as it reduces the state space from 1.8 x
1014 to 2057 , and it is easy to find the solutions.
3/21/2024 7
SEARCH TECHNIQUES
Search: Step by step procedure to solve a search-problem in a given search space. A
search problem can have three main factors:

1.Search Space: Search space represents a set of possible solutions, which a system
may have.

2.Start State: It is a state from where agent begins the search.

3.Goal test: It is a function which observe the current state and returns whether the goal
state is achieved or not.
3/21/2024 8
PROBLEM’S STATE-SPACE
▪ State-space of a problem-Set of all states which can be reached from the initial state
followed by any sequence of actions.

▪ Directed map or graph where nodes are the states, links between the nodes are actions,
and the path is a sequence of states connected by the sequence of actions.

3/21/2024 9
MEASURING PROBLEM-
SOLVING PERFORMANCE
There are four ways to measure the performance of an algorithm:
▪ Completeness: It measures if the algorithm guarantees to find a solution
(if any solution exist).
▪ Optimality: It measures if the strategy searches for an optimal solution.
▪ Time Complexity: The time taken by the algorithm to find a solution.
▪ Space Complexity: Amount of memory required to perform a search.

The complexity of an algorithm depends on branching factor, depth of the shallowest


goal node and the maximum length of any path in a state space.

3/21/2024 10
TYPES OF SEARCH STRATEGIES

• Breadth-first search
• Uniform-cost search
• Depth-first search
Uninformed • Depth-limited search
search • Iterative deepening depth-first search
• Bidirectional search

• Greedy best-first search


• A* search
Informed • Memory-bounded heuristic search
search

3/21/2024 11
BREADTH-FIRST SEARCH
( BFS )
▪ Expand shallowest unexpanded node first
▪ Frontier is a FIFO Queue

3/21/2024 12
3/21/2024 13
BFS - PSEUDOCODE

3/21/2024 14
BFS- PROPERTIES
▪Complete? Yes (if b is finite)

▪Time? 1+b+b2+b3+… +bd + b(bd-1) = O(bd+1)

▪Space? O(bd+1) (keeps every node in memory)

▪Optimal? Yes (if cost = 1 per step)

▪ Space complex than Time Complex


3/21/2024 15
UNIFORM-COST SEARCH ( UCS )
▪ Expand least cost unexpanded node first
▪ Frontier is a Priority Queue ordered by Path
cost
▪ Equivalent to BFS if all step-costs = 1
▪ Goal test performed when selected for expanding
whereas in BFS performed when generated.

3/21/2024 16
UCS - PSEUDOCODE

3/21/2024 17
UCS- PROPERTIES
▪ Complete? Guaranteed only if all the step costs are positive

▪ Time? O(b^[1+(C*/ e)]) C* - optimal path cost, e- step cost

▪ Space? O(b^[1+(C*/ e)])) (keeps every node in memory)

▪ Optimal? Yes (if cost = least at each step)

▪ UCS is worse than BFS in both Space & Time Complexity

▪ Opt only if path cost differs & is non-decreasing


3/21/2024 18
DEPTH-FIRST SEARCH ( DFS )

▪ Expand deepest unexpanded node first


▪ Frontier is a LIFO Queue, i.e. Put
successor nodes first

3/21/2024 19
DFS- PROPERTIES

▪Complete? Complete in finite spaces and incomplete in infinite-depth 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 ( the number of steps & cost spent in reaching the solution is high )

3/21/2024 20
DEPTH-LIMITED SEARCH
( DLS )
▪ A depth-limited search algorithm is similar to depth-first search with a predetermined
limit.
▪ Depth-limited search can solve the drawback of the infinite path in the Depth-first
search. In this algorithm, the node at the depth limit will treat as it has no successor
nodes further.

Expands nodes only if depth d<= L

3/21/2024 21
DLS - PSEUDOCODE

3/21/2024 22
DLS- PROPERTIES
▪Complete? No, if L<=d

▪ Time? O(b^L)

▪Space? O(bL)

▪Optimal? No, if L<=d

3/21/2024 23
ITERATIVE DEEPENING
DEPTH-FIRST SEARCH ( IDS )
▪ What if solution is deeper than L?
▪ Increase L iteratively
▪ Solves both infinite depth problem & optimality problem in DFS & DLS

3/21/2024 24
3/21/2024 25
IDS/ IDLS- PROPERTIES
▪Complete? Yes, Increases depth iteratively till goal reached

▪ Time? O(b^d)

▪Space? O(bd)

▪Optimal? Yes, if step cost=1 or increases depth function

Actually faster than breadth-first search!


It does better because other nodes at depth d are not expanded

3/21/2024 26
SUMMARY OF UNINFORMED
SEARCH STRATEGIES

3/21/2024 27
BIDIRECTIONAL SEARCH
▪ Runs two simultaneous searches, one form initial state called as forward-search and other from
goal node called as backward-search, to find the goal node.
▪ Replaces one single search graph with two small subgraphs in which one starts the search from an
initial vertex and other starts from goal vertex.
▪ The search stops when these two graphs intersect each other.
▪ Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Advantages:
• Bidirectional search is fast.
• Bidirectional search requires less memory
Disadvantages:
• Implementation of the bidirectional search tree is difficult.
• In bidirectional search, one should know the goal state in advance.
3/21/2024 28
BIDIRECTIONAL SEARCH

3/21/2024 29
BDS- PROPERTIES
▪ Complete? Yes, if BFS used in both searches

▪ Time? O(b^(d/2))

▪ Space? O(b^(d/2})

▪ Optimal? Yes, if BFS used in both searches & paths have uniform cost

BFS detects duplicate nodes while DFS fails

3/21/2024 30

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