Hi,
I have been going back over Tutorial 5 as I have switched IDEs from Atom to VSCode. To simplify things, I am using the One-Region Model from Tutorial 4 rather than the Multi-Region Model. To further simplify things, I am just looking at two parameters - share and s. The latter is indexed by time, so I have been trying to just change the values for the time periods between 2015 and 2050. I did try to use a line like:
s[2015:5:2020] = Uniform(0.2, 0.3)
This seems to work fine at first, but when I try to run the following:
si = run(sd, m, 10; trials_output_filename = “./Results/trialdata.csv”, results_output_dir="./Results")
I get this error “ArgumentError: indexed assignment with a single value to many locations is not supported; perhaps use broadcasting .=
instead?”
So, I went back and modified the earlier line to read:
s[2015:5:2020] .= Uniform(0.2, 0.3)
but, then I get this error: “LoadError: LoadError: Unrecognized expression ‘s[2015:5:2050] .= Uniform(0.2, 0.3)’ in @defsim”
I have tried lots of other things, but to no avail. I finally ended up with the following code to define the Monte Carlo Simulation, which worked with my si = run(. . . ) function.
sd = @defsim begin
# assign RVs to model Parameters
share = Uniform(0.2, 0.8)
s[2015] = Uniform(0.2, 0.3)
s[2020] = Uniform(0.2, 0.3)
s[2025] = Uniform(0.2, 0.3)
s[2030] = Uniform(0.2, 0.3)
s[2035] = Uniform(0.2, 0.3)
s[2040] = Uniform(0.2, 0.3)
s[2045] = Uniform(0.2, 0.3)
s[2050] = Uniform(0.2, 0.3)
# Indicate which variables to save for each model run.
# The syntax is: component_name.variable_name
save(grosseconomy.share, grosseconomy.s, grosseconomy.K, grosseconomy.YGROSS,
emissions.E)
end
Surely, there must be a more elegant way to do this.
In addition, this now randomly assigns different values for s for each time step from 2015 to 2050 in each trial, rather than having the same values for s for all time steps from 2015 to 2050 within each trial, but different ones from trial to trial.
I tried many things, e.g.,
s[2015:5:2050] = s[2015:5:2050] = ones(8) .* Uniform(0.2, 0.3)
but to no avail.
p.s. I also played with the *= function like in the line from Tutorial 5. My specific line was:
s[2020:5:2050] *= Uniform(0.9, 1.1)
When I did this, I noted that instead of multiplying by the default value for s[2020:5:2050], which is 0.22, in each trial, it was multiplying by the value of s[2020:5:2050] from the previous trial. So, across the trials, instead of s[2020:5:2050] being a uniform distribution around 0.22, it took on the characteristic of a random walk starting at 0.22.