Skip to content

A listed landfill's share a rounding error below zero sends no negative waste - #96

Merged
HughRunyan merged 1 commit into
am-waste-flowfrom
other-landfills-clamps-tolerated-shares
Oct 20, 2026
Merged

HughRunyan merged 1 commit into
am-waste-flowfrom
other-landfills-clamps-tolerated-shares

Conversation

@HughRunyan

Copy link
Copy Markdown
Collaborator

Environment

SWEET_python am-waste-flow, advanced_dst_city._with_other_landfills (added by #90).

Reproduction

A city-level ADST request with one listed landfill at share -0.01, plus other_landfills.

Expected vs actual

  • Expected: the listed site takes nothing, and other landfills take 100% of what the city landfills.
  • Actual: _validate_share_range tolerates shares down to −0.02, and the routing used them as given. The split became [-0.01, 1.01]. For 10,000 t of residual waste, that buried −100 t at the listed site and 10,100 t at other landfills.

Copilot flagged it on #95 (whose diff showed #90's code at the time). It was never fixed in #90.

Fix

Clip tolerated shares to [0, 1] before working out what other landfills take. A regression test fails on am-waste-flow and passes here.

Acceptance criteria

  • A tolerated negative share sends no negative waste anywhere.
  • pytest -m "not integration": 610 passed.

Definition of Done

Acceptance criteria met · tests pass · changelog updated · reviewed & merged.

🤖 Generated with Claude Code

…ve waste

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan HughRunyan added bug Something isn't working model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs labels Oct 20, 2026
@HughRunyan
HughRunyan requested a balanced review from Copilot October 20, 2026 18:31
@HughRunyan
HughRunyan merged commit e6be4d0 into am-waste-flow Oct 20, 2026
3 checks passed
@HughRunyan
HughRunyan deleted the other-landfills-clamps-tolerated-shares branch October 20, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized fix addresses the reported failure and includes regression coverage for both variants, with no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes negative waste routing in advanced DST city requests with other_landfills.

Changes:

  • Clips tolerated listed shares to [0, 1] before calculating remaining waste.
  • Adds regression coverage for baseline and scenario routing.
  • Documents the correction in the changelog.
File Description
tests/​test_adst_city_other_landfills.py Checks that tolerated negative shares produce no negative waste.
SWEET_python/​advanced_dst_city.py Clips shares while preserving validation and normalization.
changelog/​2026-10.md Documents the routing fix.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants