common#
ae_util#
- calculate_capacities(capacities: ndarray, layouts: ndarray) ndarray #
- fill_project(project: ProjectWrapper, demand_nodes: PointEntity, demand_links: VirtualLinkEntity, transport_nodes: PointEntity, transport_segments: TransportSegmentEntity)#
- get_capacities_from_attribute(capacity_attribute: UniformAttribute, layout_attribute: UniformAttribute | None = None) ndarray #
- get_cargo_allowed_from_attribute(cargo_allowed_attribute: UniformAttribute) ndarray #
- get_demand_links(segments: VirtualLinkEntity) LinkCollection #
- get_demand_nodes(demand_nodes: PointEntity, point_generator: PointGenerator) NodeCollection #
- get_links(segments: TransportSegmentEntity) LinkCollection #
- get_max_speeds_from_attribute(max_speed_attribute: UniformAttribute) ndarray #
- get_nodes(nodes: PointEntity, point_generator: PointGenerator) NodeCollection #
- get_transport_directions(segments: TransportSegmentEntity) ndarray #
attributes#
csv_tape#
- class BaseTapefile(timeline_info: TimelineInfo | None = None)#
Bases:
object
- get_data(key: str)#
- has_update()#
- set_timeline(seconds: ndarray)#
- class CsvTape(timeline_info: TimelineInfo | None = None)#
Bases:
BaseTapefile
- assert_parameter(parameter_name)#
- get_data(key: str) float #
- initialize(csv: DataFrame, time_column: str = 'seconds')#
entity_groups#
- class GeometryEntity(name: str | None = None)#
Bases:
EntityGroup
- attributes: t.Dict[str, attribute.AttributeField] = {'reference': <movici_simulation_core.core.attribute.AttributeField object>}#
- dimensions()#
- ensure_ready() None #
- get_geometry(slice=None) Geometry #
- get_single_geometry(index: int) BaseGeometry #
- is_ready()#
- reference#
- class GridCellEntity(name: str | None = None)#
Bases:
GeometryEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'grid_points': <movici_simulation_core.core.attribute.AttributeField object>}#
- get_geometry(slice=None) ClosedPolygonGeometry #
- get_single_geometry(index: int) Polygon #
- grid_points#
- is_ready()#
- points: PointEntity | None = None#
- set_points(points: PointEntity)#
- class LineEntity(name: str | None = None)#
Bases:
GeometryEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'_linestring2d': <movici_simulation_core.core.attribute.AttributeField object>, '_linestring3d': <movici_simulation_core.core.attribute.AttributeField object>}#
- dimensions()#
- get_geometry(slice=None) LinestringGeometry #
- get_single_geometry(index: int) LineString #
- is_ready() bool #
- property linestring: CSRAttribute#
- class LinkEntity(name: str | None = None)#
Bases:
LineEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'from_node_id': <movici_simulation_core.core.attribute.AttributeField object>, 'to_node_id': <movici_simulation_core.core.attribute.AttributeField object>}#
- from_node_id#
- to_node_id#
- class PointEntity(name: str | None = None)#
Bases:
GeometryEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'x': <movici_simulation_core.core.attribute.AttributeField object>, 'y': <movici_simulation_core.core.attribute.AttributeField object>, 'z': <movici_simulation_core.core.attribute.AttributeField object>}#
- dimensions()#
- get_geometry(slice=None) PointGeometry #
- get_single_geometry(index: int) Point #
- is_ready()#
- x#
- y#
- z#
- class PolygonEntity(name: str | None = None)#
Bases:
GeometryEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'_polygon2d': <movici_simulation_core.core.attribute.AttributeField object>, '_polygon3d': <movici_simulation_core.core.attribute.AttributeField object>, '_polygon_legacy': <movici_simulation_core.core.attribute.AttributeField object>}#
- dimensions()#
- get_geometry(slice=None) ClosedPolygonGeometry #
- get_single_geometry(index: int) Polygon #
- is_ready() bool #
- property polygon: CSRAttribute#
- class TransportLinkEntity(name: str | None = None)#
Bases:
LinkEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'layout': <movici_simulation_core.core.attribute.AttributeField object>}#
- layout#
- class TransportSegmentEntity(name: str | None = None)#
Bases:
LinkEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'_max_speed': <movici_simulation_core.core.attribute.AttributeField object>, 'capacity': <movici_simulation_core.core.attribute.AttributeField object>, 'layout': <movici_simulation_core.core.attribute.AttributeField object>}#
- capacity#
- layout#
- property max_speed#
- class VirtualLinkEntity(name: str | None = None)#
Bases:
LinkEntity
- attributes: t.Dict[str, attribute.AttributeField] = {'capacity': <movici_simulation_core.core.attribute.AttributeField object>, 'max_speed': <movici_simulation_core.core.attribute.AttributeField object>}#
- capacity#
- max_speed#
- delayed_raise(err: Exception)#
model_util#
- find_y_in_x(x: ndarray, y: ndarray)#
find position of y in x, adapted from https://stackoverflow.com/a/8251757
- get_transport_info(model_config: Dict[str, List[str] | None]) Tuple[str, str] #
- safe_divide(numerator, denominator, fill_value=None)#
- try_get_geometry_type(geometry_type)#
network#
- class Graph(indptr, indices, cost_factor_indices)#
Bases:
object
- get_cost(source_idx, target_idx)#
- get_neighbours(source_index)#
- update_cost_factor(cost_factor)#
- class Network(transport_nodes: PointEntity, transport_links: TransportSegmentEntity, virtual_nodes: PointEntity | None, virtual_links: LinkEntity | None, cost_factor: ndarray | None = None)#
Bases:
object
Representation of a transport network containing transport nodes and -links and virtual nodes and -links. Virtual nodes can be used as source and target nodes for the the network
- MAX_COST_FACTOR = inf#
- MIN_COST_FACTOR = 1e-12#
- all_shortest_paths(virtual_node_ids: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None)#
Compute the shortest path distance between all virtual nodes
- all_shortest_paths_sum(values, virtual_node_ids=None, no_path_found=-1)#
Calculate the sum of a quantity that is defined for every link on the shortest path from all source (virtual) nodes to all target (virtual) nodes. When the source node and the target node are the same, the summed value equals 0
- Parameters:
values – an array (or array-like) with the quantity values on transport links that are to be summed
no_path_found – A fill value for when no valid shortest path can be found between source and target.
- all_shortest_paths_weighted_average(values, virtual_node_ids=None, weights=None, no_path_found=-1)#
Calculate the weighted average of a quantity that is defined for every link on the shortest path from all source (virtual) nodes to all target (virtual) nodes. The average is weighted by the cost factor of every link on the shortest path
- Parameters:
values – an array (or array-like) with the quantity values on transport links that are to be averaged
virtual_node_ids – an array (or array-like) for which virtual nodes to calculate the weighted averages
weights – (optional) an array with alternative weights to calculate the weighted average. By default the network cost factor is used for both calculating the shortest path and as weights for the weighted average. Supplying this attributes makes it possible to calculate the shortest path by cost factor (eg. travel time) and the weighted average by a different attribute (eg. length). This array should have the same length as the cost_factor array
no_path_found – A fill value for when no valid shortest path can be found between source and target. This is also used for when the source and target node are the same
- property cost_factor#
- get_shortest_path(source_node_id: int)#
see https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.shortest_path.html for more information.
:returns a (dist, prev) tuple
- initialize_cost_factor()#
- process_transport_links(transport_links: TransportSegmentEntity)#
- process_virtual_links(virtual_links: LinkEntity)#
- classmethod register_required_attributes(state: TrackedState, dataset_name: str, transport_segments_name: str, entities: Dict[str, EntityGroup | Type[EntityGroup]] | None = None) NetworkEntities #
- set_source_node(source_node_id: int)#
Set the current source node for a shortest path calculation, this must be a virtual node id
- set_virtual_node_outgoing_cost_factor(vn_index, value)#
- shortest_path_sum(source_node_id, values, no_path_found=-1, values_are_mapped=False)#
Calculate the sum of a quantity that is defined for every link on the shortest path from a source node to all target (virtual) nodes. When the source node and the target node are the same, the summed value equals 0
- Parameters:
source_node_id – The entity id of the source (virtual) node
values – See Network.all_shortest_paths_weighted_average
no_path_found – See Network.all_shortest_paths_weighted_average
values_are_mapped – A boolean indicating whether the value array is in their original order or already mapped to the corresponding link index in the graph (default: False). This is usually False
- shortest_path_weighted_average(source_node_id, values, weights=None, no_path_found=-1, values_are_mapped=False)#
Calculate the weighted average of a quantity that is defined for every link on the shortest path from a source node to all target (virtual) nodes. The average is weighted by the cost factor of every link on the shortest path
- Parameters:
source_node_id – The entity id of the source (virtual) node
values – See
Network.all_shortest_paths_weighted_average
weights – See
Network.all_shortest_paths_weighted_average
no_path_found – See
Network.all_shortest_paths_weighted_average
values_are_mapped – A boolean indicating whether the value array is in their original order or already mapped to the corresponding link index in the graph (default: False). This is usually
False
- source_node_idx = None#
- tl_count = 0#
- tl_from_node_id: ndarray | None = None#
- tl_mapping: ndarray | None = None#
- tl_to_node_id: ndarray | None = None#
- update_cost_factor(cost_factor=None)#
- vl_cost_factor: ndarray | None = None#
- vl_count = 0#
- vl_directionality: ndarray | None = None#
- vl_from_node_id: ndarray | None = None#
- vl_to_node_id: ndarray | None = None#
- vn_ids: ndarray | None = None#
- class NetworkEntities#
Bases:
TypedDict
- transport_links: TransportSegmentEntity#
- transport_nodes: PointEntity#
- virtual_links: LinkEntity#
- virtual_nodes: PointEntity#
- build_graph(node_idx: Index, from_node_id, to_node_id)#
- Parameters:
node_idx – the Index with all node ids
from_node_id – an array with source node id for every edge
to_node_id – an array with target node id for every edge
- Returns:
a tuple of indptr, indices and edge_indices: where indptr and indices form the graph and edge_indices are the positions of the graph data (cost factor) in the original edge data such that cost_factor = original_cost_factor[edge_indices]
- link_indices(indptr, indices, from_idx, to_idx)#
return the indices of all links in a csr sparse network going from from_idx to to_idx
- shortest_link_index(indptr, indices, from_idx, to_idx, cost_factor)#
time_series#
- class TimeSeries(iterable: Iterable[Tuple[int, T]] = ())#
Bases:
list
,List
[Tuple
[int
,T
]]- property next_time#
- pop_until(timestamp: int) Iterable[Tuple[int, T]] #
- sort()#
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
Module contents#
- class CsvTape(timeline_info: TimelineInfo | None = None)#
Bases:
BaseTapefile
- assert_parameter(parameter_name)#
- get_data(key: str) float #
- initialize(csv: DataFrame, time_column: str = 'seconds')#
- class Graph(indptr, indices, cost_factor_indices)#
Bases:
object
- get_cost(source_idx, target_idx)#
- get_neighbours(source_index)#
- update_cost_factor(cost_factor)#
- class Network(transport_nodes: PointEntity, transport_links: TransportSegmentEntity, virtual_nodes: PointEntity | None, virtual_links: LinkEntity | None, cost_factor: ndarray | None = None)#
Bases:
object
Representation of a transport network containing transport nodes and -links and virtual nodes and -links. Virtual nodes can be used as source and target nodes for the the network
- MAX_COST_FACTOR = inf#
- MIN_COST_FACTOR = 1e-12#
- all_shortest_paths(virtual_node_ids: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None)#
Compute the shortest path distance between all virtual nodes
- all_shortest_paths_sum(values, virtual_node_ids=None, no_path_found=-1)#
Calculate the sum of a quantity that is defined for every link on the shortest path from all source (virtual) nodes to all target (virtual) nodes. When the source node and the target node are the same, the summed value equals 0
- Parameters:
values – an array (or array-like) with the quantity values on transport links that are to be summed
no_path_found – A fill value for when no valid shortest path can be found between source and target.
- all_shortest_paths_weighted_average(values, virtual_node_ids=None, weights=None, no_path_found=-1)#
Calculate the weighted average of a quantity that is defined for every link on the shortest path from all source (virtual) nodes to all target (virtual) nodes. The average is weighted by the cost factor of every link on the shortest path
- Parameters:
values – an array (or array-like) with the quantity values on transport links that are to be averaged
virtual_node_ids – an array (or array-like) for which virtual nodes to calculate the weighted averages
weights – (optional) an array with alternative weights to calculate the weighted average. By default the network cost factor is used for both calculating the shortest path and as weights for the weighted average. Supplying this attributes makes it possible to calculate the shortest path by cost factor (eg. travel time) and the weighted average by a different attribute (eg. length). This array should have the same length as the cost_factor array
no_path_found – A fill value for when no valid shortest path can be found between source and target. This is also used for when the source and target node are the same
- property cost_factor#
- get_shortest_path(source_node_id: int)#
see https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.shortest_path.html for more information.
:returns a (dist, prev) tuple
- initialize_cost_factor()#
- process_transport_links(transport_links: TransportSegmentEntity)#
- process_virtual_links(virtual_links: LinkEntity)#
- classmethod register_required_attributes(state: TrackedState, dataset_name: str, transport_segments_name: str, entities: Dict[str, EntityGroup | Type[EntityGroup]] | None = None) NetworkEntities #
- set_source_node(source_node_id: int)#
Set the current source node for a shortest path calculation, this must be a virtual node id
- set_virtual_node_outgoing_cost_factor(vn_index, value)#
- shortest_path_sum(source_node_id, values, no_path_found=-1, values_are_mapped=False)#
Calculate the sum of a quantity that is defined for every link on the shortest path from a source node to all target (virtual) nodes. When the source node and the target node are the same, the summed value equals 0
- Parameters:
source_node_id – The entity id of the source (virtual) node
values – See Network.all_shortest_paths_weighted_average
no_path_found – See Network.all_shortest_paths_weighted_average
values_are_mapped – A boolean indicating whether the value array is in their original order or already mapped to the corresponding link index in the graph (default: False). This is usually False
- shortest_path_weighted_average(source_node_id, values, weights=None, no_path_found=-1, values_are_mapped=False)#
Calculate the weighted average of a quantity that is defined for every link on the shortest path from a source node to all target (virtual) nodes. The average is weighted by the cost factor of every link on the shortest path
- Parameters:
source_node_id – The entity id of the source (virtual) node
values – See
Network.all_shortest_paths_weighted_average
weights – See
Network.all_shortest_paths_weighted_average
no_path_found – See
Network.all_shortest_paths_weighted_average
values_are_mapped – A boolean indicating whether the value array is in their original order or already mapped to the corresponding link index in the graph (default: False). This is usually
False
- source_node_idx = None#
- tl_count = 0#
- tl_from_node_id: ndarray | None = None#
- tl_mapping: ndarray | None = None#
- tl_to_node_id: ndarray | None = None#
- update_cost_factor(cost_factor=None)#
- vl_cost_factor: ndarray | None = None#
- vl_count = 0#
- vl_directionality: ndarray | None = None#
- vl_from_node_id: ndarray | None = None#
- vl_to_node_id: ndarray | None = None#
- vn_ids: ndarray | None = None#
- class TimeSeries(iterable: Iterable[Tuple[int, T]] = ())#
Bases:
list
,List
[Tuple
[int
,T
]]- property next_time#
- pop_until(timestamp: int) Iterable[Tuple[int, T]] #
- sort()#
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- build_graph(node_idx: Index, from_node_id, to_node_id)#
- Parameters:
node_idx – the Index with all node ids
from_node_id – an array with source node id for every edge
to_node_id – an array with target node id for every edge
- Returns:
a tuple of indptr, indices and edge_indices: where indptr and indices form the graph and edge_indices are the positions of the graph data (cost factor) in the original edge data such that cost_factor = original_cost_factor[edge_indices]
- find_y_in_x(x: ndarray, y: ndarray)#
find position of y in x, adapted from https://stackoverflow.com/a/8251757
- get_transport_info(model_config: Dict[str, List[str] | None]) Tuple[str, str] #
- safe_divide(numerator, denominator, fill_value=None)#
- try_get_geometry_type(geometry_type)#