示例#1
0
def astar_heuristic(roads: graph.Roads, src, trg):
    src_junc = roads[src]
    trg_junc = roads[trg]
    air_distance = compute_distance(src_junc.lat, src_junc.lon, trg_junc.lat,
                                    trg_junc.lon)
    # return the air distance / max speed in all graph.
    return 1000 * (air_distance / avgspeed)
 def estimate(self, problem, state):
     max_val = 0
     for waiting_order in state.waitingOrders:
         coord1 = self.roads[waiting_order[0]].coordinates
         coord2 = self.roads[waiting_order[1]].coordinates
         current = compute_distance(coord1, coord2)
         if (max_val < current):
             max_val = current
     return max_val
示例#3
0
def heuristic_time(roads, src, target):
    src_lat = roads[src].lat
    src_lon = roads[src].lon
    target_lat = roads[target].lat
    target_lon = roads[target].lon

    # use the speed as the average speed since we don't have a given road type
    speed = sum(maxspeeds) / len(maxspeeds)
    return compute_distance(src_lat, src_lon, target_lat, target_lon) / speed
示例#4
0
文件: astar.py 项目: ayurkovs/AI1
def heuristic_function(source_junction, target_junction):
    return speed_and_distance_to_time(
        110, compute_distance(source_junction.lat, source_junction.lon, target_junction.lat, target_junction.lon)
    )
示例#5
0
def h(source, target):
    h = convert_to_time(
        110, compute_distance(source.lat, source.lon, target.lat, target.lon))
    return h
def heuristic(node_one, node_two):
    return compute_distance(node_one.lat, node_one.lon, node_two.lat,
                            node_two.lon) / 110
示例#7
0
 def heuristic_cost(self, s, a):
     return compute_distance(s.lat, s.lon, a.lat, a.lon)
示例#8
0
 def h(node):
     junction = roads[node.state]
     target = roads[goal.state]
     x = compute_distance(junction.lat, junction.lon, target.lat,
                          target.lon) / 110
     return x
示例#9
0
 def h(node):
     node_junction = node.junction
     target_junction = target.junction
     return ways.compute_distance(node_junction.lat, node_junction.lon,
                                  target_junction.lat, target_junction.lon)
示例#10
0
 def dis(self,a):
     g = self.G[self.goal]
     curr = self.G[a]
     return compute_distance(curr.lat, curr.lon, g.lat, g.lon)
示例#11
0
 def hx(self, a):
     g = self.G[self.goal]
     curr = self.G[a]
     max_speed = max(info.SPEED_RANGES[0])
     cost = compute_distance(curr.lat, curr.lon, g.lat, g.lon) / max_speed
     return cost
 def estimate(self, problem, state):
     return compute_distance(problem.target.coordinates, state.coordinates)