plafosim.spawning module
- plafosim.spawning.get_arrival_position(depart_position: int, road_length: int, ramp_interval: int, min_trip_length: int, max_trip_length: int, rng: Random, random_arrival_position: bool = False, pre_fill: bool = False) int [source]
Return a (random) arrival position for a given departure position.
This considers the ramp interval, road length, and minimum trip length.
- Parameters:
depart_position (int) – The departure position to consider
road_length (int) – The length of the entire road
ramp_interval (int) – The distance between two on-/off-ramps
min_trip_length (int) – The minimum trip length
max_trip_length (int) – The maximum trip length
rng (random.Random) – The random number generator to use
random_arrival_position (bool) – Whether to use random arrival positions
pre_fill (bool, optional) – Whether the trip is for a pre-filled vehicle
- Returns:
The arrival position in m
- Return type:
int
- plafosim.spawning.get_depart_speed(desired_speed: float, rng: Random, depart_desired: bool = False, random_depart_speed: bool = False) float [source]
Return a (random) departure speed.
- Parameters:
desired_speed (float) – The desired speed to consider
rng (random.Random) – The random number generator to use
depart_desired (bool, optional) – Whether to depart with the desired speed
random_depart_speed (bool, optional) – Whether to choose a random value from a range
- Returns:
The value for the departure speed
- Return type:
float
- plafosim.spawning.get_desired_speed(desired_speed: float, rng: Random, speed_variation: float, min_desired_speed: float, max_desired_speed: float, random_desired_speed: bool = False) float [source]
Return a (random) desired driving speed.
- Parameters:
desired_speed (float) – The value to be used as is or as the mean for sampling from a normal distribution
rng (random.Random) – The random number generator to use
speed_variation (float) – The value to be used as variation for sampling from a normal distribution
min_desired_speed (float) – The minimum allowed value for the desired driving speed
max_desired_speed (float) – The maximum allowed value for the desired driving speed
random_desired_speed (bool, optional) – Whether to choose a random value from a normal distribution
- Returns:
The value for the desired driving speed
- Return type:
float