Skip to content

One discounted EAC of age replacement; value_plan takes a unit's plan - #502

Merged
derrynknife merged 2 commits into
devfrom
build/one-eac
Nov 21, 2026
Merged

derrynknife merged 2 commits into
devfrom
build/one-eac

Conversation

@derrynknife

Copy link
Copy Markdown
Owner

Summary

One EAC. The equivalent annual cost of age replacement at a discount rate (Fox, 1966) is now defined in one place: maintenance._options.cycle_eac. It covers every cost category that belongs to the unit itself: the failure price, the planned price, and the unit's downtime during repairs and during planned work that takes time.

Before this change, NonRepairable's discounted optimum and run to failure (_cycle_value and discounted_run_to_failure) and a diagram component's rbd._discounted_long_run.node_eac each had their own copy of this formula. All of them now call cycle_eac. The shared function keeps the old arithmetic operation for operation, so no value changes. The tests of every caller pass with their reference values unchanged.

value_plan takes plans. value_plan now accepts UnitPlan.to_dict() as its "diagram" and values it as the plan's one-node diagram. The npv-1.json schema description says so.

Type of change

  • Refactor / tooling
  • New feature (value_plan)

Checklist

  • Tests added. test_one_eac.py:

    • cycle_eac against Fox's closed form for an exponential life;
    • node_eac and the part's discounted optimum and run to failure against cycle_eac;
    • downtime and timed work against the hand formula.

    test_value_plan.py gains a test that a plan's document is valued as its diagram.

  • black, isort and flake8 on the changed files, and mypy on the changed modules. Tests run (one process): test_one_eac, test_value_plan, test_discounted_long_run, test_npv_intervals and test_exact_or_horizon (81 passed), plus the doctests of the three changed modules.

  • CHANGELOG.md updated

  • Monte-Carlo tests are seeded (none added)

Notes for reviewers

These are still separate: the diagram's shutdown dicts versus Opportunities, and bracketed discounting in the calendar's failures_by_period. Neither is part of this change.


Generated by Claude Code

maintenance._options.cycle_eac is the one equivalent annual cost of age
replacement at a discount rate (Fox, 1966), with every category of a
unit's own (failure and planned prices, its downtime over repairs and
planned work that take time). NonRepairable's discounted optimum and
run to failure and a diagram component's node_eac take it; the shared
arithmetic is the old two's, so no value changes.

value_plan takes UnitPlan.to_dict() as its diagram, valued as the plan's
one-node diagram; the npv-1 schema says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6RpnXB87vwhYETeh7ihtA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6RpnXB87vwhYETeh7ihtA

# Conflicts:
#	CHANGELOG.md
@derrynknife
derrynknife merged commit 380fd77 into dev Nov 21, 2026
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