Skip to content

Accumulate lifecycle total loss across events - #145

Merged
HenryGeorgist merged 3 commits into
mainfrom
fix/lifecycle-total-loss
Sep 23, 2026
Merged

HenryGeorgist merged 3 commits into
mainfrom
fix/lifecycle-total-loss

Conversation

@trietmnj

@trietmnj trietmnj commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
  • Problem: computeConsequencesMultiHazard assigns StructureTotalLoss and ContentsTotalLoss on every event instead of adding to them, so the lifecycle summary reports only the last event's damage (a DE001 run showed $16.9M against $944.4M summed over its event rows).
  • Fix: accumulate with +=. TestComputeConsequencesMultiHazard now asserts both totals equal the sum of its five events' damage (67.5; it was 18.0).
structure 365314, DE001 lifecycle 1 (19 events)

event    damage      before: total = damage    after: total += damage
───────  ──────────  ────────────────────────  ──────────────────────
22       $54,235     $54,235                   $54,235
23–31    $0          $0   ◄ reset each event   $54,235
32       $121,427    $121,427                  $175,662
33–36    $0          $0                        $175,662
37       $1,685      $1,685                    $177,348
                     ────────────────────────  ──────────────────────
summary              $1,685   ✗                $177,348   ✓

StructureTotalLoss and ContentsTotalLoss were assigned each event, so the summary held only the last event's damage. Sum them instead, and assert the totals in TestComputeConsequencesMultiHazard.
The fixture's damages are multiples of 0.5, so the totals are exact in float64 and a tolerance only obscured the check.
@trietmnj
trietmnj marked this pull request as ready for review September 23, 2026 19:33
@HenryGeorgist
HenryGeorgist self-requested a review September 23, 2026 19:47

@HenryGeorgist HenryGeorgist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good catch

@HenryGeorgist
HenryGeorgist merged commit 41456e1 into main Sep 23, 2026
1 check passed
@HenryGeorgist
HenryGeorgist deleted the fix/lifecycle-total-loss branch September 23, 2026 19:48
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