Test/road poles#25
Draft
paulapreuss wants to merge 26 commits into
Draft
Conversation
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
3a3c160 to
a69a528
Compare
ac7d46a to
98853bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.