PRSG (Primary-Secondary Road-Network Graph Builder)#
The primary concrete graph builder that creates a distribution graph from clustered parcels and road network data.
- class shift.PRSG(groups: list[~shift.data_model.GroupModel], source_location: ~shift.data_model.GeoLocation, buffer: ~infrasys.quantities.Distance = <Quantity(20, 'meter')>, routing_strategy: ~shift.graph.routing.RoutingStrategy | None = None, secondary_strategy: ~shift.graph.secondary.SecondaryNetworkStrategy | None = None, offline: bool = False, snap_to_roads: bool = True, snap_threshold_m: float = 50.0)#
Bases:
OpenStreetGraphBuilderClass interface for Primary Road and Secondary Grid distribution graph builder.
It searches for available openstreet road network within an area defined by points + buffer. Primary network is built by applying a routing strategy (default: Steiner tree) on the road network connecting all nodes closest to the group centers, which will be treated as distribution transformer locations. Secondary network is built using a configurable secondary strategy (default: rectangular mesh + Steiner tree).
- Parameters:
groups (list[GroupModel]) – List of groups for building a openstreet network.
source_location (GeoLocation) – Power source location.
buffer (Distance, optional) – Buffer for road network search. Defaults to 20m.
routing_strategy (RoutingStrategy, optional) – Strategy for primary network routing. Defaults to SteinerTreeStrategy.
secondary_strategy (SecondaryNetworkStrategy, optional) – Strategy for secondary network construction. Defaults to MeshSteinerStrategy.
Constructor for the class.
- Parameters:
groups (list[GroupModel]) – List of groups for building a openstreet network.
source_location (GeoLocation) – Power source location.
buffer (Distance, optional) – Buffer to be applied in a bounding polygon formed by points for searching road network. Defaults to 20m.
routing_strategy (RoutingStrategy, optional) – Strategy for routing the primary network. Defaults to SteinerTreeStrategy (uniform weights, backward-compatible).
- build_secondary_network(group: GroupModel) Graph#
Build secondary network using the configured strategy.
- Parameters:
group (GroupModel) – Group for which the secondary network is to be built.
- Return type:
nx.Graph
- build_primary_network() Graph#
Internal method for building primary network.
- Return type:
nx.Graph