Пример #1
0
def scoreMeetup(places):
    if len(places) == 0:
        return 99999999
    center = centroid([(p["bounds"][0], p["bounds"][1]) for p in places])
    distances = [distanceBetweenLatLongs(center, (p["bounds"][0], p["bounds"][1])) for p in places]
    distance_score = reduce(lambda d1, d2: d1 +  d2, distances, 0)
    average_distance = distance_score / len(places)
    variance_score = math.sqrt(reduce(lambda s, d: s + (d - average_distance)**2, distances, 0))
    return distance_score + variance_score, center
Пример #2
0
def updateMeetupScore(total_distance, total_variance, center, numUsers, place):
    place_point = randomPointInRegion(place["bounds"])
    center_sum = (center[0] * numUsers, center[1] * numUsers)
    print "%s %s %s"%(place["key"],center, place_point)
    new_center = ((center_sum[0] + place_point[0]) / (numUsers + 1), (center_sum[1] + place_point[1]) / (numUsers + 1))
    distance = distanceBetweenLatLongs(new_center, place_point)
    new_distance = total_distance + distance
    average_distance = new_distance / (numUsers + 1)
    new_variance = math.sqrt(total_variance**2 + (distance - average_distance)**2)

    return new_distance, new_variance, new_center
Пример #3
0
def updateMeetupScore(total_distance, total_variance, center, numUsers, place):
    place_point = randomPointInRegion(place["bounds"])
    center_sum = (center[0] * numUsers, center[1] * numUsers)
    print "%s %s %s" % (place["key"], center, place_point)
    new_center = ((center_sum[0] + place_point[0]) / (numUsers + 1),
                  (center_sum[1] + place_point[1]) / (numUsers + 1))
    distance = distanceBetweenLatLongs(new_center, place_point)
    new_distance = total_distance + distance
    average_distance = new_distance / (numUsers + 1)
    new_variance = math.sqrt(total_variance**2 +
                             (distance - average_distance)**2)

    return new_distance, new_variance, new_center
Пример #4
0
def scoreMeetup(places):
    if len(places) == 0:
        return 99999999
    center = centroid([(p["bounds"][0], p["bounds"][1]) for p in places])
    distances = [
        distanceBetweenLatLongs(center, (p["bounds"][0], p["bounds"][1]))
        for p in places
    ]
    distance_score = reduce(lambda d1, d2: d1 + d2, distances, 0)
    average_distance = distance_score / len(places)
    variance_score = math.sqrt(
        reduce(lambda s, d: s + (d - average_distance)**2, distances, 0))
    return distance_score + variance_score, center