Repository navigation
The least spend that keeps a bad run's downtime under a limit - #505
Merged
Merged
Conversation
RepairableRBD.least_spend_for_downtime (and UnitPlan's, through its one-node diagram) searches redundancy and interval levers on common random numbers for the cheapest design whose downtime quantile (or tail mean) has an upper bound under the limit, in hours or cost, all downtime or unplanned only. Each design reports planned and unplanned downtime, the frontier keeps the non-dominated designs, and a limit not met names the floor that stopped the levers. Risk measures go in repyability.value._risk; each run's unplanned downtime, which both engines already worked out, is kept per run. Use case UC-68. The bound's coverage study is committed unrun, for consolidation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6RpnXB87vwhYETeh7ihtA
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
Answers "I want to be 95% sure I don't lose more than x on downtime over the horizon: what is the least I need to pay?". Use case UC-68 was written in the maintenance README first.
The method.
RepairableRBD.least_spend_for_downtime(horizon, limit, ...), plusUnitPlan.least_spend_for_downtime, which goes through the plan's one-node diagram.The target is downtime only.
measure="cost"(thedowntime_cost_rate, plus anyvalue_ratelost).downtime="unplanned"counts failures only.budget=is given.When a design counts as safe. A design meets the limit only when an upper confidence bound on the downtime's risk measure is under it, so simulation noise cannot make a design look safe:
objective="var": the quantile atlevel, with an exact order-statistic bound (binomial method);objective="cvar": the tail mean, with a normal bound that is stated as approximate.The risk measures live in the money module,
repyability.value._risk.results._order_statisticnow calls itsquantile, so there is one definition.Levers, each at its own price:
redundancy={node: price}: copies in parallel, drawn asallocate_redundancydraws a train of one node;intervals={node: [...]}: a preventive interval's candidates, priced at the change in expected preventive cost.The search is the allocations' marginal analysis on common random numbers (one seed for every design). An interval move may jump to any later candidate, because a quantile can stay flat over a single step.
What the result reports:
frontier: the non-dominated designs, so more spend never raises the downtime along it;floorandstoppedname what stopped the levers: the budget, the levers' caps, or planned task downtime at or over the limit on its own.Per-run unplanned downtime.
AvailabilityResult.unplanned_downtimesgives each run's unplanned downtime. Both engines already computed it and only summed it, so the tally now keeps the per-run values too. The engines are untouched and no number changes.Registration. The new method has a route in
analysis_routes, a call inREPAIRABLE_CALLS, a row in the capability matrix (README regenerated), a guide section indocs/guide/costs.md, and API entries forDowntimeRiskResultandDowntimeDesign.Type of change
Checklist
test_downtime_risk.py(12 tests) covers:Other checks:
CHANGELOG.mdupdatedNotes for reviewers
Tests run (one process each):
test_downtime_risk+test_planned_split: 28 passed, 2 skipped (numba).test_analysis_routes -k "least_spend or covers_every or readme", which includes the new method on every catalogue diagram, plustest_readme_capabilities: 8 passed.test_help,test_result_objects,test_plan_alone,test_unit_plan, the costs guide's examples,test_every_analysis_is_called, the saving guide's table, and the doctests of_risk.py,_downtime_risk.pyand the new method: 255 passed, 1 skipped.The new tests passed on their first run, and none was changed after a failure.
Pre-existing failures. In
test_api_docstrings, theUnitPlantask classes (AgePolicy…Upgrade) are undocumented on the API pages and lack parameter docs. That already fails ondevand this PR doesn't change it.Study to run at consolidation.
scripts/downtime_bound_coverage.pychecks the bound's coverage at its stated rate: 1,000 seeded repeats of 500 runs, passing if the coverage's 99% binomial interval reaches 0.95. It is committed unrun, as the testing rule asks.Generated by Claude Code