plafosim.platoon module
- class plafosim.platoon.Platoon(platoon_id: int, formation: list, desired_speed: float)[source]
Bases:
object
A collection of parameters for a specific platoon.
- __init__(platoon_id: int, formation: list, desired_speed: float)[source]
Initialize a platoon instance.
- Parameters:
platoon_id (int) – The id of the platoon
formation (list) – The list of PlatooningVehicles within the platoon
desired_speed (float) – The platoon’s desired driving speed
- get_back(vehicle: PlatooningVehicle)[source]
Return the PlatooningVehicle in the back.
- Parameters:
vehicle (PlatooningVehicle) – The considered vehicle within the platoon.
- Returns:
PlatooningVehicle
- Return type:
The member in the back
- get_front(vehicle: PlatooningVehicle)[source]
Return the PlatooningVehicle in the front.
- Parameters:
vehicle (PlatooningVehicle) – The considered vehicle within the platoon.
- Returns:
PlatooningVehicle
- Return type:
The member in the front
- get_member_index(vehicle: PlatooningVehicle) int [source]
Return the index of a member within the platoon.
- Parameters:
vehicle (PlatooningVehicle) – The considered vehicle within the platoon.
- Returns:
int
- Return type:
The index of the member within the platoon
- update_desired_speed()[source]
Update the desired driving speed of the platoon.
This is based on the desired driving speed of all members.
- update_max_acceleration()[source]
Update the maximum acceleration of the platoon.
The maximum acceleration is based on the slowest vehicle within the platoon.
- update_max_deceleration()[source]
Update the maximum deceleration of the platoon.
The maximum deceleration is based on the slowest vehicle within the platoon.
- update_max_speed()[source]
Update the maximum speed of the platoon.
The maximum speed is based on the slowest vehicle within the platoon.
- property desired_speed: float
Return the desired driving speed of the platoon.
- property formation: list
Return the complete formation of the platoon.
- property lane: int
Return the current lane of the platoon.
- property last: PlatooningVehicle
Return the last PlatooningVehicle of the platoon.
- property leader: PlatooningVehicle
Return the leading PlatoonVehicle of the platoon.
- property length: float
Return the length of the platoon.
- property max_acceleration: float
Return the maximum acceleration of the platoon.
The maximum acceleration is based on the slowest vehicle within the platoon.
- property max_deceleration: float
Return the maximum deceleration of the platoon.
The maximum deceleration is based on the slowest vehicle within the platoon.
- property max_speed: float
Return the maximum speed of the platoon.
The maximum speed is based on the slowest vehicle within the platoon.
- property member_ids: list
Return the ids of all platoon members.
- property platoon_id: int
Return the id of the platoon.
- property position: int
Return the current position of the platoon.
- property rear_position: int
Return the current rear position of the platoon.
- property size: int
Return the size of the platoon.
- property speed: float
Return the current driving speed of the platoon.
- plafosim.platoon.mean(data)[source]
Return the sample arithmetic mean of data.
>>> mean([1, 2, 3, 4, 4]) 2.8
>>> from fractions import Fraction as F >>> mean([F(3, 7), F(1, 21), F(5, 3), F(1, 3)]) Fraction(13, 21)
>>> from decimal import Decimal as D >>> mean([D("0.5"), D("0.75"), D("0.625"), D("0.375")]) Decimal('0.5625')
If
data
is empty, StatisticsError will be raised.