0% found this document useful (0 votes)
4 views

Unit 2 Searching methods (1)

The document provides an overview of problem-solving techniques and searching methods in artificial intelligence, including uninformed and informed search algorithms. It discusses state space representation, production systems, and various search strategies such as breadth-first search, depth-first search, and heuristic methods like A* and hill climbing. Additionally, it outlines properties of search algorithms, applications, and challenges faced in problem-solving.

Uploaded by

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

Unit 2 Searching methods (1)

The document provides an overview of problem-solving techniques and searching methods in artificial intelligence, including uninformed and informed search algorithms. It discusses state space representation, production systems, and various search strategies such as breadth-first search, depth-first search, and heuristic methods like A* and hill climbing. Additionally, it outlines properties of search algorithms, applications, and challenges faced in problem-solving.

Uploaded by

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

Unit 2

Problem Solving Searching Methods


01 Problem Solving Techniques

02 Properties of searching algorithm

Overview 03 Types of search algorithms

04 Uninformed search algorithms

05 Informed search algorithms


01
Representation of Problem
01 State Space Representation
States
Operators
Initial State
Goal State
02 Production System
If a problem is not easily solvable, then we check that if the
problem can be decomposed into smaller sub problems
AND-OR Graph
02
Steps to be followed in PS
04
02
Choose the best
Analyzing the Problem
solution

Define the Problem Identifying Solutions Implement


03 the solution
01
05
03
Problem Solving Techniques
State Space Search
Problem Reduction Uninformed Search
Search Methods Breadth First Search
Informed Search Depth First Search
Best First Search Uniform Cost Search
Hill Climbing Iterative Deepening
Greedy Search Depth First Search
AO* and A*Search
Means and End Analysis
Constrainst Satisfaction Problem
04
State Space Search
State Space Search is used in AI to find the solution path from the
initial state to the goal state by exploring the various states
Used in various applications like game-playing algorithms to natural
language processing
The efficiency of the search algorithm depends on
Size of the state space
Choose an appropriate representation and
Search strategy to search the state space efficiently
05
Properties of State Space Search

Completeness: Exhaustiveness
If a solution exists, state space
search will find it
01 02 Explores all possible states of a
problem to find a solution

Optimality: Informed/Uninformed Search


Best amongst all the solutions
which are possible for the given 03 04 provides additional information
about the problem or guide the
problem. search process
06 Steps in State Space Search
07
State Space Representation
State
Initial State, a Goal State, or any other possible state
Space
Exhaustive collection of all conceivable states.
Search
Moves from the beginning state to the desired state by applying
set of rules
Search Tree
A tree-like structure that represents the problem
Transition Model - What each action performed and optimal cost
Example
08
09
Applications
Robotics
Planning robot motion and finding the best sequence of actions to achieve a goal
Game playing
Determine the best move for a player given a particular game state
Computer networks and Operations research
Optimize routing and resource allocation
Bioinformatics
Find patterns in biological data and predict protein structures
Cryptography
Break codes and find cryptographic keys
Supply chain management
10
Production System
01 A set of Rules

Each rule is written in such a way that each has left hand side which
shows the condition to be matched and the right-hand side which
describes the operation to be performed if the condition matches

02 Control Strategy

It provides the way and the order in which rules will be compared to the
Knowledge database and it also describes the way of resolving the conflicts
that may arise in case left-hand side of many rules match.
11
Production System
03 Rule Applier

Once the left side of the rule gets match at a particular state and the
control strategy resolves the conflicts if there are, the rule is fired using
rule applier.

04 Knowledge Database

This is a collection of facts and information that the production system can
use to make decisions.
12 Example

Let us consider that the Initial state of a problem to be BADCCB and Goal State is
ABBCCD.
The set of rules are as follows (notice they are written as Left-Hand side (IF) and
Right Hand Side (Then Condition).
1) BA AB
2) DC CD
3) CB BC
4) DB BD
13 Working of Prodution Rules
14 Water Jug 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?

