Repository navigation
User guide for commodity graphs - #1575
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1575 +/- ##
=======================================
Coverage 90.90% 90.90%
=======================================
Files 61 61
Lines 9116 9116
Branches 9116 9116
=======================================
Hits 8287 8287
Misses 507 507
Partials 322 322 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexdewar
left a comment
There was a problem hiding this comment.
This looks great! Very comprehensive. I've suggested a few small things, but feel free to ignore.
And the graph the AI generated does look much prettier than ours... I like the key too. Shall we open an issue for this? I'm not sure how much flexibility we have with tweaking the output of petgraph, but it might be worth a go. (Could also -- optionally? -- include a key in this output for the often-opaque abbreviations used for commodities, processes, etc.)
|
|
||
| When reading these graphs, note that: | ||
|
|
||
| - nodes are labelled `COMMODITY | REGION` and edges are labelled `PROCESS | REGION`; |
There was a problem hiding this comment.
I wonder if, for single-region models, we should just hide the | REGION part? It just makes the output a bit more cluttered. (Not something for this PR anyway -- just a thought.)
There was a problem hiding this comment.
Agree. I was also thinking we could draw boxes around each region (i.e. each region is a subgraph), so we wouldn't need to label the region on nodes and edges. I had a go at this before in d8e85db (not on this branch, but could use as inspiration for a future PR)
|
There was a problem hiding this comment.
🟢 Approval recommended
The commodity-graph documentation update has no active review issues.
No open issues 🎉
What changed in this PR
Adds a user-facing guide to commodity graphs, building on the unified yearly graphs introduced in #1569. It explains how graphs support model validation, investment ordering and price calculation, with examples to help users diagnose problems.
Changes:
- Documents graph structure, validation rules, circularities and investment layers.
- Adds three illustrated examples with editable DOT sources and rendered SVGs.
- Links the guide from existing documentation and clarifies the SED producer requirement in the input schema documentation.
| File | Description |
|---|---|
schemas/input/commodities.yaml |
Clarifies when SED commodities require a producer. |
docs/user_guide.md |
Links graph visualisation guidance to the new chapter. |
docs/SUMMARY.md |
Adds the chapter to the documentation navigation. |
docs/model/README.md |
Links the investment-order overview to commodity graphs. |
docs/model/prices.md |
Links to the explanation of price calculation order. |
docs/model/investment.md |
Links to the investment-order explanation and example. |
docs/model/commodity_graphs.md |
Adds the guide, examples and troubleshooting advice. |
docs/images/save_graphs_simple.svg |
Illustrates graph output for the simple model. |
docs/images/save_graphs_simple.dot |
Provides the source for the simple-model illustration. |
docs/images/investment_order_example.svg |
Illustrates investment layers and a circularity. |
docs/images/investment_order_example.dot |
Provides the investment-order diagram source. |
docs/images/commodity_graph_example.svg |
Illustrates commodity types and process relationships. |
docs/images/commodity_graph_example.dot |
Provides the commodity-graph diagram source. |
docs/glossary.md |
Defines commodity graphs and their role in MUSE2. |
Review effort: Balanced
Sounds good. I found this crate for building dot files programmatically: https://docs.rs/dot/0.2.0/dot/index.html Might be worth a look. Or we can just generate the text ourselves, as you say. |
Description
I thought it would be useful to have a section in the documentation on commodity graphs, as this is an important part of how MUSE works, and a fundamental improvement over MUSE1 where users had to manually define hierarchies. Rather than writing this manually, I tried to get copilot to do it mostly for me. This is based off #1569, where region-level graphs have been combined.
My process was as follows:
I want a section in the user-facing docs describing commodity graphs in the context of the model. It should mention the fact that graphs are built and why:
The docs should focus on user facing implications, rather than algorithmic details. The goal is to help users to build models and diagnose problems
A few things to mention (allows users to understand visualised graphs and diagnose problems)
There should be at least one diagrammatic example, maybe more. E.g. we should give an example of a set of commodities and processes, and how the nodes in the graph represent commodities and the edges are processes. For simplicity, limit this to one region (don't include regions on the graph). Colour code by SVD/SED/OTH. Include a circularity. Then from the graph, write down/show what the investment order would be, walking it through. It might be easier to give dot code and I go away and create a png/svg - not sure. Use the example models for inspiration.
This documentation should be easy to read for a MUSE newcomer. The aim is to educate users to help them use MUSE effectively, not to confuse them. Aim for conciseness and do not include unnecessary details that aren't important for MUSE users to know.
Come up with a detailed plan
Notes:
circularityexample is a bit too complex for this.save-graphscommand more visually appealing. The first graph in the doc is good inspiration. If we did this then maybe we could combine these sections. Beyond the scope of this PR though.Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks