plafosim.algorithms package
Submodules
- plafosim.algorithms.dummy module
- plafosim.algorithms.speed_position module
FormationAlgorithm
PlatoonRole
SpeedPosition
SpeedPosition.__init__()
SpeedPosition._do_formation_centralized()
SpeedPosition._do_formation_distributed()
SpeedPosition._do_formation_optimal()
SpeedPosition._record_infrastructure_assignments()
SpeedPosition.add_parser_argument_group()
SpeedPosition.cost_speed_position()
SpeedPosition.do_formation()
SpeedPosition.dp()
SpeedPosition.ds()
SpeedPosition.finish()
SpeedPosition._abc_impl
SpeedPosition.name
initialize_infrastructure_assignments()
initialize_solver_traces()
record_solver_trace()
strtobool()
timer()
Module contents
- class plafosim.algorithms.Dummy(owner: object, dummy: int = -1, **kw_args)[source]
Bases:
FormationAlgorithm
Dummy Platoon Formation Algorithm.
- __init__(owner: object, dummy: int = -1, **kw_args)[source]
Initialize an instance of this formation algorithm to be used in a vehicle or an infrastructure.
- Parameters:
owner (object) – The owning object that is execution this algorithm. This can be either a PlatooningVehicle or an Infrastructure.
dummy (int, optional) – The value for the dummy parameter
- classmethod add_parser_argument_group(parser: ArgumentParser) _ArgumentGroup [source]
Create and return specific argument group for this algorithm to use in global argument parser.
- Parameters:
parser (argparse.ArgumentParser) – The global argument parser
- Returns:
The specific argument group for this algorithm
- Return type:
argparse._ArgumentGroup
- do_formation()[source]
Run platoon formation algorithm to search for a platooning opportunity and perform the corresponding join maneuver.
- finish()[source]
Clean up the instance of the formation algorithm.
This includes mostly statistic recording.
- _abc_impl = <_abc_data object>
- property name
Print the name of the formation algorithm.
- class plafosim.algorithms.FormationAlgorithm(owner: object)[source]
Bases:
ABC
Abstract base class for any type of platoon formation algorithm (i.e., assignment calculation).
Implementing sub-classes need to override the do_formation() method.
- __init__(owner: object)[source]
Initialize an instance of a formation algorithm.
- Parameters:
owner (object) – The owning object that is execution this algorithm. This can be either a PlatooningVehicle or an Infrastructure.
- abstract add_parser_argument_group(parser: ArgumentParser) _ArgumentGroup [source]
Abstract method for performing any type of platoon formation (i.e., assignment calculation).
This methods needs to be overridden in implementing sub-classes.
- Returns:
The specific argument group for this algorithm.
- Return type:
argparse._ArgumentGroup
- abstract do_formation()[source]
Abstract method for performing any type of platoon formation (i.e., assignment calculation).
This methods needs to be overridden in implementing sub-classes.
- _abc_impl = <_abc_data object>
- property name
Print the name of the formation algorithm.
- class plafosim.algorithms.SpeedPosition(owner: object, alpha: float = 0.5, speed_deviation_threshold: float = 0.2, position_deviation_threshold: int = 1000, formation_centralized_kind: str = 'greedy', solver_time_limit: int = 60, record_solver_traces: bool = False, record_infrastructure_assignments: bool = False, **kw_args)[source]
Bases:
FormationAlgorithm
Platoon Formation Algorithm based on Similarity, considering Speed and Position.
See papers
Julian Heinovski and Falko Dressler, “Where to Decide? Centralized vs. Distributed Vehicle Assignment for Platoon Formation,” arXiv, cs.MA, 2310.09580, October 2023. https://www.tkn.tu-berlin.de/bib/heinovski2023where-preprint/
and
Julian Heinovski and Falko Dressler, “Platoon Formation: Optimized Car to Platoon Assignment Strategies and Protocols,” Proceedings of 10th IEEE Vehicular Networking Conference (VNC 2018), Taipei, Taiwan, December 2018. https://www.tkn.tu-berlin.de/bib/heinovski2018platoon/
- __init__(owner: object, alpha: float = 0.5, speed_deviation_threshold: float = 0.2, position_deviation_threshold: int = 1000, formation_centralized_kind: str = 'greedy', solver_time_limit: int = 60, record_solver_traces: bool = False, record_infrastructure_assignments: bool = False, **kw_args)[source]
Initialize an instance of this formation algorithm to be used in a vehicle or an infrastructure.
- Parameters:
owner (object) – The owning object that is execution this algorithm. This can be either a PlatooningVehicle or an Infrastructure.
alpha (float) – The weighting factor alpha
speed_deviation_threshold (float) – The threshold for speed deviation
position_deviation_threshold (int) – The threshold for position deviation
formation_centralized_kind (str) – TODO
solver_time_limit (int) – The time limit in s to apply to the solver
record_solver_traces (bool) – Whether to record continuous solver traces
record_infrastructure_assignments (bool) – Whether to record infrastructure assignments
- _do_formation_centralized()[source]
Run centralized greedy formation approach.
This selects candidates and triggers join maneuvers.
- _do_formation_distributed()[source]
Run distributed greedy formation approach.
This selects a candidate and triggers a join maneuver.
- _do_formation_optimal()[source]
Run centralized optimal formation approach.
This selects candidates and triggers join maneuvers.
- _record_infrastructure_assignments(basename: str)[source]
Record infrastructure assignments.
- Parameters:
basename (str) – The basename of the result file
- classmethod add_parser_argument_group(parser: ArgumentParser) _ArgumentGroup [source]
Create and return specific argument group for this algorithm to use in global argument parser.
- Parameters:
parser (argparse.ArgumentParser) – The global argument parser
- Returns:
The specific argument group for this algorithm
- Return type:
argparse._ArgumentGroup
- cost_speed_position(ds: float, dp: float) float [source]
Return the overall cost (i.e., the weighted deviation) for a candidate.
- Parameters:
ds (float) – The deviation in speed
dp (int) – The deviation in position
- Returns:
The weighted relative deviation
- Return type:
float
- do_formation()[source]
Run platoon formation algorithms to search for a platooning opportunity and perform the corresponding join maneuver.
- dp(vehicle: PlatooningVehicle, platoon: Platoon) float [source]
Return the deviation in position from a given platoon.
NOTE: In the original version of the paper, the deviation calculated here was not normalized.
- Parameters:
vehicle (PlatooningVehicle) – The vehicle for which the deviation is calculated
platoon (Platoon) – The platoon to which the deviation is calculated
- Returns:
The relative deviation in position
- Return type:
float
- ds(vehicle: PlatooningVehicle, platoon: Platoon) float [source]
Return the deviation in speed from a given platoon.
NOTE: In the original version of the paper, the deviation calculated here was not normalized.
- Parameters:
vehicle (PlatooningVehicle) – The vehicle for which the deviation is calculated
platoon (Platoon) – The platoon to which the deviation is calculated
- Returns:
The relative deviation in speed
- Return type:
float
- finish()[source]
Clean up the instance of the formation algorithm.
This includes mostly statistic recording.
- _abc_impl = <_abc_data object>
- property name
Print the name of the formation algorithm.
- plafosim.algorithms.attribute()
perf_counter() -> float
Performance counter for benchmarking.
- plafosim.algorithms.import_module(name, package=None)[source]
Import a module.
The ‘package’ argument is required when performing a relative import. It specifies the package to use as the anchor point from which to resolve the relative import to an absolute import.
- plafosim.algorithms.isclass(object)[source]
Return true if the object is a class.
- Class objects provide these attributes:
__doc__ documentation string __module__ name of module in which this class was defined
- plafosim.algorithms.iter_modules(path=None, prefix='')[source]
Yields ModuleInfo for all submodules on path, or, if path is None, all top-level modules on sys.path.
‘path’ should be either None or a list of paths to look for modules in.
‘prefix’ is a string to output on the front of every module name on output.