0% found this document useful (0 votes)
38 views2 pages

Problem Set 5

This document contains summaries of 4 problems related to A* search on Euclidean spaces. Problem 1 discusses how heuristics can sometimes make the search less efficient by overestimating distances. Problem 2 proves that a landmark heuristic satisfies consistency and provides Python code to generate landmark heuristics. Problem 3 notes that Euclidean heuristics become more efficient than Manhattan or uninformed search as problem size increases. Problem 4 provides Python code for Prim's minimum spanning tree algorithm.

Uploaded by

beta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
38 views2 pages

Problem Set 5

This document contains summaries of 4 problems related to A* search on Euclidean spaces. Problem 1 discusses how heuristics can sometimes make the search less efficient by overestimating distances. Problem 2 proves that a landmark heuristic satisfies consistency and provides Python code to generate landmark heuristics. Problem 3 notes that Euclidean heuristics become more efficient than Manhattan or uninformed search as problem size increases. Problem 4 provides Python code for Prim's minimum spanning tree algorithm.

Uploaded by

beta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 2

Akhilesh

Yeleswarapu

Problem Set 5: A* search on Euclidean spaces


Problem 1
This is because the heuristic function can sometimes make the function less strict, giving us a slightly less efficient
solution. This error happens when the heuristic is greater than the actual value.

Problem 2
A)

We know that

potential(u) - potential(v) <= dist(u, v)

is the same as

dist(li, t) − dist(li , u) – (dist(lj, t) − dist(lj , v)) <= dist(u, v

for arbitrary i and j

We also know that from the triangle inequality, that the potential function is less than the actual distance. Therefore,

dist(u, v) >= dist(u, t) − dist(v, t)

>= dist(u, l) − dist(t, l) – ((dist(v, l) − dist(t, l))

= dist(u, l) − dist(v, l)

Therefore

dist(u, v) >= dist(u, l) − dist(v, l)

Which means the function is consistent

B)
def create_landmark_heuristic_generator(G):
landmarks = numpy.random.choice(G(1))
for u in G:
a[0][u] = math.inf
a[1][u] = math.inf
a[2][u] = null
for l in landmarks:
for u in G:
if a[0][u] > djikstra[u][l] and a[1][u] > djikstra[l][t]:
a[0][u] = djikstra[u][l]
a[1][u] = djikstra[l][t]
a[2][u] = l
Akhilesh Yeleswarapu

def construct_heuristic_for(t):
def heuristic(u):
return a[0][u]+a[1][u]
return heuristic
return construct_heuristic_for

pylab.subplot(2,2,4)
pylab.title("ALT heuristic")
heuristic_generator = create_landmark_heuristic_generator(G)

heuristic_for_t = heuristic_generator(t)
visualize_path(G, s, t, *dijkstra(G, s, t, heuristic_for_t))

Problem 3
All of them are obviously increasing with n and d, however, I noticed that the Euclidian heuristic was initially
making it less efficient. After a point though, the ranking was consistently Manhattan, Euclidean, and
Dijkstra last.

Problem 4

import PQdict
def prim(G,s):
cur = s
visited = set()
pq = PQdict()
mst = []
while len(mst) < G.number_of_nodes() – 1
for n in G.neighbors(cur):
if n not in visited and cur not in visited:
if (cur, n) not in pq and (n, cur) not in pq:
w = G.edge[cur][n]['weight']
pq.add((cur, n), w)
visited.add(cur)
t, w = pq.popitem()
while(t[1] in visited):
t, w = pq.popitem()
mst.append(t)
current = t[1]
return mst

You might also like