Add commodity constraints input and validation - #1487
Conversation
|
@tsmbland I've taken a stab at this but some feedback would be helpful before I add tests |
tsmbland
left a comment
There was a problem hiding this comment.
Good start, but a few comments
| /// | ||
| /// A `HashMap<CommodityID, CommodityConstraintsMap>` mapping commodity IDs to their | ||
| /// commodity-constraints maps, or an error. | ||
| pub fn read_commodity_constraints( |
There was a problem hiding this comment.
We also want to disallow SVD commodities from having commodity constraints, so you'll need to pass in the map of the commodities rather than just the IDs (i.e. &IndexMap<CommodityID, Commodity>)
Another slightly tricky thing is that, since OTH commodities can either be consumed or produced (but not both), we don't want users to supply production constraints for OTH commodities that are consumed, and vice-versa. Probably worth opening an issue about this rather than attempting this here, as we may have to do this in the graph validation stage
- Cleaner parsing of region_id - Change units of limits from money to flow - Store time slice selection and balance type in `CommodityConstraint` struct - Store vectors of `CommodityConstraint`s in `CommodityConstraintMap`
c872f0a to
273b323
Compare
273b323 to
328243d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1487 +/- ##
==========================================
+ Coverage 90.31% 90.38% +0.07%
==========================================
Files 60 61 +1
Lines 8663 8833 +170
Branches 8663 8833 +170
==========================================
+ Hits 7824 7984 +160
- Misses 525 526 +1
- Partials 314 323 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
This PR adds a new module for reading and validating an input csv file for commodity constraints.
Commodity constraints are stored in a new
CommodityConstraintstruct, and the set of constraints provided are read and stored in aCommodityConstraintsMaptype, which mapsCommodityConstraints by region ID and year.CommodityConstraints have a single field,limits, which stores the range of values to which the commodity is constrained.An example commodity_constraints.csv file has been added to the "simple" setup for demonstration, and a corresponding schema has been added.
Fixes #1448
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks