You are on page 1of 36

PROBLEM SOLVING METHODS

•BEST FIRST SEARCH (OR-GRAPH)


•A* ALGORITHM
•PROBLEM GRAPHS
(AND-OR GRAPH, AO* ALGORITHM)
Problem Solving Methods - Introduction

Intro PROBLEM SOLVING METHODS


BEST FIRST SEARCH
OR (OR GRAPH)
A* ALGORITHM
INFORMED
AND-OR-GRAPH SEARCH
PROBLEM REDUCTION
A* AO* ALGORITHM
PROBLEM GRAPH
STRATEGIES
AND - HILL CLIMBING
OR HEURISTIC FUNCTION

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Expand the node that is closest to the goal by using


heuristic function.
• Heuristic function estimates path cost from node
OR n(current node) to goal node.
• Heuristic function is denoted by h’ or h(n).

A*

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Example: Use OR graph to find the route to reach state J


from state A

OR
h’

A*

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Example:

OR Promising
node

A*

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Example:

OR

A*

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Example:

OR

A*

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Example:

OR

A*

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro • Example Summary:


Step: 1 h’ Step: 2 Promising Step: 3
node
8
OR
1
A* Step: 4 Step: 5

AND -
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro
• OPEN: nodes that have been generated, but have not
examined.
OR
This is organized as a priority queue.

• CLOSED: nodes that have already been examined.


A*
Whenever a new node is generated, check whether it has
AND - been generated before.
OR

AO*
Problem Solving Methods – Best First Search – OR Graph

Intro ALGORITHM:
• OPEN = {initial state}.
• Loop until a goal is found or there are no nodes left in OPEN:
OR −Pick the best node in OPEN
−Generate its successors
−For each successor:
new →evaluate it, add it to OPEN, record its parent
A*
generated before →change parent, update successors

AND -
OR

AO*
Problem Solving Methods – A* Algorithm

Algorithm A* (Hart et al., 1968):


Intro
f(n) = g(n) + h(n)
or
f’ = g’ + h’
OR
h(n)= cost of the cheapest path from node n to a goal state.
g(n)= cost of the cheapest path from the initial state to node n.
A* I
h(n)

