def disaggregate_odflow( self, time_start, time_end, id_mode, id_zone_orig, id_zone_dest, tripnumber, probs_fac, ids_fac, id_landusetype_orig, id_landusetype_dest, ): print 'disaggregate_odflow', time_start, time_end, id_mode, id_zone_orig, id_zone_dest, tripnumber """ Disaggregation of demand dem from taz id_zone_orig to id_zone_dest with id_mode during time interval time_start,time_end, and creation of persons which are parameterized accordingly. The facility type at origin will be landusetype_orig and at destination landusetype_dest. The probability vector to start/end the trip in the different facilities of facility type id_landusetype_orig/id_landusetype_dest is given by the dictionary probs_fac[id_zone][id_landusetype]. The ids_fac is an array that contains the facility ids in correspondence to the probability vector. These information are obtained from probs_fac, ids_fac = landuse.get_departure_probabilities() """ print 'disaggregate_odm', tripnumber, id_mode, id_zone_orig, id_zone_dest probs_orig = probs_fac[id_zone_orig][id_landusetype_orig] probs_dest = probs_fac[id_zone_dest][id_landusetype_dest] print ' probs_orig', sum(probs_orig) # ,'\n',probs_orig print ' probs_dest', sum(probs_dest) # ,'\n',probs_dest # is there a chance to find facilities to locate persons in # origin and destination zone # print ' ',self.times_start.value.dtype,np.random.randint(time_start,time_end,tripnumber) # print ' ',self.ids_mode_preferred.value.dtype,id_mode * # np.ones(tripnumber, np.int32), if (np.sum(probs_orig) > 0) & (np.sum(probs_dest) > 0): return self.add_rows( n=tripnumber, ids_fac_home=ids_fac[random_choice(tripnumber, probs_orig)], ids_fac_activity=ids_fac[random_choice(tripnumber, probs_dest)], ids_mode_preferred=id_mode * np.ones(tripnumber, dtype=np.int32), times_start=np.random.randint(time_start, time_end, tripnumber)) else: return []
def disaggregate_odflow(self, time_start, time_end, id_mode, id_zone_orig, id_zone_dest, tripnumber, probs_fac, ids_fac, id_landusetype_orig, id_landusetype_dest,): print 'disaggregate_odflow', time_start, time_end, id_mode, id_zone_orig, id_zone_dest, tripnumber """ Disaggregation of demand dem from taz id_zone_orig to id_zone_dest with id_mode during time interval time_start,time_end, and creation of persons which are parameterized accordingly. The facility type at origin will be landusetype_orig and at destination landusetype_dest. The probability vector to start/end the trip in the different facilities of facility type id_landusetype_orig/id_landusetype_dest is given by the dictionary probs_fac[id_zone][id_landusetype]. The ids_fac is an array that contains the facility ids in correspondence to the probability vector. These information are obtained from probs_fac, ids_fac = landuse.get_departure_probabilities() """ print 'disaggregate_odm', tripnumber, id_mode, id_zone_orig, id_zone_dest probs_orig = probs_fac[id_zone_orig][id_landusetype_orig] probs_dest = probs_fac[id_zone_dest][id_landusetype_dest] print ' probs_orig', sum(probs_orig) # ,'\n',probs_orig print ' probs_dest', sum(probs_dest) # ,'\n',probs_dest # is there a chance to find facilities to locate persons in # origin and destination zone # print ' ',self.times_start.value.dtype,np.random.randint(time_start,time_end,tripnumber) # print ' ',self.ids_mode_preferred.value.dtype,id_mode * # np.ones(tripnumber, np.int32), if (np.sum(probs_orig) > 0) & (np.sum(probs_dest) > 0): return self.add_rows(n=tripnumber, ids_fac_home=ids_fac[ random_choice(tripnumber, probs_orig)], ids_fac_activity=ids_fac[ random_choice(tripnumber, probs_dest)], ids_mode_preferred=id_mode * np.ones(tripnumber, dtype=np.int32), times_start=np.random.randint( time_start, time_end, tripnumber) ) else: return []
def get_modes_random(self, n): """ Return a vector with mode IDs of length n. """ ids = self.get_ids() ids_modes_all = self.ids_mode[ids] return ids_modes_all[random_choice(n, self.shares[ids])]