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

Chapter 3 - Solving Problems by Searching

This document discusses problem solving and searching algorithms. It begins by defining what a problem is and providing examples of different types of problems. It then discusses solving problems by defining the initial state, actions, goal test, goal state, and path cost. Steps in problem solving like goal formulation, problem formulation, search, and execution are explained. Finally, searching algorithms are introduced for systematically exploring the state space to find optimal solutions.

Uploaded by

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

Chapter 3 - Solving Problems by Searching

This document discusses problem solving and searching algorithms. It begins by defining what a problem is and providing examples of different types of problems. It then discusses solving problems by defining the initial state, actions, goal test, goal state, and path cost. Steps in problem solving like goal formulation, problem formulation, search, and execution are explained. Finally, searching algorithms are introduced for systematically exploring the state space to find optimal solutions.

Uploaded by

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

Select Collage

Computer Science
CHAPTER 3
Solving Problems
by
By Samuel M.
Searching DEC. 2022
Learning objectives: at the end of the class, you should be able
to:

•What is a Problem?
• Problem types with examples

•Solving a problem
• Solution and optimal solution

• Components of problem

•Steps in problem solving

•Searching
• Searching Algorithm Evaluation

• Search Strategies
2
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 an obstacle which makes it difficult to achieve a
desired goal or objective.
• A number of problems are addressed towards designing
intelligent agent:
• Toy problems: are problems that are useful to test and
demonstrate methodologies and can be used by researchers to
compare the performance of different algorithms.
• May require little or no ingenuity, good for games design
• e.g. 8-puzzle, n-queens, vacuum cleaner world, towers of Hanoi, river
crossing…
• Real-life problems: problems that have much greater
commercial/economic impact if solved.
• Such problems are more difficult and complex to solve, and there is no
single agreed-upon description.
• E.g. Route finding, Traveling sales person, etc.
3
Some more Real-world Problems
 Route finding Problem
 Traveling Salesman Problem(TSP)
 VLSI Layout
 Assembly Sequencing
 Robot Navigation
Route Finding Problem
• Route Finding Problem - shortest path problem
• Defined in terms of locations and transitions along links between
them.
• Applications: automated travel advisory systems, airline
travel planning systems, military operations planning,
routing in computer networks,
General Route Finding Algorithm
1. Identify initial state as origin: Initial State
2. Expand to All Possible Locations: Successors
3. Choose Location with smallest cost/fastest route
4. Test Goal Function, is it the destiny? Goal Test
5. if yes, return location: Goal State
else, return to 2
Cont’d
• Route Finding Problem: Entire States - State Space

A simplified road map of part of Romania

6
Cont’d
• Route Finding Problem:
• A problem can be defined formally by five components
• Initial State: The initial state that the agent starts in. For
example, the initial state for our agent in Romania might be
described as In(Arad)

• Actions: Paths Visited (Successors) =


From State: In(Arad), applicable actions are {Go(Sibiu),
Go(Timisoara), Go(Zerind)}.
• Goal Test: Test if state is goal(Bucharest).
• Goal State: Bucharest
• Path Cost: Total cost in number

7
• Traveling Salesperson Problems(TSP)
Cont…
• Visit each city on the map exactly once and returns to the
origin city.
• Needs information about the visited cities
• The aim is used to find the shortest possible route that visits
every city exactly once and return to the starting point.
• Applications: vehicle routing
• VLSI Layout Cont…
• Place cells on a chip so they don’t overlap and there is room for
connecting wires to be placed between the cells
• A VLSI Layout problem requires positioning millions of
components and connections on a chip to minimize area,
minimize circuit delays, minimize stray capacitances, and
maximize manufacturing yield.
Solving a Problem

10
Solving a Problem
Problem Solving: is a process of generating solutions from
observed/or given data. Use direct or indirect(Model based) methods
A problem is characterized by - a stet of goals, objects & operations
operations.
To build a system, to solve a particular problem, we need to
• Define the problem precisely
 Find input situations as well as final situations for acceptable solution to
the problem
• Analyze the problem
 Find few important features that may have impact on the appropriateness
of various possible techniques for solving the problem.
• Isolate and represent task necessary to solve the problem
• Choose the best problem solving technique(s) and apply to
the particular problem

