Пример #1
0
 def __init__(self, new=False):
     self.new = new
     self.starting_points = []
     self.ending_points = []
     self.a_to_b = []
     self.num_trips = None
     self.radius = None
     self.amount_missed = 0
     self.starting_counter = esmmc.Counter()
     self.ending_counter = esmmc.Counter()
     self.mode_counter = esmmc.Counter()
     self.prog_bar = ""
Пример #2
0
def get_succesor(user_id, place_id, time):
    temp = esmmc.Counter()
    day = time.weekday()
    place = get_common_place_from_db(place_id)
    for suc in place["successors"]:
        trip = esdctp.get_common_trip_from_db(user_id, place_id, suc)
        for temp_hour in xrange(time.hour, esdctp.HOURS_IN_DAY):
            counter_key = ("%s" % suc, temp_hour)
            temp[counter_key] = trip.probabilites[day, temp_hour]
    return boi.ObjectId(esmmc.sampleFromCounter(temp)[0])
Пример #3
0
def get_normalized_times(lst_of_trips):
    counter = emmc.Counter()
    i = 0
    for trip in lst_of_trips:
        counter[i] = get_time_of_trip(trip)
        i += 1
    counter.normalize()
    to_return = []
    for i in range(len(lst_of_trips)):
        to_return.append(counter[i])
    return to_return
Пример #4
0
 def get_successor(self):
     temp_counter = esmmc.Counter( )
     time = self.tm.time
     day = time.weekday()
     for suc in self.successors:
         suc_obj = self.tm.get_location(suc)
         edge = self.tm.get_edge(self, suc_obj)
         for temp_hour in xrange(time.hour, HOURS_IN_DAY):
             counter_key = (suc_obj, temp_hour, edge.get_rough_time_duration())
             temp_counter[counter_key] = edge.probabilities[day, temp_hour]
     return esmmc.sampleFromCounter(temp_counter)
Пример #5
0
    def __init__(self, has_bike=False):
        self.utilities = emmc.Counter()
        self.has_bike = has_bike
        self.user_base = the_base

        self.user_base.add_user(self)

        ## Initialize utilities
        self.utilities["sweat"] = 0
        self.utilities["scenery"] = 0
        self.utilities["social"] = 0
        self.utilities["time"] = 0
Пример #6
0
def get_normalized_beauty(lst_of_trips):
    counter = emmc.Counter()
    i = 0
    for trip in lst_of_trips:
        factor = get_beauty_score_of_trip(trip)
        print("beauty_factor : %s" % factor)
        counter[i] = factor
        i += 1
    counter.normalize()
    to_return = []
    for i in range(len(lst_of_trips)):
        to_return.append(counter[i])
    return to_return
Пример #7
0
def get_normalized_sweat(lst_of_trips, testing=False):
    counter = emmc.Counter()
    i = 0
    for trip in lst_of_trips:
        factor = get_sweat_factor(trip, testing)
        print("sweat_factor : %s" % factor)
        counter[i] = factor
        i += 1
    counter.normalize()
    to_return = []
    for i in range(len(lst_of_trips)):
        to_return.append(counter[i])
    return to_return
Пример #8
0
 def normalize_sounds(self):
     counter = emmc.Counter()
     for k,v in self.time_to_noise.items():
         counter[k] = v
     counter.normalize()
     self.time_to_noise = counter
Пример #9
0
 def __init__(self, name, hour, day):
     self.hour = hour  ## An int 0-23 representing the hour
     self.name = name  ## The name of the place, important for equality
     self.day = day  ## 0-6 Monday-Sunday
     self.counter = esmmc.Counter(
     )  ## Reps successors and probabilities of each one