:py:mod:`starling_sim.basemodel.topology.network_speeds` ======================================================== .. py:module:: starling_sim.basemodel.topology.network_speeds Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: starling_sim.basemodel.topology.network_speeds.NetworkEdgeSpeed starling_sim.basemodel.topology.network_speeds.ConstantSpeed starling_sim.basemodel.topology.network_speeds.SpeedByHighwayType starling_sim.basemodel.topology.network_speeds.SpeedByEdge .. py:class:: NetworkEdgeSpeed Bases: :py:obj:`abc.ABC` Abstract class for speed evaluation on topologies. .. py:property:: speeds_data Access the speeds data structure .. py:method:: __call__(u, v, d) -> float :abstractmethod: Get the edge's speed from the data stored in self._speeds_data :param u: origin node :param v: destination node :param d: edge data :return: speed in km/h .. py:class:: ConstantSpeed(speed: float) Bases: :py:obj:`NetworkEdgeSpeed` Evaluate a constant speed independently of the edge. .. py:method:: __call__(u, v, d) -> float Get the edge's speed from the data stored in self._speeds_data :param u: origin node :param v: destination node :param d: edge data :return: speed in km/h .. py:class:: SpeedByHighwayType(speeds_json_file: str) Bases: :py:obj:`NetworkEdgeSpeed` Evaluate the edge speed based on its "highway" tag. This class uses a speed mapper that maps "highway" tag values to speed values. The mapper has the following format: { : { "speed": } }. If a list of tags is provided, use the first one. If the tag ends with '_links' and is not found in the speed mapper, look for the tag value without the '_link' suffix. If the tag is still not found in the mapper, use the 'other' value of the mapper. .. py:method:: __call__(u, v, d) -> float Get the edge's speed from the data stored in self._speeds_data :param u: origin node :param v: destination node :param d: edge data :return: speed in km/h .. py:class:: SpeedByEdge(speeds_table_file: str) Bases: :py:obj:`NetworkEdgeSpeed` Evaluate speed individually for each network edge. This class uses a mapper that maps (origin, destination) tuples to speed values. The mapper is read from a CSV file that contains "origin", "destination" and "speed" columns. The mapper must contain exactly one value for each (directed) edge of the graph. .. py:method:: __call__(u, v, d) -> float Get the edge's speed from the data stored in self._speeds_data :param u: origin node :param v: destination node :param d: edge data :return: speed in km/h