11
Solving a problem…
Solution and Optimal Solution
•Solution is set of actions that leads from initial state to goal
state,

• There may be many solution for a problem solving


agent. The quality of this solution is measured by the path
cost and the solution with minimum path cost is called
Optimal Solution.

12
Example: The 8 puzzle problem
1 2 3 1 2 3
4 8 4 5 6
7 6 5 7 8

Initial state Goal state


Operators: slide blank up, slide blank down, slide blank
left, slide blank right
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
4 8 4 8 5 4 8 5 4 5 4 5 4 5 6
7 6 5 7 6 7 6 7 8 6 7 8 6 7 8

Solution: sb-down, sb-left, sb-up,sb-right, sb-down


Path cost: 5 steps to reach the goal

14
Exercise: The 8 puzzle problem
• This is the problem of arranging the tiles so that all the tiles are in
the correct positions. You do this by moving tiles or space up,
down, left, or right, so long as the following conditions are met:
• a) there's no other tile blocking you in the direction of the movement; and
• b) you're not trying to move outside of the boundaries/ edges. 

• Identify possible states & operators?


• Construct state space?

1 2 3 1 2 3
8 4 5 8 4
7 6 7 6 5
15
Exercise : River Crossing Puzzles
Goat, Wolf and Cabbage Problem
• A farmer returns from the market, where he bought a goat,
a cabbage and a wolf. On the way home he must cross a
river. His boat is small and unable to transport more
than one of his purchases. He cannot leave the goat alone
with the cabbage (because the goat would eat it), nor he can leave
the goat alone with the wolf (because the goat would be eaten). How
can the farmer get everything safely on the other side?
1. Identify the set of possible states and operators
2. Construct the state space of the problem using suitable
representation

17
Steps in Problem Solving
• Goal Formulation
• is a step that specifies exactly what the agent is trying to achieve
• This step narrows down the scope that the agent has to look at
• Problem Formulation
• Is a step that puts down the actions and states that the agent has to
consider given a goal (avoiding any redundant states), like:
• the initial state
• the allowable actions etc…

• Search
• is the process of looking for the various sequence of actions that
lead to a goal state, evaluating them and choosing the optimal
sequence.
• Execute
• is the final step that the agent executes the chosen sequence of
actions to get it to the solution/goal
19
Example: Path Finding Problem
Initial
Arad to Bucharest
State
• Formulate goal:
• be in Bucharest (Romania)

• Formulate problem: Goal


• action: drive between pair of connected State
cities (direct road)

• state: be in a city
(20 world states)

• Find solution:
• sequence of cities leading from start to goal
state, e.g., Arad, Sibiu, Fagaras, Bucharest

• Execution
• drive from Arad to Bucharest according to
the solution
Route Finding Problems

• Basic idea:
• Simulated exploration
of state space by
generating successors
of already explored
states (AKA expanding
states)

Sweep out from start (breadth)


…Cont’d

• Basic idea:
• Simulated exploration of
state space by
generating successors of
already explored states
(AKA expanding states)

Go East, young man! (depth)


Searching
Searching
• Search consists of a set of methods to systematically
determine the next best action in order to search for a
solution of a problem

• Parts of a Problem: initial state, operators, goal test


function, path cost function.
Searching in State Space
Select optimal (min-cost/max-profit) node/state in
the state space
Test whether the state selected is the goal state or
not
if not, expand the node further to identify its
Evaluation Searching Algorithm
Searching algorithm can be evaluated by the following four
criteria

• Completeness
• Optimality
• Time complexity
• Space complexity
Cont…
• Completeness
• Guarantees finding a solution whenever one exists.
• Think about the density of solutions in space and evaluate whether
the searching technique guaranteed to find all solutions or not.
• Optimality
• is the algorithm finding an optimal/best solution; i.e. the one
with minimize cost or maximize profit
• If a solution is found, is it guaranteed to be an optimal one? That
is, is it the one with minimum cost?
• how good is our solution?
 Time complexity: how long does it take to find a solution
- Usually measured in terms of the number of nodes expanded
(time taken)
 Space complexity: how much space is used by the algorithm
Types of search algorithms:
 Based on the search problems we can classify the search algorithms into
uninformed (Blind search) and informed search (Heuristic search) algorithms:
Uninformed/Blind Search:
 The uninformed search does not contain any domain