AND - n
OR
g(n)
G
Node n
AO* (current node)
Best First Search - An Example
• There are cities in a country (Romania). The task is to reach from Arad to Bucharest
Best First Search - An Example
Method: Best First Search: Start from Source (Arad). At each possible outward node n from S, write the heuristic
function h(n). Proceed further in the direction in which h(n) is minimum. Repeat the exercise till goal (destination-
Bucharest ) is achieved
A* Search
Method: A* Search: Start from Source (Arad). At each possible outward n, node from S, calculate f(n)=g(n)
+h(n), where the heuristic function is h(n) and the total distance travelled so far is g(n). Proceed further in the
direction in which h(n)( is minimum. Repeat the exercise till goal (destination- Bucharest ) is achieved
A* Search
Method: A* Search: Start from Source (Arad). At each possible outward node from S, write the heuristic
function h(n). Add the total distance travelled so far g(n). Proceed further in the direction in which h(n) is
minimum. Repeat the exercise till goal (destination- Bucharest ) is achieved
A* Search Algorithm

Algorithm
Let h(n) be the heuristic function in a graph. In simple case, let it be the straight line
distance SLD from a node to destination. Let g(n) be the function depending on the
distance from source to current node. Thus f(n) = g(n) + h(n)
1. Start from source node S, determine all nodes outward from S and queue them.
2. Examine a node from queue (as generated in 1) .
* If this node is desired destination node, stop and return success.
* Evaluate f(n) at this node. The node with optimal f(n) gives the next successor,
term this node as S.
3. Repeat steps 1 and 2.
Time = O(log f(n)) where h(n) is the actual distance travelled from n to goal
Problem Solving Methods : AND – OR Graph
Problem Reduction:
Intro • Useful for representing the solution of problem by
decomposing it into smaller sub-problems.
• Each sub-problem is solved and final solution is
obtained by combining solutions of each sub-problem.
OR • Decomposition generates arcs that we will call AND arc.
• Such structure is called AND–OR graph rather than
simply AND graph.
A* • AND-OR graph solve the problem using revised cost
technique.

A Simple AND – OR Graph


AND -
OR Acquire TV

AO*
Steal TV Earn Money Buy TV
Problem Solving Methods : AND – OR Graph
AND-OR Graph:
Intro • For simplicity, Each arc with successor will have a cost of 1.
• Estimate cost for each node using f’ (ignore g’)
• Each node has estimated cost and revised cost.
OR • Example: Step 1

A* f’

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
AND-OR Graph:
Intro • For simplicity, Each arc with successor will have a cost of 1.
• Estimate cost for each node using f’
• Estimate revised cost by f’+1
OR • Example: Step 2

Revised
Costs. Here
A* 6 is least so
expand ‘D’

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
AND-OR Graph:
Intro • For simplicity, Each arc with successor will have a cost of 1.
• Estimate cost for each node using f’
• Example: Step 3
OR

A*

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
AND-OR Graph:
Intro • For simplicity, Each arc with successor will have a cost of 1.
• Estimate cost for each node using f’
• Example: Step 4
OR

A*

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
AND-OR Graph:
Intro • For simplicity, Each arc with successor will have a cost of 1.
• Estimate cost for each node using f’ Revised
Costs. Here
6 is least so
f’ expand ‘D’
OR

A*

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
Note:
Intro • For searching AND-OR Graph we need ‘FUTILITY’
• If f’ > FUTILITY = abandon the search
• FUTILITY correspond to threshold (it’s too expensive),
OR even if it could ever found.
• Traverse the graph using problem reduction algorithm
(refer text book) until the starting node is labeled as
‘SOLVED’.
A*

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
Operation of Problem Reduction
Intro • Use Marker (arrow) to identify the better way to finding
the goal.

OR

A*
11 11

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
Longer Path may be better!!
Intro • Consider in the below figure goal state is state E
• Successor node of J is E (Shown in fig b)
• New path E is longer than through C
OR • But, path C only lead to a solution if D has solution
• D has no solution. So, J path is better than C path.

A*

AND -
OR

AO*
Problem Solving Methods : AND – OR Graph
Limitation: Interacting Sub goals
Intro • Fails to take into account any interaction between sub goals.
Failure is shown in fig.
• Assume C and E ultimately lead to a solution.
OR • Our Algorithm will report complete solution about C and E.
• For A to be solved C and D must be solved.
• But solution of D is separate process from solution of C.
• Need to consider both but our algorithm does not
A* consider such interactions.
• It will find a non optimal path.
AND -
OR

AO*
Problem Solving Methods – AO* Algorithm

• If AND-OR graph contains CYCLE then we need AO*


Intro
algorithm.
• Each node point both immediate successors and
immediate predecessors.
OR • Each node has h’ value.
• Used to avoid unnecessary backward propagation.

A*

AND -
OR

AO*
Problem Solving Methods – AO* Algorithm

 AO* algorithm follows “solve” labeling procedure along


Intro
with AND-OR graph concept.

The "Solve" labeling Procedure:


OR A terminal node is labeled as
"solved" if it is a goal node and h’ value is 0 (representing a solution of
sub-problem)
"unsolved" otherwise (as we can not further reduce it)
A* A non-terminal AND node labeled as
"solved" if all of its successors are "solved".
"unsolved" as soon as one of its successors is labeled "unsolved".
AND - A non-terminal OR node is labeled as
"solved" as soon as one of its successors is labeled "solved".
OR "unsolved" if all its successors are "unsolved".

AO*
Problem Solving Methods – AO* Algorithm

Example
Intro 1. After one cycle
A (3)

OR
B (2) C (1) D (1)
2. After two cycle
A* A (4)

AND - B (5) C (1) D (1)


OR Best path
E (4) F (6)
AO*
Problem Solving Methods – AO* Algorithm

Example – Cont…
Intro

OR

A*

AND -
OR

AO*
Problem Solving Methods – AO* Algorithm

Example – Cont…
Intro

OR

A*

AND -
OR

AO*
Problem Solving Methods – AO* Algorithm

Algorithm:
Intro
1. Initialise the graph to start node
2. Traverse the graph following the current path accumulating nodes
that have not yet been expanded or solved
3. Pick any of these nodes and expand it and if it has no successors
OR
call this value FUTILITY otherwise calculate only f' for each of the
successors.
4. If f' is 0 then mark the node as SOLVED
A* 5. Change the value of f' for the newly created node to reflect its
successors by back propagation.
6. Wherever possible use the most promising routes and if a node is
marked as SOLVED then mark the parent node as SOLVED.
AND - 7. If starting node is SOLVED or value greater than FUTILITY, stop,
OR else repeat from 2.

AO*
Intro

QUERIES???
OR

A*

AND -
OR

AO*
AO*
Intro

THANK YOU
OR

A*

AND -
OR

AO*
AO*
CLASS TEST 1

Intro Class Test - I will be on 10-1-2019. Portions


are:
1. Water Jug Problem
OR 2. Search Strategies (Both informed & uninformed
search strategies)

A*

AND -
OR

AO*
AO*

You might also like