Trip Generators
Random Generators
from mosstool.trip.generator import RandomGenerator
RandomGenrator
generate specified number of persons
with random departure times and random visiting positions.
The initialization function of RandomGenerator
.
Args of RandomGenerator.__init__
m (Map)
: the mapposition_modes (List[PositionMode])
: the schedules generated will follow the position modes in this list, the generated person will visit modes of positions as specified.trip_mode (TripMode)
: the target trip modetemplate (Person)
: the template of generated person object, whoseschedules
,home
will be replaced and others will be copied
This function Generate persons following uniform distribution
Args of RandomGenerator.uniform
num (int)
: the number of person objects to generatefirst_departure_time_range (Tuple[float, float])
: the range of the first departure time (uniform random sampling)schedule_interval_range (Tuple[float, float])
: the range of the interval between schedules (uniform random sampling)seed (int)
: the random seed. Defaults to Nonestart_id (int)
: the start id of the generated person objects. Defaults to None. If None, theid
will be NOT set
OD-Matrix Generators
This model generate OD-matrix for trip generation.
Gravity model
from mosstool.trip.generator import GravityGenerator
Args of GravityGenerator.__init__
Lambda, Alpha, Beta, Gamma (float):
the parameters of Gravity model.
Args of GravityGenerator.load_area
area (GeoDataFrame)
: the area data as origins and destinations.
Args of GravityGenerator.generate
pop (list[int])
: the population of each area, consistent with the order ofarea
.
Realistic Generators by Diffusion Models Based on Public Data
from mosstool.trip.generator import AigcGenerator
Args of AigcGenerator.__init__
Lambda, Alpha, Beta, Gamma (float):
the parameters of Gravity model.
Args of AigcGenerator.set_satetoken
satetoken (str)
: set the satetoken for the generator, token is used for World_Imagery, can be applied from ArcGIS (https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9)
Args of AigcGenerator.load_area
area (GeoDataFrame)
: the area data as origins and destinations.
OD-Matrix Based Generators
from mosstool.trip.generator.generate_from_od import TripGenerator
TripGenerator
generate specified number of persons
according to input OD matrix.
Args of TripGenerator.__init__
-
m (Map)
: the map -
pop_tif_path (str)
: path of world populationTIFF
-
template (Person)
: the template of generated person object, whoseschedules
,home
will be replaced and others will be copied -
add_pop (bool)
: if true andpop_tif_path
is valid, population ofAOI
will be calculated -
workers: (int)
: number of workers for multiprocessing of adding populations
Args of TripGenerator.generate_persons
od_matrix (numpy.ndarray)
: the OD matrixareas (GeoDataFrame)
: the area data as origins and destinations, consistent with the order ofod_matrix
.departure_time_curve(list[float])
: the departure time of a day (24h). The resolution must >=1hagent_num: (int)
: the number of person objects to generateseed (int)
: the random seed. Defaults to 0