-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add data structure for asset pool #388
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aa7fa2d
Make `AssetPool` into struct
alexdewar bbc81f8
Commission assets as separate step rather than filtering
alexdewar 1b9df3f
Asset: Add decommission_year() method
alexdewar f28c970
Decommission assets that have reached EOL
alexdewar b1af5cf
Use newtype for `Asset` IDs
alexdewar b3bca17
Add `AssetPool::get` method
alexdewar ee25515
Fix examples/simple: Make last milestone year 2040
alexdewar 1aa9234
Fix examples/simple: Make last milestone year 2030
alexdewar 90f2048
Merge branch 'main' into asset-pool
alexdewar 0895010
Tweak doc comment `Asset::INVALID`
alexdewar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
commodity_id,region_id,balance_type,year,time_slice,value | ||
CO2EMT,GBR,net,2020,annual,0.04 | ||
CO2EMT,GBR,net,2100,annual,0.04 | ||
CO2EMT,GBR,net,2030,annual,0.04 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
commodity_id,region_id,year,demand | ||
RSHEAT,GBR,2020,927.38 | ||
RSHEAT,GBR,2100,927.38 | ||
RSHEAT,GBR,2030,927.38 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[milestone_years] | ||
years = [2020, 2100] | ||
years = [2020, 2030] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
process_id,start_year,end_year,capital_cost,fixed_operating_cost,variable_operating_cost,lifetime,discount_rate,cap2act | ||
GASDRV,2020,2100,10.0,0.3,2.0,25,0.1,1.0 | ||
GASPRC,2020,2100,7.0,0.21,0.5,25,0.1,1.0 | ||
WNDFRM,2020,2100,1000.0,30.0,0.4,25,0.1,31.54 | ||
GASCGT,2020,2100,700.0,21.0,0.55,30,0.1,31.54 | ||
RGASBR,2020,2100,55.56,1.6668,0.16,15,0.1,1.0 | ||
RELCHP,2020,2100,138.9,4.167,0.17,15,0.1,1.0 | ||
GASDRV,2020,2030,10.0,0.3,2.0,25,0.1,1.0 | ||
GASPRC,2020,2030,7.0,0.21,0.5,25,0.1,1.0 | ||
WNDFRM,2020,2030,1000.0,30.0,0.4,25,0.1,31.54 | ||
GASCGT,2020,2030,700.0,21.0,0.55,30,0.1,31.54 | ||
RGASBR,2020,2030,55.56,1.6668,0.16,15,0.1,1.0 | ||
RELCHP,2020,2030,138.9,4.167,0.17,15,0.1,1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so I understand; So all
commission_new()
is doing is updating thecurrent_year
for theAssetPool
.decommission_old
is doing the important bit by making sure that only assets whose decommission year is in the future is kept inAssetPool
.Do we not want to set the
id
field of theAsset
toAssetID::INVALID
here also? Or is that not the intended use of that value? Does "decommissioned" have a different meaning to "inactive"?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, exactly. Because the assets are sorted by commission year, to get the active assets we can then just iterate over the
Vec
until we find a commission year >current_year
.Decommissioned assets are just deleted from the
Vec
for now, though we could potentially just mark them as inactive in some way instead (maybe replace them withNone
?), which would have the advantage that we wouldn't have to move memory around every time we decommission things. But I just went for deleting them for now because that seemed easier.I've noticed that the doc comments are a bit confusing here.
AssetID::INVALID
is just the ID that everyAsset
is given when it's created. When we move the assets into theAssetPool
, then at that point they're all given a unique ID. The reason for doing it at this point is so that we can sort the assets by commission year and then give them IDs in that same order, which will make it faster to look up assets by ID. We could also just sort the assets when we load them in, but it seemed a bit fragile forAssetPool
to rely on this (we might refactor the input code and subtly break it).