Skip to content

New NPV metric using SNAS#1379

Merged
tsmbland merged 10 commits into
mainfrom
new_npv_method
Jul 1, 2026
Merged

New NPV metric using SNAS#1379
tsmbland merged 10 commits into
mainfrom
new_npv_method

Conversation

@tsmbland

@tsmbland tsmbland commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Simplifies the NPV metric to use the SNAS calculation described in #1201. Previously, there was a much more complicated ranking method based on two numbers (total_annualised_surplus and annualised_fixed_cost), now it's a much simpler method involving one number (the SNAS), where higher is better.

In practice, this ends up being extremely similar to LCOX, the only real difference being that SNAS includes the commodity of interest whereas LCOX doesn't. Apart from that, SNAS is just the negative of LCOX, and maximised instead of minimised.

There are almost certainly ways we could tidy up the code, but I figured that's a separate job and @alexdewar may already have ideas about that. We also need to retain some flexibility as future objective metrics may be more fundamentally different.

The docs are also of date. I've deleted the entire NPV section and replaced it with a short section below LCOX that just highlights the differences. The LCOX documentation is outdated, but that was already the case, and I figured that's a separate job.

Fixes the circularity_npv model, so I've re-enabled that.

Fixes #1201

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@tsmbland tsmbland marked this pull request as ready for review June 26, 2026 14:49
Copilot AI review requested due to automatic review settings June 26, 2026 14:49
@tsmbland

tsmbland commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Oh great, we have a model differing between OS's again. Fantastic 😐 False alarm!

Copilot AI 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.

Pull request overview

This PR updates the “NPV” investment appraisal tool to use the SNAS-style metric described in #1201, and refreshes regression fixtures/docs accordingly.

Changes:

  • Switch NPV appraisal from the previous profitability-index/TAS hybrid comparison to a single per-activity metric (via snas).
  • Re-enable and update regression coverage/fixtures for circularity_npv and update simple_npv expected outputs.
  • Simplify the investment-tool documentation by removing the old NPV section and noting the intended relationship to LCOX.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/finance.rs Introduces snas() helper and removes the old profitability index implementation.
src/simulation/investment/appraisal.rs Updates NPV appraisal to use snas and adjusts metric structs/tests accordingly.
docs/model/investment.md Rewrites the NPV tool documentation section.
tests/regression.rs Re-enables the circularity_npv regression test.
tests/data/simple_npv/commodity_prices.csv Updates expected outputs for simple_npv regression.
tests/data/simple_npv/commodity_flows.csv Updates expected outputs for simple_npv regression.
tests/data/simple_npv/assets.csv Updates expected outputs for simple_npv regression.
tests/data/simple_npv/asset_capacities.csv Updates expected outputs for simple_npv regression.
tests/data/circularity_npv/commodity_prices.csv Updates expected outputs for circularity_npv regression.
tests/data/circularity_npv/commodity_flows.csv Updates expected outputs for circularity_npv regression.
tests/data/circularity_npv/assets.csv Updates expected outputs for circularity_npv regression.
tests/data/circularity_npv/asset_capacities.csv Updates expected outputs for circularity_npv regression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/finance.rs
Comment thread src/simulation/investment/appraisal.rs Outdated
Comment thread docs/model/investment.md Outdated
Comment thread src/simulation/investment/appraisal.rs
@tsmbland tsmbland requested a review from alexdewar June 26, 2026 15:17
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.60%. Comparing base (cb8a34d) to head (05b8d8e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1379      +/-   ##
==========================================
- Coverage   89.68%   89.60%   -0.09%     
==========================================
  Files          58       58              
  Lines        8406     8338      -68     
  Branches     8406     8338      -68     
==========================================
- Hits         7539     7471      -68     
  Misses        550      550              
  Partials      317      317              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dc2917 dc2917 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.

Just made a comment on the docs, but the code itself looks good - implementation in src/finance.rs looks fine, and it seems reasonable to have snas defined as a function in a separate module, that happens to be the metric used for NPV.

Comment thread docs/model/investment.md
@tsmbland

tsmbland commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@alexdewar Merging now, but you may want to look at when you're back

@tsmbland tsmbland merged commit 3e9d3b5 into main Jul 1, 2026
8 checks passed
@tsmbland tsmbland deleted the new_npv_method branch July 1, 2026 09:53
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.

Change the way the NPV appraisal tool works

3 participants