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

Chapter-3 Problem Solving

ai

Uploaded by

thoughpsych
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)
15 views

Chapter-3 Problem Solving

ai

Uploaded by

thoughpsych
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/ 37

Chapter 3

Solving Problems by Searching


What is a problem?
• It is a gap between what actually is and what is desired.
– A problem exists when an individual becomes aware of the existence of
a significant difference between the expected and the actual situation,
which is an obstacle and makes it difficult to achieve a desired goal or
objective.
•To solve problems by searching we can consider: uninformed search and
informed search
Uniformed Search
• It is also called blind of exhaustive search
• Two types : BFS(Breadth First search) and
DFS(depth first search)
1) BFS(Breadth First search): this is
blind/exhaustive search algorithm in which
search start from initial node and searches
level by level up to goal node found.
• Search terminates when a solution is found.
Uniformed Search…
Example:
let Initial state= A goal state = J and M
leve0
leve1

leve2

leve3

leve4
Uniformed Search…
Nodes are explored in the level like
leve0,level1,level2,level3,level as follows
ABCDEFGHIJKLM

I G1 G2
• The goal node J will be found before the goal node M.
• Search requires considerable memory resource.
• Similar to BFS, DFS search requires considerable memory
space
Uniformed Search…
2) DFS(Depth First Search):is also blind/exhaustive search
algorithm in which search starts at initial node and searches up
to some depth in one direction.
• If goal node is found, it stop the search process, otherwise you
can do backtracking.
Uniformed search…
Example:
Let initial node=A and goal node=M and J
Uniformed search…
• Nodes are explored as A B D E H L M I N O F GJ
I G1 G2

•The goal node M will be found before J the goal node


•Similar to BFS, DFS also requires considerable memory space
Informed Search
• It is also called heuristic/intelligent search
• It is technique that improve the efficiency of search
process.
• For complex problems, traditional algorithms are unable to
find the solution with some limits of time & space.
• Hence heuristic techniques are used to solve complex
problems.
 types of informed search:
8-puzzle problem
Generate and test
A* search
AO* search
Hill climbing
Informed Search:8-puzzle problem:
• State space: Configuration of 8-tiles on the
board.
• Action:“Move tiles towards blank spaces”
• Direction: Left, Right, Up, Down
Informed Search:8-puzzle problem …

Approaches to solve 8-puzzle problem


Approach1: count correct position of tiles when compared with
goal state.
• In this approach the highest heuristic value is the best it is
and other values are ignored
Approach2: count incorrect position tiles when compared with
goal state
• In this approach the lowest heuristic value is the best it is and
other values are ignored
Approach3: count how far away each tile from its position when
compared with goal state.
• In this approach the lowest heuristic value the best it is and
other values are ignored.
• This method is preferable when there is ambiguities.
Informed Search:8-puzzle problem …
Compute the following 8-puzzle problem using three approaches?

Given

Initial state Goal state


method1: Solution

Initial state Goal state


method2: Solution

Initial state Goal state


method3: Solution
Initial state Goal state
• Assignment2(for next class):
Compute the following 8-puzzle problem using
three approaches?
Informed Search : Generate and Test algorithm
• Acceptable for simple problems.
• There is the problem state space.
• Inefficient for problems with large space. This is
disadvantage of generate and test search algorithm

problem state space


2. Generate and Test
Algorithm for Generate and Test
1.start with initial state
2.Apply technique
1.Produce a new state
3.Check a new state
4. If new state is goal state search stop, otherwise return to step2
2. Generate and Test…
Start

Initial
state

Apply technique

Produce
new state
YES
NO
New sate is goal state

Flow chart for generate and test algorithm


STOP
3. Hill climbing
• Generate and test + direction toward the goal
state.
• Searching for goal=climbing to the top of hill

Example of hill climbing


• Algorithm:
1. Evaluate the initial state. If it is goal state, then return and
quit. Otherwise make initial state as the current state.
2. Loop until a solution is found
3) Select and apply operator on current sate to produce a
new state.
4) Evaluate the new state.
i) If it is goal state, then return & quit.
ii) If it is not goal state, but it is better than the current state, then
make it as new current state.
iii) If it is not better than current state, then go to step2
Limitation of hill climbing
1. Local Maxima
• A state that is better than all of its neighbor states, but not better than some other
• For example In figure below , node C have better value than neighbor node A and B but it is not
better than node E, F and G
• This represents local maxima.
• You will not see other node in search space for goal state
• So search will see local maxima as goal state and stops search process without reaching
goal node .

Goal state

Local maxima

starts
Local Maxima
Limitation of hill climbing…
2. Plateau
•A plat area of search space in which all neighboring states have the same value
•So in plateau search stops at particular point because of plat value will found at
particular point.
•This is limitation of hill climbing
•Fore example, in figure below , node A,B And C have the same value.
•The equality represents plateau.

Goal state

Plateau

starts

Plateau
4. A* search
•Also called Best First Search
•The lowest heuristic function value is called most
promising node and that node is expanded in
next level
• A* search has three function such as f(n), g(n) and h(n)
Law: f(n)= g(n)+h(n)
g(n)= edge cost
h(n)= estimated cost from node n to goal node
f(n)= estimated total cost of path from node n to goal node
•It has 2lists:
 {OPEN} and {CLOSE} lists.
 Initially the OPEN list contains initial node and CLOSE list
contains empty.
A* search…
Example: Find shortest path from initial node S to goal node G using A* search
algorithm
A* search…

• Exploring S:
A* search…

• A is the current most promising path, so it is explored next:


A* search…
• Exploring D:
A* search…
• Exploring F:

Notice that the goal node G has been found. However,


it hasn’t been explored, so the algorithm continues
because there may be a shorter path to G.
A* search…
The node B has two entries in the open list: one at a
cost of 16 (child of S) and one at a cost of 18 (child
of A). The one with the lowest cost is explored next
A* search…
• Exploring C:
A* search…
• The next node in the open list is again B.
However, because B has already been
explored and the algorithm continues to
the next candidate.
A* search…
• The next node to be explored is the goal node G,
meaning the shortest path to G has been found!
The path is constructed by tracing the graph
backwards from G to S:
5. AO* Search(Problem Reduction)
•When a problem is divided into set of sub problems where each sub problems
can be solved separately and combination of these is solution.
•Also known as And-Or graph algorithm.
•For example Below figure shows that if you want to acquire TV, then you earn
some money and buy TV or get TV directly.
In this figure getting TV is problem one, Earning some money is problem two and buy Tv
is problem three and all of them Require solution.

Goal : Own TV

Steal TV
BUY TV

Earn some money


6. Constraint satisfaction or crypt arithmetic problem.

• The General problem that is used to find a


solution that satisfies a set of constraint.
Rule :
1.No two alphabets should have a single digit
2.Every alphabet will be given a single digit
3.If you add two digit you may or may not get carry
4.If at all carry occur it should be one
4. If at all carry is one the top most input could be
eight or nine
Forward and Backward Reasoning

Forward reasoning
• In forward reasoning the search start from initial
state and reaching to goal state.
Backward reasoning:
• In back ward reasoning the search start from goal
state to reach initial node

Backward
reasoning Goal state

Forward
Initial state reasoning

You might also like