Repository navigation
Credit a unit's own salvage and retirement in simulated runs - #509
Merged
Merged
Conversation
npv_distribution and compare_npv refused a unit's own retire_at and salvage. The runs now end at the retirement, and every run is credited the salvage (a number) at the end, discounted as expected_npv discounts it; the result says so (salvage, undiscounted_salvage, retire_at). A salvage by age and one of several units retiring are still refused, as are a unit's own salvage and retirement in best_switch_time, plan_vs_actual and task_value. Results without them are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6RpnXB87vwhYETeh7ihtA
# Conflicts: # CHANGELOG.md
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.
Summary
A
UnitPlan, or a component spec, can carry its ownsalvageandretire_at.expected_npvcredited both, butnpv_distributionandcompare_npvrefused them. Now they take them:min(horizon, retire_at)). The contract periods are cut there too.expected_npvdiscounts it, growing only by the"salvage"stream. This applies to a salvage given as a number, which is the same whatever happened in the run.NPVDistributiongainssalvage,undiscounted_salvageandretire_at. Incompare_npv, each plan ends at its own retirement and gets its own credit._npv.own_end, does this for both.Still refused, with messages that name what to give:
expected_npv's refusal);best_switch_time,plan_vs_actualandtask_value.best_switch_time's route now refuses this itself, since it no longer inherits the refusal fromnpv_distribution's route.Results without these terms are unchanged.
Type of change
Checklist
test_npv_runs_own_end.py: each run with a salvage equals the run without it plus the salvage, to 1e-9; a retirement equals the run to that time; the credit equalsexpected_npv's salvage to 1e-12;compare_npv's matched differences equal the salvage; the refusals and their routes.test_plan_alone.py: its test that the runs refuse a salvage now checks thatplan_vs_actualstill refuses and thatnpv_distributionis simulated.test_npv_runs_own_endandtest_plan_alone: 216 passed, re-run after mergingdev.test_npv_distribution,test_upgrade_retire_salvage,test_npv_escalationand thenpv_distribution,compare_npvandbest_switch_timecases oftest_analysis_routes: 282 passed, 1 skipped.analysis_routes(thenpv_distributionandbest_switch_timeroutes) and UC-65 in the maintenance README.CHANGELOG.mdupdated under[Unreleased]Notes for reviewers
A first draft of the new retirement test expected a unit's own escalation to grow its salvage.
expected_npvgrows a salvage only by the"salvage"stream (23.5988 against the 24.7592 the draft expected, for 30 at 240 h with 2e-4 of growth). The test now checks againstexpected_npv. No tolerance was changed.Generated by Claude Code