knowledge such as closeness, the location of the goal.
 It operates in a brute-force (trial-and-error) way as it only
includes information about how to traverse the tree and
how to identify leaf and goal nodes.
 Uninformed search applies a way in which search tree is
searched without any information about the search space
like initial state operators and test for the goal, so it is also
called blind search.
 It examines each node of the tree until it achieves the goal
node
It can be divided into five main types:

 Breadth-first search
 Uniform cost search
 Depth-first search
 Iterative deepening depth-first search
 Bidirectional Search
Informed Search:

 Informed search algorithms use domain knowledge.


 In an informed search, problem information is available
which can guide the search.
 Informed search strategies can find a solution more
efficiently than an uninformed search strategy.
 Informed search is also called a Heuristic search.
 An example of informed search algorithms is a traveling
salesman problem.
 Greedy Search
 A* Search
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.
 Expand shallowest unexpanded
node,
 Expand all nodes on a given level of the
search tree before moving to the next level
 Implementation: uses Queue(FIFO)
data structure to store the list:
 Put successors at the end of queue
 Pop nodes from the front of the queue
Example of Breadth First Search (BFS):
 Properties:
 Takes space: keeps every node
in memory
 Optimal and complete:
guarantees to find solution
 Time Complexity: can be obtained by
the number of nodes traversed in BFS
until the shallowest Node. Where the
d= depth of shallowest solution and b
is a node at every state.
T (b) = 1+b2+b3+.......+ bd= O (bd)
 Space Complexity: Space complexity
of BFS algorithm is given by the
Memory size of frontier which is O(bd).
• Traversed path:
S---> A--->B---->C--->D---->G--->H--->E---->F---->I---->K
Breadth First Search (BFS)
 Advantages:
 BFS will provide a solution if any solution
exists.
 If there are more than one solutions for a
given problem, then BFS will provide the
minimal solution which requires the least
number of steps.
 Disadvantages:
 It requires lots of memory since each
level of the tree must be saved into
memory to expand the next level.
 BFS needs lots of time if the solution is
far away from the root node.
Exercise
• Apply BFS to find an optimal path from Start Node (S)
to Goal Node (G).

• BFS: S->B->C->D->E->G
Depth-First Search (DFS)
 Expand one of the node at the
deepest level of the tree.
 Only when the search hits a non-goal dead end
does the search go back and expand nodes at
shallower levels
 It is called the DFS because it starts
from the root node & follows each
path to its greatest depth node before
moving to the next path.
 will follow the order as:
Root node--->Left node ----> right node.
Depth-First Search (DFS)…

• Implementation: treat the list as Stack(LIFO)


• Expansion: push successors at the top of stack
• Pop nodes from the top of the stack
• Properties
• Incomplete and not optimal: fails in infinite-depth spaces,
spaces with loops.
• Modify to avoid repeated states along the path
• Takes less space (Linear): Only needs to remember up to the
depth expanded
Depth-First Search (DFS)
Advantage: Disadvantage:
There is the possibility that many states
DFS requires very less memory as it only
keep re-occurring, & there is no
needs to store a stack of the nodes on the
guarantee of finding the solution.
path from root node to the current node.
DFS algorithm goes for deep down
It takes less time to reach to the goal node searching and sometime it may go to the
than BFS algorithm (if it traverses in the infinite loop.
right path).
…Cont’d
• Example of Depth First Search (DFS)
 Time Complexity: Time complexity of DFS
will be equivalent to the node traversed by the
algorithm. It is given by:

T(n)= 1+ n2+ n3 +.........+ nm=O(nm)


Where, m= maximum depth of any node and this
can be much larger than d (Shallowest
solution depth)

 Space Complexity: DFS algorithm needs to store only single path from the
root node, hence space complexity of DFS is equivalent to the size of the
fringe set, which is O(bm).
Exercise
• Apply DFS to find an optimal path from Start Node (S)
to Goal Node(G).
Depth Limited Search (DLS)
• Depth Limited Search 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.
• The node at the depth limit will treat as it has no successor nodes
further.
• Depth-limited search can be terminated with two Conditions of
failure:
 Standard failure value: It indicates that problem does not have any
solution.
 Cutoff failure value: It defines no solution for the problem within a given
depth limit.
Example of DLS
Consider a case where depth-
limit d=2