Here the initial state is (0, 0). The goal state is (2, n) for any value of n.
15 Water Jug Problem

State Space Representation:

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. Note that 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3

We can fill a jug from the pump.


We can pour water out of a jug to the ground.
We can pour water from one jug to another.
There is no measuring device available.
16 Production rules
17
State Space Representation - Water Jug Problem
18 Missinaries Cannibles Problem

In the missionaries and cannibals problem, 3 missionaries and 3 cannibals


must cross a river using a boat which can carry at most 2 people, under the
constraint that, for both banks, if there are missionaries present on the
bank, they cannot be outnumbered by cannibals (if they were, the
cannibals would eat the missionaries). The boat cannot cross the river by
itself with no people on board.
19
Properties of Problem Solving

Completeness: Time Complexity


If a solution exists, state space
search will find it
01 02 Amount of time taken by an
algorithm to find the solution

Optimality: Space Complexity


Best amongst all the solutions
which are possible for the given 03 04 Amount of space that the algorithm
will use during the search for the
problem. solution
Search in Problem Solving

States
Initial State 01 02 Transition Model
Goal State

Actions 03 04 Cost Function


Types of Problem

Standardised Problem
Grid Problem
Vacuum Cleaner System
8-Puzzle
Real World Problem
Route Finding
Touring Problem
Robot Navigation
VLSI Design
States (Set of states and actions between states) and Search Tree (Path
between states to reach goal)
20 Uninformed Search

Used to find the solutions to the problem which does not have any
domain knowledge associated with it.

It is used in Artificial Intelligence to find relevant solutions by


exploring all the possibility sets of the problem space.

Uses heuristics to improve the efficiency and speed of the search.


To explore all the neighboring states or
nodes of the initial node
Queue data structure is used
Crawlers in search engine, GPS Navigation,
Broadcasting in networking are applications
of BFS
Time and Space Complexity = b^d ;
Breadth First b= branching factor and d = depth
Algorithm
Search 1. Take an Empty Queue.
2. Select a starting node and insert it into the
Queue.
3. Provided that the Queue is not empty,
extract the node from the Queue and insert
its child nodes (exploring a node) into the
Queue.
4. Print the extracted node.
21
22
To visit the next node, pop the top node from
the stack and push all of its nearby nodes
into a stack.
Topological sorting, scheduling problems,
Depth First graph cycle detection, and solving puzzles
Search with just one solution, such as a maze or a
sudoku puzzle, all employ depth-first search
algorithms.
Time Complexity: O(b^d)
Space Complexity: O(bd)
23
24
Depth-limited DFS (DLDFS) runs just as DFS
but with an additional stopping criterion.
if l=d, where d is the depth of the target
node closest to the start , then DLDFS will
Depth Limited find the shortest path.
DFS if l<d, then DLDFS will not be able to reach
it.
if l>d , then DLDFS may find a suboptimal
path to a target node
26
27 Iterative Deepening

Combination of DFS and BFS algorithms.


Finds out the best depth limit and does it by gradually increasing the
limit until a goal is found.
It performs depth-first search up to a certain "depth limit" and it keeps
increasing the depth limit after each iteration until the goal node is
found.
Useful uninformed search when search space is large and depth of goal
node is unknown.
Iterative Deepening = BFS (fast search) +DFS (memory-efficiency)
The main drawback of IDDFS is that it repeats all the work of the
previous phase.
28 Algorithm

bool DLS(src, target, limit)


if (src == target)
bool IDDFS(src, target, max_depth) return true;
for limit from 0 to max_depth if (limit <= 0)
if DLS(src, target, limit) == true return false;
return true; for each adjacent i of src
return false; if DLS(i, target, limit?1)
return true ;
return false;
•There can be two cases-
29 a)When the graph has no cycle
We can use DFS multiple times with different height limits.
b) When the graph has cycles
This is interesting as there is no visited flag in IDDFS.
30

