powergrid_synth.distribution.distribution_validation

Validation and statistical comparison for synthetic distribution feeders.

Provides KL-divergence computation and emergent property validation against reference feeders, as described in Section IV of Schweitzer et al. (2017).

Module Contents

powergrid_synth.distribution.distribution_validation.compare_feeders(synthetic, reference)[source]

Compare synthetic and reference feeders via KL-divergence.

Returns a dict mapping distribution name → KL divergence value.

Parameters:
  • synthetic (networkx.Graph)

  • reference (networkx.Graph)

Return type:

Dict[str, float]

powergrid_synth.distribution.distribution_validation.compute_emergent_properties(G)[source]

Compute emergent (aggregate) properties of a feeder.

Returns a dict with:

  • n_nodes : total number of nodes

  • n_edges : total number of edges

  • max_hop : maximum hop distance

  • mean_degree : mean node degree

  • total_load_mw : sum of positive P

  • total_gen_mw : sum of negative P (absolute)

  • frac_intermediate : fraction of intermediate nodes

  • frac_injection : fraction of injection nodes

  • mean_length_km : mean cable length

  • max_length_km : maximum cable length

  • total_length_km : total cable length

Parameters:

G (networkx.Graph)

Return type:

Dict[str, float]

powergrid_synth.distribution.distribution_validation.extract_cable_length_distribution(G, n_bins=50)[source]

Return cable-length histogram (counts, bin_edges).

Parameters:
  • G (networkx.Graph)

  • n_bins (int)

Return type:

Tuple[numpy.ndarray, numpy.ndarray]

powergrid_synth.distribution.distribution_validation.extract_degree_distribution(G)[source]

Return degree histogram from a feeder graph.

Parameters:

G (networkx.Graph)

Return type:

numpy.ndarray

powergrid_synth.distribution.distribution_validation.extract_hop_distribution(G)[source]

Return hop-distance histogram from a feeder graph.

Parameters:

G (networkx.Graph)

Return type:

numpy.ndarray

powergrid_synth.distribution.distribution_validation.extract_load_per_node(G)[source]

Return array of non-zero load values (MW).

Parameters:

G (networkx.Graph)

Return type:

numpy.ndarray

powergrid_synth.distribution.distribution_validation.kl_divergence_discrete(p_counts, q_counts, n_bins=None)[source]

Compute KL divergence D_KL(P || Q) for two discrete histograms.

Parameters:
  • p_counts (array-like) – Raw counts or probability arrays. They are normalized internally.

  • q_counts (array-like) – Raw counts or probability arrays. They are normalized internally.

  • n_bins (int, optional) – Re-bin both arrays into n_bins equally spaced bins.

Returns:

KL divergence in nats. Returns inf if Q has zero probability where P is nonzero.

Return type:

float

powergrid_synth.distribution.distribution_validation.validate_tree(G)[source]

Check structural validity of a feeder and return list of issues.

Parameters:

G (networkx.Graph)

Return type:

List[str]