Beispiel #1
0
def airlines_sphere(n1, n2):
    """
	Airlines feature heuristic based on actual distance over
	the surface of the earth between coordinates (assuming a perfectly round earth)
	"""
    from util import distance_on_earth

    return distance_on_earth(n1["lat"], n1["lon"], n2["lat"], n2["lon"])
Beispiel #2
0
	def __init__(self, alg, problem, start_n, goal_n, two_h):
		from graph import read_airline_graph
		from util import distance_on_earth

		g = read_airline_graph('data/openflights/')

		start = start_n
		goal = lambda n: n == goal_n
		successors = lambda n: g.successors[n]
		cost = lambda n,m: distance_on_earth(g.node[n]['lat'],g.node[n]['lon'],g.node[m]['lat'],g.node[m]['lon'])
		h = lambda n: two_h(g.node[n], g.node[goal_n])

		self.problem = problem(start, goal, successors, cost, h)
		self.alg = alg(self.problem)