Skip to content

Conversation

@alexdewar
Copy link
Collaborator

@alexdewar alexdewar commented Jan 23, 2026

Description

My previous attempt at adding a test for NPV didn't work (#1093). @tsmbland pointed out that we could probably get away with just changing the objective type for one agent to NPV, which I've done here and seems to fix things.

This PR just includes the stuff related to NPV (except for a couple of minor tweaks) and I've left the code related to #1090 on a different branch (replace-value-option-for-patch-examples). I figure we can open a PR for that later if/when we find a use for it.

Closes #1062.

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

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.27%. Comparing base (195c94c) to head (097a942).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1094      +/-   ##
==========================================
+ Coverage   85.14%   86.27%   +1.13%     
==========================================
  Files          55       55              
  Lines        7559     7555       -4     
  Branches     7559     7555       -4     
==========================================
+ Hits         6436     6518      +82     
+ Misses        816      730      -86     
  Partials      307      307              

☔ View full report in Codecov by Sentry.
📢 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.

@alexdewar alexdewar marked this pull request as ready for review January 23, 2026 13:22
Copy link
Contributor

Copilot AI left a comment

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 re-enables the Net Present Value (NPV) objective for agents and adds an integration-style regression test to lock in the expected behaviour via a patched example model.

Changes:

  • Remove the guard that previously blocked ObjectiveType::NetPresentValue from being used in agent objectives.
  • Define a new patched example "simple_npv" and hook it into the muse2 example CLI patch mechanism and regression test suite.
  • Add regression output data (assets, commodity flows, and prices) for the "simple_npv" example and introduce a small internal refactor in the patching code (CSVTable alias).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/input/agent/objective.rs Removes the special-case error and warning that treated the NPV objective as broken, allowing objective_type = "npv" to be used like other objectives.
src/example/patches.rs Extends the patch map with a "simple_npv" entry that patches the simple example’s agent_objectives.csv to set A0_RES’s objective to NPV.
src/patch.rs Introduces a CSVTable type alias for IndexSet<Vec<String>> and updates FilePatch and modify_base_with_patch to use it, without changing behaviour.
tests/regression.rs Adds a patched regression test define_regression_test_with_patches!(simple_npv); so muse2 example run simple_npv --patch is checked against golden CSV outputs.
tests/data/simple_npv/assets.csv Provides expected asset state outputs for the patched "simple_npv" example across milestone years.
tests/data/simple_npv/commodity_flows.csv Provides expected per-asset commodity flow outputs for the "simple_npv" example to validate NPV path behaviour.
tests/data/simple_npv/commodity_prices.csv Provides expected commodity prices for all time slices and milestone years for the "simple_npv" example.

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

@alexdewar
Copy link
Collaborator Author

Sorry, forgot to add PR description before requesting review. I've edited it now.

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.

Unhide NPV option and add regression test

2 participants