Depth limit ℓ = 2
S-->A-->C-->D--->B-->I-->J
…cont.
• Advantages:
• Memory efficient.
• Disadvantages:
• incompleteness.
• may not be optimal if problem has more than one solution.

Goal
Exercise
• Apply DLS to find an optimal path from Start Node (S)
to Goal Node (G) with depth limit ℓ = 2
Iterative Deepening Search (IDS)
 The Iterative Deepening Depth-First Search (IDS) algorithm,
repeatedly applies depth-limited search with increasing limits.
 It gradually increases limits from 0,1,...d, until the goal node is
found.

It terminates in the following


two cases:
When the goal node is found
The goal node does not exist in
the graph/tree.
…Cont’d
• Advantages:
• It combines the benefits of BFS and DFS search algorithm in
terms of fast search and memory efficiency.
• Disadvantages:
• The main drawback of IDS is that it repeats all the work of the
previous phase.
• Example:
• Following tree structure is showing the iterative deepening
depth-first search.
• IDS algorithm performs various iterations until it does not
find the goal node. The iteration performed by the algorithm
is given as:
…Cont’d
Exercise
A
oApply IDS to find Optimal Path from
oInitial State = A to Goal State = H
B C D

E F G
H
Level Iteration Path Returned using IDS
I J K
Depth
0 1
1 2
2 3
3 4
Uniform Cost Search
• The goal of this technique is to find the shortest path to the
goal in terms of cost.
• It modifies the BFS by always expanding least-cost unexpanded
node
• Implementation: nodes in list keep track of total path length
from start to that node
• List kept in priority queue ordered by path cost
A
S S S
1 10 S
5 B 5
S G 0 A B C A B C A B C
1 5 15 5 15 15
G G G
15 5
11 11 10
C
• Properties:
• This strategy finds the cheapest solution provided the cost of a
path must never decrease as we go along the path successor(n))
≥ g(n), for every node n.
• Takes space since it keeps every node in memory
Example of UCS
• niform-Cost Search is mainly used in Artificial Intelligence.
U
…Cont’d
 Cost: S-->A: 1, A-->D: 2, D-->G: 3
 S---> A---> D---> G

Minimum cost from S to G is =3


…Cont’d
• Advantages:
• Optimal because at every state the path with the least cost is
chosen.
• Disadvantages:
• It does not care about the number of steps involve in
searching and only concerned about path cost. Due to which
this algorithm may be stuck in an infinite loop.
Exercise:
Apply UCS to find optimal path from Strat Node
(Initial State = S), Goal Node(Goal State = G)
S
1 5 8

A B C
3 9
7 4 5
D E G
Exercise:
Apply Uninformed Search Strategies to find optimal
path. Initial State = S, Goal State = G, ℓ = 1
Find Optimal Path
S
1.BFS? 1 8
5
2.DFS?
3.IDS? A B C
9
4.DLS: ℓ = 2? 3
7 4
5
5.UCS? D E G
Comparing Uninformed Search Strategies
Time Space
Strategies Complete Optimal Complexity Complexity

Breadth First Search Yes Yes O(bd) O(bd)


Depth First search No No O(bm) O(bm)
Uniform Cost Search Yes Yes O(bd) O(bd)
Depth Limited Search if l >= d No O(bℓ) O(bℓ)
Iterative Deepening Yes Yes O(bd) O(bd)
Search
Bi-Directional Search Yes Yes O(bd/2) O(bd/2)
Where:
• b is branching factor,
• d is depth of the shallowest solution,
• m is the maximum depth of the search tree,
• ℓ is the depth limit
Informed Search
(Heuristic Search)

• Informed Search (Heuristic)


• Best First Search
• Greedy Best First Search
• A* Search
Informed Heuristic Search
 Search efficiency would improve greatly if there is a way to
order the choices so that the most promising are explored
first.
 This requires domain knowledge of the problem (i.e. heuristic) to
undertake focused search
 Define a heuristic function, h(n) that estimates the goodness
of a node n, based on domain specific information that is
computable from the current state description.
• h(n) is an estimate of how close we are to a goal state
• It is an estimated cost of path from state n to a goal state.
Best First Search
 It is a generic name to the class of informed methods
 The two best first approaches to find the shortest path:
