Skip to content

Test/road poles#25

Draft
paulapreuss wants to merge 26 commits into
production/workersfrom
test/road-poles
Draft

Test/road poles#25
paulapreuss wants to merge 26 commits into
production/workersfrom
test/road-poles

Conversation

@paulapreuss

Copy link
Copy Markdown
Collaborator

No description provided.

Bachibouzouk and others added 26 commits May 26, 2026 10:40
  When grid_opt_json["roads"] is present, poles are sampled along road
  polylines at distribution_cable_max_length/2 intervals and consumers
  within connection_cable_max_length are assigned to them directly.
  K-means runs only on consumers road poles cannot reach.

  - _sample_road_poles: UTM-projected road sampling, cluster labels
    offset at 100000 to avoid collision with k-means labels (0..n)
  - _associate_consumers_to_road_poles: greedy nearest-pole assignment
  - _associate_consumers_to_road_poles: greedy nearest-pole assignment
    with pole_max_connection cap; empty road poles discarded
  - _kmeans_for_unassigned: k-means on unassigned subset only, preserves
    road poles already in self.nodes
  - _place_poles_with_roads: orchestrator; replicates power-house
    handling from determine_poles
  - _clear_poles: skip road-sampled poles so they survive internal
    kmeans_clustering calls during is_enough_poles binary search

Co-authored-by: Claude Sonnet 4.6 <claude@anthropic.com>
Both determine_poles and _place_poles_with_roads duplicated the same
post-placement steps. Extract them into optimize() so each placement
method is responsible for poles only.

- determine_poles: reduced to kmeans_clustering call
- _place_poles_with_roads: reduced to road sampling + association
- optimize: owns powerhouse inject, MST, connect, long-link fix
- _sample_road_poles: use _add_node instead of DataFrame concat;
  road coords pre-projected in convert_lonlat_xy as road_geometries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ustering

Both functions ran identical k-means logic. Unified by adding optional
consumer_indices param — None means all connected consumers (non-road
path), a subset means road-unassigned consumers only.

- kmeans_clustering: drop internal _clear_poles, use append-style
  concat, add consumer_indices param, fix size_max=0 guard
- is_enough_poles: owns _clear_poles before each trial so pole
  accumulation across binary search iterations is prevented
- _place_poles_with_roads: call kmeans_clustering directly
- _kmeans_for_unassigned: deleted

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cluster_labels sometimes was including NaN label from power-house
Used to happen automatically when rebuilding nodes, but not anymore because of concat due to road poles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants