I tried to make some changes in the Mimi-RICE model to divide the regions index internally into two subsets of developing countries and developed countries. Is there any syntax in the mimi or Julia syntax that can do the following division?
Hi Emily,
Thanks for the question! To understand your end goals further, is the idea that you want to aggregate certain output variables using two subsets of the regions dimension of a model, or run the model itself using two subsets (developing and developed) of the built in regions dimension? Or perhaps something else?
Lisa
Hi Lisa, thanks for your reply!
I modified the original “neteconomy” module to provide different investment mechanisms for developing and developed regions (meaning different equations for different region types), and later to aggregate regional results. If you have the method to set subset, please let me know!
Got it thanks this is really helpful! So this is actually something in Mimi that I am actively working on right now here so a few users, including myself, want to do something similar.
The basic issue is that d
is a NamedTuple
that only holds information on (1) dimension names and (2) how many elements there are in each dimension. It represents the indices as integers of 1 through size of dimension, which can then be used for indexing into Parameter
s and Variable
s, but d
does not contain information on the keys like “EU”. If you typed
for r in d.regions
println(r)
end
it would print
1
2
3
...
And instead we want it to now be able to give us the actual keys. While I work on that, what I would suggest is externally figuring out which Integer indices apply to the subsets. The simplest way then would be:
for region in d.regions
if r in [1,3,5,9]
<do something>
else
<do something else>
end
To add some structure to this and make it a bit more robust, you could actually create Parameter
s for those sets of region indices. So then you’d end up with something like
# these use an anonymous dimension e.g. index = [4] that just tells the index how long your array will be, no need to use a named dimension here
developing_region_idxs = Parameter(index=[4]) # use an anonymous dimension for the size
developed_region_idxs = Parameter(index=[5]) # use an anonymous dimension for the size
for region in d.regions
if r in p.developing_region_idxs
<do something>
elseif r in p.developed_region_idxs
<do something else>
end
Then when building your model you would need to lookup what those indices are, either by hand or with some lookup function, and then set them
update_param!(m, :neteconomy, :developing_region_idxs, [1,3,5,9])
update_param!(m, :neteconomy, :developed_region_idxs, [2,4,6,7,8])
Let me know how that goes, there are a few ways we could approach this.
Hi Lisa
I have tried your approach and it seems works for me! Thanks for your help!