• Greedy Search: minimizes estimated cost to reach a goal
• A* Search: minimizes the total path cost
 When expanding a node n in the search tree, Greedy Search
uses the estimated cost to get from the current state to the
goal state, defined as h(n).
 In route finding problem h(n) is the straight-line distance
f(n) = h(n)
• We also possess the sum of the cost to reach that node from
the start state, defined as g(n).
• In route finding problem; this is the sum of the step costs for the
search path.
• For each node in the search tree, A*-Search uses an
evaluation function, f(n):
f(n) = g(n) + h(n)
Admissibility
• Search Algorithms (such as Greedy and A* Search) are
admissible when the heuristic function never overestimated
the actual cost so that
• The algorithm always terminates in an optimal path from the
initial state to goal node if one exists.
• Check Admissibility of estimated cost h(n): make sure that
h(n) is not overestimated as compared to g(n)
• g (n): Actual cost of shortest path from n to z (not known)
• h(n) is said to be an admissible heuristic function if for all n, h(n) ≤
g(n)
• The closer estimated cost to actual cost the fewer extra nodes that
will be expanded
• Using an admissible heuristics guarantees that the solution found
by searching algorithm is optimal
Greedy Search
• A Best First Search that uses a heuristic function h(n)
alone to guide the search
• Selects node to expand that is closest (hence it’s greedy) to a
goal node
• The algorithm doesn’t take minimum path costs from initial to
current nodes into account, it just go ahead optimistically and
never looks back.

• Implementation:
• expand 1st the node closest to the goal state, i.e. with evaluation
function f(n) = h(n)
• h(n) = 0 if node n is the goal state
• Otherwise h(n) ≥ 0; an estimated cost of the cheapest path from
the state at node n to a goal state
Example

Initial state
S
8
1 5 8

A B C
8 4 3
3 9
7 4 5
D E G
  0
goal state
…Cont’d
• Best First (Greedy) Search Algorithm:
• Step 1: Place the starting node into the OPEN list.
• Step 2: If the OPEN list is empty, Stop and return failure.
• Step 3: Remove the node n, from the OPEN list which has the
lowest value of h(n), and places it in the CLOSED list.
• Step 4: Expand the node n, and generate the successors of node n.
• Step 5: Check each successor of node n, and find whether any node
is a goal node or not. If any successor node is goal node, then
return success and terminate the search, else proceed to Step 6.
• Step 6: For each successor node, algorithm checks for evaluation
function f(n), and then check if the node has been in either OPEN
or CLOSED list. If the node has not been in both list, then add it to
the OPEN list.
• Step 7: Return to Step 2.
…Cont’d
• Advantages:
• switch between BFS and DFS (gaining the advantages of both).
• more efficient than BFS and DFS algorithms.
• Disadvantages:
• behave as unguided depth-first search in worst case scenario.
• get stuck in a loop as DFS.
• not optimal.
…Cont’d
• Example of Greedy Search
• Consider the below search problem, and we will traverse it using
greedy best-first search. At each iteration, each node is
expanded using evaluation function f(n)=h(n) , which is given in
the below table.
A* Search Algorithm
• It considers both estimated cost of getting from n to the goal
node h(n), and cost of getting from initial node to node n, g(n)
• Apply three functions over every nodes
• g(n): Cost of path found so far from initial state to n (path cost)
• h(n): Estimated cost of shortest path from n to z (heuristic value)
• f(n): Estimated total cost of shortest path from a to z via n
• Evaluation function f(n) = h(n) + g(n)
• Implementation: Expand the node for which the evaluation
function f(n) is lowest
• Rank nodes by f(n) that goes from the start node to goal node via
given node

• Example: Route Finding Problem


Properties of A* Search
• A* Search is complete, optimal, and optimally efficient
for any given admissible heuristic function
• Completeness
• Complete, it guarantees to reach to goal state
• Optimality
• If the given heuristic function is admissible, then A* Search is
optimal.
• Proof optimality of A* Search
• Space Complexity - depends on the quality of the heuristic function.
• Takes memory: It keeps all generated nodes in memory
• Space complexity is exponential
• Space Complexity - depends on the quality of the heuristic function.
• Worst case is exponential
…Cont’d
• A* Search uses search heuristic as well as the cost to
reach the node. Hence we can combine both costs as
following, and this sum is called as a fitness number.

