You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorials/tutorial_2.md
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,6 @@ Working through the following tutorial will require:
10
10
11
11
**If you have not yet prepared these, go back to the first tutorial to set up your system.**
12
12
13
-
Note that we have recently released Mimi v1.0.0, which is a breaking release and thus we cannot promise backwards compatibility with version lower than v1.0.0 although several of these tutorials may run properly with older versions. For assistance updating your own model to v1.0.0, or if you are curious about the primary changes made, see the How-to Guide on porting to Mimi v1.0.0. Mimi v0.10.0 is functionally dentical to Mimi v1.0.0, but includes deprecation warnings instead of errors to assist users in porting to v1.0.0.
14
-
15
13
#### Step 1. Download FUND
16
14
17
15
The first step in this process is downloading the FUND model, which is now made easy with the Mimi registry. Assuming you have already done the one-time run of the following command to connect your julia installation with the central Mimi registry of Mimi models, as instructed in the first tutorial,
Copy file name to clipboardExpand all lines: docs/src/tutorials/tutorial_3.md
+23-9Lines changed: 23 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,6 @@ Working through the following tutorial will require:
10
10
11
11
**If you have not yet prepared these, go back to the first tutorial to set up your system.**
12
12
13
-
Note that we have recently released Mimi v1.0.0, which is a breaking release and thus we cannot promise backwards compatibility with version lower than v1.0.0 although several of these tutorials may run properly with older versions. For assistance updating your own model to v1.0.0, or if you are curious about the primary changes made, see the How-to Guide on porting to Mimi v1.0.0. Mimi v0.10.0 is functionally dentical to Mimi v1.0.0, but includes deprecation warnings instead of errors to assist users in porting to v1.0.0.
14
-
15
13
## Introduction
16
14
17
15
There are various ways to modify an existing model, and this tutorial aims to introduce the Mimi API relevant to this broad category of tasks. It is important to note that regardless of the goals and complexities of your modifications, the API aims to allow for modification **without alteration of the original code for the model being modified**. Instead, you will download and run the existing model, and then use API calls to modify it. This means that in practice, you should not need to alter the source code of the model you are modifying. Thus, it is easy to keep up with any external updates or improvements made to that model.
@@ -22,15 +20,21 @@ Possible modifications range in complexity, from simply altering parameter value
22
20
23
21
Several types of changes to models revolve around the parameters themselves, and may include updating the values of parameters and changing parameter connections without altering the elements of the components themselves or changing the general component structure of the model. The most useful functions of the common API in these cases are likely **[`update_param!`](@ref)/[`update_params!`](@ref), [`disconnect_param!`](@ref), and [`connect_param!`](@ref)**. For detail on these functions see the API reference guide, Reference Guide: The Mimi API.
24
22
25
-
When the original model calls [`set_param!`](@ref), Mimi creates an shared model parameter by the name provided, and stores the provided scalar or array value. The functions [`update_param!`](@ref) and [`update_params!`](@ref) allow you to change the value associated with this shared model parameter.
23
+
The parameters in the original model receive their values either from exogenously set model parameters through external parameter connections, or from another component's variable through an internal parameter connection.
24
+
25
+
The functions [`update_param!`](@ref) and [`update_params!`](@ref) allow you to change the value associated with a model parameter. If the model parameter is shared, obtain the shared model parameter name (often this will be the same as the parameter name by default) and use the following to update it:
Note here that `newvalues` must be the same type (or be able to convert to the type) of the old values stored in that parameter, and the same size as the model dimensions indicate.
32
36
33
-
If you wish to alter connections within an existing model, [`disconnect_param!`](@ref) and [`connect_param!`](@ref) can be used in conjunction with each other to update the connections within the model, although this is more likely to be done as part of larger changes involving components themslves, as discussed in the next subsection.
37
+
The functions [`disconnect_param!`](@ref) and [`connect_param!`](@ref) can be used to to alter or add connections within an existing model. These two can be used in conjunction with each other to update the connections within the model, although this is more likely to be done as part of larger changes involving components themselves, as discussed in the next subsection.
34
38
35
39
## Parametric Modifications: DICE Example
36
40
@@ -76,7 +80,7 @@ In the case that you wish to alter an exogenous parameter, you may use the [`upd
76
80
using Mimi
77
81
```
78
82
79
-
In DICE the parameter `fco22x` is the forcings of equilibrium CO2 doubling in watts per square meter, and exists in the components `climatedynamics` and `radiativeforcing`. We can change this value from its default value of `3.200` to `3.000` in both components, using the following code:
83
+
In DICE the parameter `fco22x` is the forcings of equilibrium CO2 doubling in watts per square meter, and is a shared model parameter with the same name that is connected to components `climatedynamics` and `radiativeforcing`. We can change this value from its default value of `3.200` to `3.000` in both components, using the following code:
80
84
81
85
```julia
82
86
update_param!(m, :fco22x, 3.000)
@@ -85,7 +89,7 @@ run(m)
85
89
86
90
A more complex example may be a situation where you want to update several parameters, including some with a `:time` dimension, in conjunction with altering the time index of the model itself. DICE uses a default time horizon of 2005 to 2595 with 10 year increment timesteps. If you wish to change this, say, to 1995 to 2505 by 10 year increment timesteps and use parameters that match this time, you could use the following code:
87
91
88
-
First you upate the `time` dimension of the model as follows:
92
+
First you update the `time` dimension of the model as follows:
At this point all parameters with a `:time` dimension have been slightly modified under the hood, but the original values are still tied to their original years. In this case, for example, the model parameter has been shorted by 9 values (end from 2595 --> 2505) and padded at the front with a value of `missing` (start from 2005 --> 1995). Since some values, especially initializing values, are not time-agnostic, we maintain the relationship between values and time labels. If you wish to attach new values, you can use `update_param!` as below. In this case this is probably necessary, since having a `missing` in the first spot of a parameter with a `:time` dimension will likely cause an error when this value is accessed.
98
102
99
-
Create a dictionary `params` with one entry `(k, v)` per model parameter you want to update by name `k` to value `v`. Each key `k` must be a symbol or convert to a symbol matching the name of a shared model parameter that already exists in the model definition. Part of this dictionary may look like:
103
+
To batch update **shared** model parameters, create a dictionary `params` with one entry `(k, v)` per model parameter you want to update by name `k` to value `v`. Each key `k` must be a symbol or convert to a symbol matching the name of a shared model parameter that already exists in the model definition. Part of this dictionary may look like:
To batch update **unshared** model parameters, follow a similar pattern but use tuples (:comp_name, :param_name) as your dictionary keys, which might look like:
115
+
116
+
```julia
117
+
params =Dict{Any, Any}()
118
+
params[(:comp1, :a1)] =0.00008162
119
+
params[(:comp1, :a2)] =0.00204626
120
+
...
121
+
params[(:comp2, :S)] =repeat([0.23], nyears)
122
+
...
123
+
```
124
+
110
125
Now you simply update the parameters listen in `params` and re-run the model with
111
126
112
127
```julia
113
128
update_params!(m, params)
114
129
run(m)
115
130
```
116
-
117
131
## Component and Structural Modifications: The API
118
132
119
133
Most model modifications will include not only parametric updates, but also structural changes and component modification, addition, replacement, and deletion along with the required re-wiring of parameters etc. The most useful functions of the common API, in these cases are likely **[`replace!`](@ref), [`add_comp!`](@ref)** along with **`delete!`** and the requisite functions for parameter setting and connecting. For detail on the public API functions look at the API reference.
Copy file name to clipboardExpand all lines: docs/src/tutorials/tutorial_4.md
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,6 @@ Working through the following tutorial will require:
11
11
12
12
**If you have not yet prepared these, go back to the first tutorial to set up your system.**
13
13
14
-
Note that we have recently released Mimi v1.0.0, which is a breaking release and thus we cannot promise backwards compatibility with version lower than v1.0.0 although several of these tutorials may run properly with older versions. For assistance updating your own model to v1.0.0, or if you are curious about the primary changes made, see the How-to Guide on porting to Mimi v1.0.0. Mimi v0.10.0 is functionally dentical to Mimi v1.0.0, but includes deprecation warnings instead of errors to assist users in porting to v1.0.0.
15
-
16
14
## Constructing A One-Region Model
17
15
18
16
In this example, we construct a stylized model of the global economy and its changing greenhouse gas emission levels through time. The overall strategy involves creating components for the economy and emissions separately, and then defining a model where the two components are coupled together.
Copy file name to clipboardExpand all lines: docs/src/tutorials/tutorial_5.md
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,6 @@ Working through the following tutorial will require:
11
11
12
12
**If you have not yet prepared these, go back to the first tutorial to set up your system.**
13
13
14
-
Note that we have recently released Mimi v1.0.0, which is a breaking release and thus we cannot promise backwards compatibility with version lower than v1.0.0 although several of these tutorials may run properly with older versions. For assistance updating your own model to v1.0.0, or if you are curious about the primary changes made, see the How-to Guide on porting to Mimi v1.0.0. Mimi v0.10.0 is functionally dentical to Mimi v1.0.0, but includes deprecation warnings instead of errors to assist users in porting to v1.0.0.
15
-
16
14
MimiDICE2010 is required for the second example in this tutorial. If you are not yet comfortable with downloading and running a registered Mimi model, refer to Tutorial 2 for instructions.
0 commit comments