Skip to content

Add documentation for commodity price calculations#1362

Open
tsmbland wants to merge 15 commits into
mainfrom
price_documentation
Open

Add documentation for commodity price calculations#1362
tsmbland wants to merge 15 commits into
mainfrom
price_documentation

Conversation

@tsmbland

@tsmbland tsmbland commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds documentation describing the approach for calculating commodity prices. Includes the example laid out in #1128 (comment)

Fixes #1034

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

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.80%. Comparing base (651b4e2) to head (f4c9118).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1362      +/-   ##
==========================================
+ Coverage   89.75%   89.80%   +0.05%     
==========================================
  Files          58       58              
  Lines        8529     8524       -5     
  Branches     8529     8524       -5     
==========================================
  Hits         7655     7655              
+ Misses        561      556       -5     
  Partials      313      313              

☔ 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.

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

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

Adds a new user-facing documentation page describing how MUSE2 calculates commodity prices after dispatch, including an end-to-end worked example for full-cost pricing (per the referenced issues).

Changes:

  • Add a new “Commodity Prices” page under the Model Description section.
  • Document pricing strategies, cost component breakdowns, ordering logic (including cycles), and a worked example.

Reviewed changes

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

File Description
docs/SUMMARY.md Adds the new “Commodity Prices” page to the mdBook table of contents.
docs/model/prices.md New documentation page describing pricing strategies and worked examples for commodity price calculation.

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

Comment thread docs/model/prices.md Outdated
Comment thread docs/model/prices.md Outdated
Comment thread docs/model/prices.md Outdated
Comment thread docs/model/prices.md Outdated
tsmbland and others added 5 commits June 23, 2026 15:30
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@dc2917 dc2917 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A couple of minor suggestions but otherwise looks good to me

Comment thread docs/model/prices.md
Comment thread docs/model/prices.md Outdated
Comment thread docs/model/prices.md Outdated
Comment thread docs/model/prices.md Outdated

@alexdewar alexdewar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! A useful resource. I've put some comments.

