Iterable
E4ST.Iterable
— Typeabstract type Iterable
Sometimes, it may be desirable to run E4ST back-to-back with very similar sets of inputs, changing small things in the inputs between runs. In order to do that, we have this custom interface!
The Iterable
represents how run_e4st
should iterate through multiple optimizations. This structure could be used for any number of things, such as:
- Running a sequence of years
- Iterating to find the optimal price for natural gas to meet some load criterion.
- Running the first simulation for capacity/retirement, then run the next sim to find generation with a higher temporal resolution.
Adding an Iterable to config
- Add the
Iterable
to the config, in the same way as you would add aModification
to the config file. I.e.:
# Inside config.yml
iter:
type: MyIterType
myfield: myval
Interfaces
init!(iter::Iterable, config)
- (optional) Initializeiter
withconfig
, making any changes.issequential(iter)
- (optional) returns whether or not the iterator will move forward in time sequentially. Defaults to true so that the config can be reused for another simulation.should_iterate(iter, config, data)
- return whether or not the simulation should continue for another iteration.iterate!(iter, config, data)
- Makes any changes to any of the structures between iterations.should_reread_data(iter)
- Returns whether or not to reread the data when iterating.fieldnames_for_yaml(::Type{<:Iterable})
- (optional) return the fieldnames to print to yaml file insave_config
E4ST.init!
— Functioninit!(iter, config) -> nothing
Initialize iter
with config
, making any changes to config
as needed.
init!(ret::Retrofit, config, data)
initialize data with the Retrofit
by adding any necessary columns to the gen table, etc. Defaults to do nothing.
init!(iter::RunSequential, config)
Sets up a new config[:out_path]
by appending iter1
to config[:out_path]
E4ST.issequential
— Functionissequential(iter) -> ::Bool
Return whether or not the iterator advances in years. This may be necessary for some Modifications, whether they prepare the config to move forward or not. Default is true
.
E4ST.should_iterate
— Functionshould_iterate(iter, config, data) -> Bool
Returns whether or not E4ST should iterate.
E4ST.iterate!
— Functioniterate!(iter::Iterable, config, data)
Make any necessary modifications to the config
or data
based on iter
.
E4ST.should_reread_data
— Functionshould_reread_data(iter::Iterable) -> ::Bool
Return whether or not the data should be re-read when iterating.
E4ST.fieldnames_for_yaml
— Methodfieldnames_for_yaml(::Type{I}) where {I<:Iterable}
returns the fieldnames in a yaml, used for printing, modified for different types of iterables.
RunOnce
E4ST.RunOnce
— Typestruct RunOnce <: Iterable end
This is the most basic Iterable. It only allows E4ST to run a single time.
RunSequential
E4ST.RunSequential
— Typestruct RunSequential <: Iterable
RunSequential(;years)
Runs E4ST sequentially by running years
(or sets of years) one after another. Overwrites config[:years]
, throwing a warning if the first set in iter
is different than that in the config.
years = ["y2020", "y2025"]
: this will run E4ST twice, once for each yearyears = ["y2020", ["y2025", "y2030"]]
: this will run E4ST twice, once for"y2020"
and once for["y2025", "y2030"]