• NB:
• At each point in the search space, only those node is expanded
which have the lowest value of f(n), and the algorithm
terminates when the goal node is found.
…Cont’d
Algorithm of A* search:
• Step 1: Place the starting node in the OPEN list.
• Step 2: Check if the OPEN list is empty or not, if the list is empty
then return failure and stops.
• Step 3: Select the node from the OPEN list which has the
smallest value of evaluation function (g+h), if node n is goal node
then return success and stop, otherwise
• Step 4: Expand node n and generate all of its successors, and put
n into the closed list. For each successor n', check whether n' is
already in the OPEN or CLOSED list, if not then compute
evaluation function for n' and place into Open list.
• Step 5: Else if node n' is already in OPEN and CLOSED, then it
should be attached to the back pointer which reflects the lowest
g(n') value.
• Step 6: Return to Step 2.
…Cont’d
• Example of A* Search:
• Traverse the given graph using the A* algorithm. The heuristic
value of all states is given in the below table. Calculate f(n) of
each state using the formula f(n)= g(n) + h(n), where g(n) is the
cost to reach any node from start state.
• Here we will use OPEN and CLOSED list.
…Cont’d
Heuristic Search Methods
Algorithm Time Space Optimal Complete
Comp. Comp.
Greedy O(bm) O(bm) No No

A* O(bd) O(bd) yes optimal if h'(n) Yes


never overestimates

b is the branching factor; d is the depth of solution; m is the


maximum depth of the search tree; N the number of nodes
Exercise: Search Space
• Given the search space below, find the optimal path from Initial
State S to Goal State G using Informed Search Strategies:
a) Best First Search (Greedy)
b) A* Search
Solution: Search Space
• Informed Search (Heuristic Search) Strategies
• BFS (Greedy): f(n) = h(n)
1. S: f(n) = 10
2. S => A: f(n) = 12 (Lowest, expand via A)
S => B: f(n) = 14 (ignore)
3. S => A => C: f(n) = 11 (ignore)
S => A => D: f(n) = 4 (Lowest, expand via D)
4. S => A => D => G: f(n) = 1 (Lowest, Reached Goal State)
S => A => D => H: f(n) = 2 (ignore)
• A* Search: f(n) = g(n) + h(n)
1. S: f(n) = 0 + 10 = 10
2. S => A: f(n) = 2 + 12 = 14 (Lowest, expand via A)
S => B: f(n) = 3 + 14 = 17
3. S => A => C: f(n) = (2 + 9) + 11 = 22
S => A => D: f(n) = (2 + 5) + 4 = 11 (Lowest, expand via D)
4. S => A => D => G: f(n) = (2 + 5 + 3) + 1 = 11 (Lowest, Reached
Goal)
Exercise: Search Space
• Given the search space below, find the optimal path from Initial
State S to Goal State G using Informed Search Strategies:
a) Best First Search (Greedy)
b) A* Search

 Solution:
 Greedy: f(n) = h(n)
 A*: f(n) = g(n) + h(n)
Solution: Search Space
• Informed Search (Heuristic Search) Strategies
• BFS (Greedy): f(n) = h(n)
1. S: f(n) = 13
2. S => A: f(n) = 12
S => B: f(n) = 4 (Lowest h, expand B)
3. S => B => E: f(n) = 8
S => B => F: f(n) = 2 (Lowest h, expand F)
4. S => B => F => I: f(n) = 9
S => B => F => G: f(n) = 0 (Lowest h, Reached Goal State)
Solution: Search Space
• Informed Search (Heuristic Search) Strategies
• A* Search: f(n) = g(n) + h(n)
1. S: f(n) = 0 + 13 = 13
2. S => A: f(n) = 3 + 12 = 15
S => B: f(n) = 2 + 4 = 6 (Lowest f-cost, expand via B)
3. S => B => E: f(n) = (2 + 3) + 8 = 13
S => B => F: f(n) = (2 + 1) + 2 = 5 (Lowest f-cost, expand via F)
4. S => B => F => I: f(n) = (2 + 1 + 2 + 3) + 9 = 17
S => B => F => G: f(n) = (2 + 1 + 3) + 0 = 6 (Lowest f-cost, Reached Goal)
Questions?

You might also like