IDS algorithm performs various iterations


until it does not find the goal node
1'st Iterationà A
2'nd Iterationà A, B, C
3'rd Iterationà A, B, D, E, C, F, G
4'th Iterationà A,B, D, H, I, E, C, F, K,G
31
Heuristic Search Method
01 Two types of problems are solved by using heuristic approach.

1. Problems for which no exact algorithms are defined.


2. Problems for which the precise solutions are known.

02 Heuristic Function

A heuristic function is a problem-solving approach that uses a rule of thumb or a


“best guess” to estimate the distance or cost to a goal state in a search problem.
32
33
34
Best First Search
• BFS would use an evaluation function to decide which among the various
available nodes is the most promising (or ‘BEST’) before traversing to that node.
• Uses the Priority queue and heuristic search.
•To search the graph space, the BFS method uses two lists for tracking the
traversal.
•An ‘Open’ list that keeps track of the current ‘immediate’ nodes available for
traversal and a ‘CLOSED’ list that keeps track of the nodes already traversed.
•BFS is called Greedy Search Algorithm too.
35
37

Example
38

Example
39
A* Search Algorithm
It combines the strength of both a greedy search and a uniform cost
search.
The heuristic of A* search is calculated as the summation of heuristic cost
in greedy search and uniform cost search.
f(x) = h(x) + g(x)
h(x) is the forward cost of a node from current state to goal state.
g(x) is the backward cost of a node from the initial state.
f(x) is fitness number
The node with smallest f(x) is selected.
The time and space complexity of A* search algorithm is O(b^d)
Example
40
Example
41
Example
42
Example - Cost Effective
43
Example - Cost Effective
44
Example - Cost Effective
45
46

Example
Example - Cost Effective
47
48
AO* Search Algorithm
AO* algorithm is a best first search algorithm.
Uses the concept of AND-OR graphs to decompose any complex problem
given into smaller set of problems which are further solved.
AND side of the graph represent a set of task that need to be done to
achieve the main goal , whereas the OR side of the graph represent the
different ways of performing task to achieve the same main goal.
f(n) = g(n) + h(n)
Example
49
Example
50
Example
51
52
Hill Climbing Algorithm
Continuously moves in the direction of increasing elevation/value to find
the peak of the mountain or best solution to the problem.
It terminates when it reaches a peak value where no neighbor has a higher
value.
This technique is used for optimizing the mathematical problems
A node of hill climbing algorithm has two components which are state and
value.
Local search, Greedy approach and No backtracking are features of it
Best when insufficient allotted time and the problem may or may not have
absolute results
53
Hill Climbing Algorithm
Graph between various
states of algorithm and
Objective function/Cost.
Y-axis=objective
function or cost function
X-axis = state-space
54 Types of Hill Climbing Algorithm

1. Simple Hill Climbing


It only evaluates the neighbor node state at a time and selects the first
one which optimizes current cost and set it as a current state

2. Steepest Ascent Hill Climbing


This algorithm examines all the neighboring nodes of the current state
and selects one neighbor node which is closest to the goal state
56 Problems in Hill Climbing

A plateau is the flat area of the search space in which all the neighbor
states of the current state contains the same value, because of this
algorithm does not find any best direction to move.
The solution for the plateau is to take big steps or very little steps
while searching, to solve the problem
57 Problems in Hill Climbing

A ridge is a special form of the local maximum.


It has an area which is higher than its surrounding areas, but itself has
a slope, and cannot be reached in a single move.
Solution: With the use of bidirectional search, or by moving in different
directions, we can improve this problem
58 Problems in Hill Climbing

A local maximum is a peak state in the landscape which is better than


each of its neighboring states, but there is another state also present
which is higher than the local maximum.
Backtracking and Generate-Test technique can be a solution of the
local maximum
59 Example
h(x) = +1 for all the blocks in the support structure if the block is correctly
positioned otherwise -1 for all the blocks in the support structure.

You might also like