Beispiel #1
0
 def get_starting_ending_points(self):
     for _ in xrange(self.num_trips):
         start_addr = esmmc.sampleFromCounter(self.starting_counter)
         end_addr = esmmc.sampleFromCounter(self.ending_counter)
         self.starting_points.append(
             get_one_random_point_in_radius(start_addr, self.radius))
         self.ending_points.append(
             get_one_random_point_in_radius(end_addr, self.radius))
Beispiel #2
0
 def get_trips_from_a_to_b(self, user_id):
     curr_time = datetime.datetime.now()
     curr_month = curr_time.month
     curr_year = curr_time.year
     curr_minute = curr_time.minute
     for i in range(len(self.a_to_b)):
         curr_day = random.randint(1, 28)
         curr_hour = random.randint(0, 23)
         t = self.a_to_b[i]
         mode = esmmc.sampleFromCounter(self.mode_counter) ## Unsophisticated mode choice, Alexi would throw up
         try:
             self.prog_bar += "."
             print(self.prog_bar)
             rand_trip_id = random.random()
             rand_user_id = user_id if user_id else random.random()
             otp_trip = OTP(t[0], t[1], mode, write_day(curr_month, curr_day, curr_year), write_time(curr_hour, curr_minute), True)
             if self.new:
                 print("here")
                 otp_trip.turn_into_new_trip(user_id)
             else:
                 alt_trip = otp_trip.turn_into_trip("%s%s" % (rand_user_id, rand_trip_id), rand_user_id, rand_trip_id, True)   ## ids
                 save_trip_to_db(alt_trip)
         except PathNotFoundException:
             print("path not found")
             self.amount_missed += 1
         except urllib.error.HTTPError:
             print("server error")
             pass   
Beispiel #3
0
 def get_trips_from_a_to_b(self, user_id):
     curr_time = datetime.datetime.now()
     curr_month = curr_time.month
     curr_year = curr_time.year
     curr_minute = curr_time.minute
     for i in range(len(self.a_to_b)):
         curr_day = random.randint(1, 28)
         curr_hour = random.randint(0, 23)
         t = self.a_to_b[i]
         mode = esmmc.sampleFromCounter(
             self.mode_counter
         )  ## Unsophisticated mode choice, Alexi would throw up
         try:
             self.prog_bar += "."
             print self.prog_bar
             rand_trip_id = random.random()
             rand_user_id = user_id if user_id else random.random()
             otp_trip = OTP(t[0], t[1], mode,
                            write_day(curr_month, curr_day, curr_year),
                            write_time(curr_hour, curr_minute), True)
             if self.new:
                 print "here"
                 otp_trip.turn_into_new_trip(user_id)
             else:
                 alt_trip = otp_trip.turn_into_trip(
                     "%s%s" % (rand_user_id, rand_trip_id), rand_user_id,
                     rand_trip_id, True)  ## ids
                 save_trip_to_db(alt_trip)
         except PathNotFoundException:
             print "path not found"
             self.amount_missed += 1
         except urllib2.HTTPError:
             print "server error"
             pass
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])
Beispiel #5
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])
 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)
 def get_successor(self):
     return esmmc.sampleFromCounter(self.counter)
Beispiel #8
0
 def get_starting_ending_points(self):
     for _ in range(self.num_trips):
         start_addr = esmmc.sampleFromCounter(self.starting_counter)
         end_addr = esmmc.sampleFromCounter(self.ending_counter)
         self.starting_points.append(get_one_random_point_in_radius(start_addr, self.radius))
         self.ending_points.append(get_one_random_point_in_radius(end_addr, self.radius))
Beispiel #9
0
 def get_successor(self):
     return esmmc.sampleFromCounter(self.counter)