@ckingdon95 can you take a look at this and give me your reactions/post? I can edit this one too if you have reactions. I’m not a FUND expert so I’m not sure which CSV files would be involved, or if there is a need to use the scenconverter
component? I tried to include general workflow info here but you might have some FUND specifics … but I think @Quirin wants to do this in several models so it’s going to change a bit by model.
@Quirin sorry for the delay on details. This is long but I wanted to be thorough, you can skip to the sections that are most useful to you!
I believe the scenario you are in is that you want to alter SSP scenarios, which we have not explicitly built in as a method in Julia. Thus, you need to change the related parameters themselves. If you add an Issue to Github we can consider trying to add this to our API, but it probabl wouldn’t be done for a few weeks.
Tldr; There are two methods discussed and I’ll give details on both in this post:
-
Use the development tools in Julia to download the code base and change the original CSV files of interest. This may be the cleanest way to do things if you are fully replacing the files, since you can cleanly imitate the FUND organization and keep country labels, handle cases where a parameter is a distribution, etc. but it is a bit more software involved. If this is an ongoing project, we should talk about how you can set up your own repository and commit your changes to Github while working on FUND, but for now I’ll show you the quick and dirty way.
-
Continue to use Jupyter notebook and the public API, especially in simple cases like you mentioned (multiplying existing matrixes by a factor rather than replacing them with new ones, for example to raise/lower the individual regional growth rate of per capita consumption for each time period by 50%.)
1. Replacing CSV Files
To do this, you will use the development tools in Julia. You are currently working in a Julia default environment, which you may not know! If you enter Pkg
mode by typing ]
, you will see something like
(v1.2) pkg>
which shows that you are in the v1.1
environment. We’ll just stay in your default for for now. You want to do some development on this package locally, so you are going to type
(v1.2) pkg> dev MimiFUND
This is an alternative to add MimiFUND
, which you used before. Doing this will put a local copy of the MimiFUND
package onto your machine at your equivalent of /Users/lisarennels/.julia/dev
if you are on a mac, or something slightly different on a PC. We can easily help you find it if it’s hidden or anything!
Now when you check that status of your environment with st
you’ll see list of installed packages including a development version of Mimi, something like
(v1.2) pkg> st # st is short for status
[336ed68f] CSV v0.5.13
[e4e893b0] Mimi v0.9.5-DEV [`~/.julia/dev/Mimi`]
...
From now on, when you type using MimiFUND
your machine will look to this local repository. You can open that in any editor to look at and change the CSV files or just work with the file system to replace the CSV files. As @ckingdon95 mentions above, I believe the ones you want to change are at least scenpgrowth
and `scenypcgrowth, @hbenveniste may know too it seems.
Once you replace those files, you can run your code as usual in this environment and it will pick up those changed CSV files!
If at any point you want to return to the standard version of MimiFUND
, you simply use the free
command:
(v1.2) pkg> free MimiFUND
This will bring you back to using our version, but will NOT delete your local copy so that will be saved don’t worry!
2. Using set_param!
It is certainly possible to do this through Jupyter notebook. I will first present an example that multiplies the values of a parameter of interest by 2, and then generalize. First carry out your usual code as follows:
using MimiFUND
using Mimi
m = MimiFUND.get_model() # or m = getfund()
run(m)
Now, you can now access the set values for parameter paramname
in component compname
with bracket indexing. You can then multiply those by two, call set_param!
, and then re-run the model with your new parameters.
values = m[:compname, :paramname]
set_param!(m, :compname, :paramname, values * 2)
run(m)
More generally, you could use set_param!
to replace the parameter values with any values
matrix, as long as it is the correct dimensions etc.
Important: Although this is not a problem in FUND, there is an important thing to note here. If a parameter is reused in more than one component (ie. has the exact same name in more than one component) and you call set_param(m, :compname, :paramname, values)
, the parameter values will be changed not only in compname
, but also in all other components where that parameter is connected. We are soon adding an explicit flag and warning for this, but I wanted to give a heads up.
Don’t hesitate to respond to this with any further questions or clarifications, or email me to schedule a call! You can copy and paste code or error messages here too if it’s not proprietary.