Maybe you could link to this page from the docs for src/simulation/prices.rs? (Though bear in mind the URL may change soon, see: #1366 (comment)).

I spotted one place where we are using a different name for the variable elsewhere in the docs from what's here (there may be more), but your naming scheme is at least internally consistent, so I think that's better. We have a bit of a mix of single letters, snake case and Pascal case in equations. Not sure if we should do something about that.

Comment thread docs/model/prices.md
highest-cost active asset producing the commodity.
- **`shadow`**: Prices are taken directly from the shadow prices (dual values) of the commodity
balance constraints in the dispatch optimisation.
- **`scarcity`**: Prices are set to the shadow price plus the highest activity dual of the assets

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Side note: I think this option might be misnamed. I had it in mind it removes the effect of scarcity from prices. scarcity_adjusted or something might be clearer.

Comment thread docs/model/prices.md
balance constraints in the dispatch optimisation.
- **`scarcity`**: Prices are set to the shadow price plus the highest activity dual of the assets
producing the commodity in that region and time slice.
- **`unpriced`**: No prices are calculated for the commodity.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Worth mentioning that for OTH-type prices, you have to use this option?

Comment thread docs/glossary.md

**Supply Equals Demand (SED):**: An SED commodity is a type of commodity that is both consumed and
produced by processes in the system. In fully resolved systems, supply of these commodities is
constrained to be equal to or greater than demand.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it also be worth mentioning OTH commodities here? The abbreviation isn't very self-explanatory

Comment thread docs/model/prices.md
The generic activity cost comprises all operating expenditures, input purchases, and flow costs/levies
not associated with specific SED/SVD outputs:
\\[
\text{GenericActivityCost} = \text{VariableOperatingCost} + \text{InputPurchases} + \sum \text{GenericFlowCosts}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just noting that we use $cost_{var}$ to mean variable operating cost in the dispatch docs. I think it would probably be confusing to use that here though.

You could abbreviate "operating cost" to "opex" though, as you use that below anyway:

Suggested change
\text{GenericActivityCost} = \text{VariableOperatingCost} + \text{InputPurchases} + \sum \text{GenericFlowCosts}
\text{GenericActivityCost} = \text{VariableOpex} + \text{InputPurchases} + \sum \text{GenericFlowCosts}

Comment thread docs/model/prices.md
Comment on lines +79 to +80
*Note: this only works if all output commodities are measured in the same energy units (e.g. PJ).
For this reason, MUSE2 disallows processes that have output commodities with differing units.*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd put this in a box:

Suggested change
*Note: this only works if all output commodities are measured in the same energy units (e.g. PJ).
For this reason, MUSE2 disallows processes that have output commodities with differing units.*
> Note: this only works if all output commodities are measured in the same energy units (e.g. PJ).
> For this reason, MUSE2 disallows processes that have output commodities with differing units.

Comment thread docs/model/prices.md

### GASPRD

In this scenario, GASPRD is produced by a single GASDRV asset. This asset produces 1 unit of GASPRD

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the reader likely to know what GASPRD refers to, i.e. is it a common abbreviation? I always assumed these names were MUSE-isms.

If so, should we maybe have a list spelling out what they mean? Alternatively we could just use longer names.

Comment thread docs/model/prices.md
Comment on lines +155 to +161
\\[
\text{CRF} = 0.11016807219
\\]

\\[
\text{AnnualFixedCostPerCapacity} = (10 \times 0.11016807219 + 0.3) = 1.4016807219
\\]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about aligning these on the = signs?

Suggested change
\\[
\text{CRF} = 0.11016807219
\\]
\\[
\text{AnnualFixedCostPerCapacity} = (10 \times 0.11016807219 + 0.3) = 1.4016807219
\\]
\\[
\begin{aligned}
\text{CRF} &= 0.11016807219
\text{AnnualFixedCostPerCapacity} &= (10 \times 0.11016807219 + 0.3) = 1.4016807219
\end{aligned}
\\]

You might even be able to get the equations below to line up by keeping the whole lot in a math block or something, but, even if not, I think it's nicer to have these aligned.

Comment thread docs/model/prices.md
Comment on lines +189 to +199
\\[
\text{CO2Levy} = 2.5565 \times 0.04 = 0.10226
\\]

\\[
\text{InputPurchases} = 8.9477554044 \times 1.05 = 9.39514317462
\\]

\\[
\text{MarginalCost}_{\text{GASNAT}} = 0.10226 + 0.5 + 9.39514317462 = 9.99740317462
\\]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As above:

Suggested change
\\[
\text{CO2Levy} = 2.5565 \times 0.04 = 0.10226
\\]
\\[
\text{InputPurchases} = 8.9477554044 \times 1.05 = 9.39514317462
\\]
\\[
\text{MarginalCost}_{\text{GASNAT}} = 0.10226 + 0.5 + 9.39514317462 = 9.99740317462
\\]
\\[
\begin{aligned}
\text{CO2Levy} &= 2.5565 \times 0.04 = 0.10226
\text{InputPurchases} &= 8.9477554044 \times 1.05 = 9.39514317462
\text{MarginalCost}_{\text{GASNAT}} &= 0.10226 + 0.5 + 9.39514317462 = 9.99740317462
\end{aligned}
\\]

Comment thread docs/model/prices.md
Comment on lines +206 to +212
\\[
\text{CRF} = 0.11016807219
\\]

\\[
\text{AnnualFixedCostPerCapacity} = (7 \times 0.11016807219 + 0.21) = 0.98117650533
\\]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
\\[
\text{CRF} = 0.11016807219
\\]
\\[
\text{AnnualFixedCostPerCapacity} = (7 \times 0.11016807219 + 0.21) = 0.98117650533
\\]
\\[
\begin{aligned}
\text{CRF} &= 0.11016807219
\text{AnnualFixedCostPerCapacity} &= (7 \times 0.11016807219 + 0.21) = 0.98117650533
\end{aligned}
\\]

Comment thread docs/model/prices.md
Comment on lines +220 to +222
\[
\text{AnnualFixedCostPerOutput} = \frac{4.6836756722}{1} = 4.6836756722
\]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This didn't render for me:

Suggested change
\[
\text{AnnualFixedCostPerOutput} = \frac{4.6836756722}{1} = 4.6836756722
\]
\\[
\text{AnnualFixedCostPerOutput} = \frac{4.6836756722}{1} = 4.6836756722
\\]

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.

Better documentation for pricing strategies

4 participants