Glad that worked! You should be able to apply to apply the constraints over just a time period, by selecting only some of the values out of the array, like model -> sum(model[:emissions, :MIU][10:20]) - 0.2
. It’s not pretty, but it will depend on what exactly you want to do.
Perfect, that works too!
Hello everyone,
I was facing a similar issue when I tried optimising MimiDICE2016R2 this summer. OptiMimi did not work because installing the package in my Julia environment forcefully downgraded my Mimi version:
Hence, I let myself be inspired by the code for Budolfson et al. (2021) and created my own fork of MimiDICE2016R2 (OptMimiDICE2016R2) which has an in-built optimise_model
function. Maybe that’s helpful to some people landing in this forum!
Cheers!
Hello jrising, I want to know how to reduce it to 2 parameters? Is it convenient for you to post the total code? It could offer great help.
Here’s a simple example that uses paramtrans
to optimize DICE with 3 parameters (just an increase in carbon price that takes 3 periods):
using Mimi
using OptiMimi
using MimiDICE2016
using Distributions
model = MimiDICE2016.get_model()
run(model)
cprice_desired = 100
function objective(model::Model)
-(abs(model[:neteconomy, :CPRICE][1] - 0) + sum(abs.(model[:neteconomy, :CPRICE][2:4] .- cprice_desired)))
end
optprob = problem(model, [:emissions], [:MIU], zeros(3), 0.99 * ones(3), objective,
paramtrans=convert(Vector{Function}, [(params) -> [0; params; params[3] * ones(96)]]))
soln = solution(optprob, () -> rand(Uniform(0.01, 0.99)) * ones(3))
println(soln)
update_param!(model, :MIU, [0; soln[2]; soln[2][3] * ones(96)])
run(model)