Sub-Ladder rungs fill from the highest-yield segment first 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-07 22:06:30 +00:00
parent 0b33f7dc65
commit c1a8c27bc1

View file

@ -195,13 +195,19 @@ _MIN_SUB_LADDER_PANELS = 2
def _resized_to(
config: SolarPanelConfiguration, panels: int
) -> SolarPanelConfiguration:
"""A copy of ``config`` filled to ``panels`` panels, each kept segment's
yearly energy scaled pro-rata (conservative: Google places panels
best-first within a segment, so the kept panels' true yield is at least
the pro-rata figure)."""
"""A copy of ``config`` filled to ``panels`` panels — taken from the
highest per-panel-yield segments first (the ADR-0038 fill-by-generation
precedent) each kept segment's yearly energy scaled pro-rata
(conservative: Google places panels best-first within a segment, so the
kept panels' true yield is at least the pro-rata figure)."""
by_yield: list[SolarRoofSegment] = sorted(
config.segments,
key=lambda s: s.yearly_energy_dc_kwh / s.panels_count,
reverse=True,
)
kept: list[SolarRoofSegment] = []
remaining: int = panels
for segment in config.segments:
for segment in by_yield:
if remaining <= 0:
break
take: int = min(segment.panels_count, remaining)