Optimizing MimiDICE

Thank you both so much @lrennels and @jrising for all your effort! This already helped a lot, I got the optimization running without the constraint!

Unfortunately, I can’t get the constraint to work, but that might also be due to my not (yet) great julia skills. I just followed the example that was given on the readme file from OptiMimi.
I created an example that should run through faster with just a few timesteps:

#add Mimi registry (registry with the Mimi models), Mimi, MimiDICE2016 and OptiMimi
#] registry add https://github.com/mimiframework/MimiRegistry.git
#] add Mimi
#] add https://github.com/AlexandrePavlov/MimiDICE2016.jl
#] add OptiMimi#master

#or update packages
#] update

# use the model
using MimiDICE2016
# access the public API of MimiDICE2016 with MimiDICE2016.get_model, which returns a copy of the default model
m_opti = MimiDICE2016.get_model() 
# run the model
run(m_opti)
# make model shorter for faster computing:
using Mimi
const years = collect(2015:5:2035)
set_dimension!(m_opti, :time, years)


# setting up the optimization problem

using OptiMimi

function objective(model::Model)
    model[:welfare, :CUMCEMUTOTPER][5]
end

constraint = [model -> sum(model[:emissions,:MIU]) - 1]
    
optprob = problem(m_opti, [:emissions], [:MIU], [0.], [1.2], objective
    , constraints=constraint
    )

# solving the optimization problem

(maxf, maxx) = solution(optprob, () -> [0. for i in 1:5])
println(maxf)
println(maxx)

update_param!(m_opti, :MIU, maxx)

The error I get after the line with “optprob=…” reads:

ERROR: TypeError: in keyword argument constraints, expected Vector{Function}, got a value of type Vector{var"#1#2"}

I would be very glad if you could help me with that. I already tried looking it up and tried some different formulations for the constraint, but there remained an error. Also I would like to let the constraint hold only for a few time periods, but I guess I get that implemented after I get a constraint working.