Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

COS3751 Assignment 01-Second Semester-2013 362609

the state at node n to a goal state. It is used to sort the nodes in the frontier, which
is a priority queue. Whenever a node is added to the frontier, the cost of reaching
the goal from this node is estimated using the evaluation function and the node is
then inserted into the queue (frontier) at a position that leaves the queue sorted
on estimate costs after the insertion has completed. In the greedy best-first search
algorithm below, the underlined statements indicate where the evaluation
function comes into play.

function GREEDY-BEST-FIRST-SEARCH(problem) returns a solution, or failure


node ← a node with STATE = problem.INITIAL-STATE
frontier ← a priority queue ordered by COST-ESTIMATE, with node as the only element
explored ← an empty set
loop do
if EMPTY?(frontier) then return failure
node ← POP(frontier) /* chooses the node with lowest estimate-cost in frontier */
if problem.GOAL-TEST(node.STATE) then return SOLUTION(node)
add node.STATE to explored
for each action in problem.ACTIONS(node.STATE) do
child ← CHILD-NODE(problem, node, action)
if child .STATE is not in explored or frontier then
frontier ← INSERT(child, frontier)
else if child .STATE is in frontier with higher COST-ESTIMATE then
replace that frontier node with child

(3.10) Consider figure 7 and table 5 and answer the questions that follow. The table provides
the estimated distances from each node to N.

A
7 3
B D 2

F C I
L
3
G K
5
H
M E
1

N
Figure 7: A* search

Node Estimated distance to N


A 10
B 12
C 4
D 5
E 4
F 7

Cornelis Dubbelman-48269328 Page 10 of 13


COS3751 Assignment 01-Second Semester-2013 362609

G 4
H 6
I 4
K 2
L 1
M 1
N 0

7 3

7
10
7

6
4
10
8

8
5
4

5
2
5

5
3

1
1

7 3
8

7
8

5
5
1

(a) List the nodes in the order in which they are expanded (not generated).
Expanding a node means that you remove it from the frontier, add its state to the
explored set, and finally generating and adding all its successors, which meat
specific criteria, to the frontier. So, according to this definition, the goal node (in
this case N) is never expanded, since, the GOAL-TEST is done directly after the node
is removed from the frontier (its state is not added to the explored set, nor is its
children, if any, generated). Thus, the order in which the nodes are expanded is as
follows:
A D K L M (N is POPed from the frontier, but technically not expanded).
The sequence of diagrams above graphically depicts the search process.

(b) Write down the content of the frontier at the time the search terminates.
The contents of the frontier at the time the search terminates is as follows: I use
the syntax n(f,g,h) to represent frontier elements, where n is the label of the node,
f is the corresponding f-cost of n (sum of g and h), g is the path-cost of getting from

Cornelis Dubbelman-48269328 Page 11 of 13


COS3751 Assignment 01-Second Semester-2013 362609

the start node (A) to n, and h is the cost-estimate of the cheapest path to the goal
from n.
C(12,8,4), I(14,10,4), E(16,12,4), B(19,7,12)

(c) Is the heuristic being applied consistent? Explain your answer.


No, it is not consistent.
Since the estimate distance between A and N is greater than the actual distance
between A and D plus the estimated distance between D and N
(10=ℎ ( ) > ( , , ) + ℎ( ) = 3 + 5 = 8), and the definition of
consistency as stated in my answer to question 3.9.a (ℎ( ) ≤ ( , , ’) + ℎ ( ’)),
I can conclude that the heuristic that is being applied here is not consistent!

(d) Explain why the search algorithm does not get stuck in loops when one considers
that there is a circular path from A to D to K to E (which leads back to A).
In the case of A* graph search. Since the algorithm keeps track of which nodes in
the state-space have already been expanded (through the implementation of an
explored set), and the fact that the algorithm discards newly generated nodes with
matching states in the explored set or frontier, it is guaranteed that the algorithm
will never get stuck in a loop (in fact, it will not even make one complete lap
around any circuit!) It is important to note that all step-costs are nonnegative,
hence the reason why newly generated nodes with matching states, only in the
frontier, will be discarded.
On the other hand, in the case of A* tree search, A* is guaranteed not to expand
any node with an f-cost greater than that of the cost of the optimal solution. So,
since the path-cost (which is a summand in the f-cost formula) is ever increasing
(accumulating) along any path in the given graph, the f-costs of some (or all) of the
nodes that form the circuit will eventually, after a finite number of trips around the
circuit, exceed the cost of the optimal solution. Hence, terminating the looping
path!

Cornelis Dubbelman-48269328 Page 12 of 13

You might also like