WIP Add Dimension Key Access to run_timestep function
#1017
+46
−6
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.
Handling part of #948 (also mentions access to
tininitbut save that for a second PR)The goal of this PR is to add access to the dimension keys from within components. Currently for a
run_timestep(p,v,d,t)function,d.dim_namewill return a vector of theTypeneeded to index into Arrays for the dimension, namelyInts for all dimensions excepttimefor which it is our customTimesteptype.While this is useful for a loop like
there are times a user would like to check the actual keys, I think the core example being something like
Note the line above fails because
dis an Integer (eg. in GIVE we know it is 174, the index of the key "USA" in the countries dimension vector).One way to pass information to
run_timestepwithout breaking compatibility is to have keyword args we set during initialization, and then are in scope for the function, that the user never needs to see or manipulate. We have access to the entireModelInstanceat the time of runningrun_timestep.Some decisions/TODOs
get_dim_keys(dim_name::Symbol)function, but we could really pass any structure that is useful. Instead of a function we could have an object calledd_keysthat is exactly the same asdbut returns the keys?initas well (?)