Mimi Framework

Optimizing Mimi Models - JuMP?

Hello everyone,

my question relates to the possibilities of optimizing multiple parameters in a set up and running Mimi model, possibly by using JuMP.

Some background information:
I am currently working on translating an integrated assessment model of which the economic component is based on a Ramsey-type growth model with temperature and climate modules from GAMS to Julia. I started by using JuMP and successfully implemented the model (defining scalars/parameters outside of JuMP, adding variables and constraints to a JuMP model, maximizing welfare using the solver Ipopt).

When I stumbled upon the Mimi framework, it seemed like a good opportunity to re-write my model and adjust it to Mimi. I did that and the model runs - which is good. However, in the process of rewriting I realized, I had to change some endogenous (JuMP) variables (e.g., investment) to exogenously given parameters with set values for every time step. Doing so, I realized that Mimi itself does not perform an optimization under constraints. Accordingly, it uses assignments ("=") in its components instead of equations ("==") as JuMP does. Thus, I gained the impression that Mimi is only a framework to implement and analyze solved models as it does not seem to be able to solve a maximization problem with constraints.

Therefore, my goal for the last couple of days has been to try to optimize some parameters ex-post which are normally endogenous model variables, i.e., when the model is solved and running. I tried using BlackBoxOptim; however, with that approach, I was not able to define different search ranges for the multiple parameters to be optimized and I was not able to add constraints underlying the optimization.

JuMP implementation:
I am new to programming and from my perspective, JuMP seems to be an attractive option to “solve” a running Mimi model. I have thought about something like this for a parameter called Res (Resource extraction):

PRIDED = JuMP.Model(Ipopt.Optimizer)

@variables PRIDED begin
0.00000001 <= Res[t] <= 100
end

@NLconstraints PRIDED begin
resourceeq[i in t], Res[i] == m_opt[:economy, :κ][i] *
m_opt[:economy, :Kr][i]
end

function eval_PRIDED()
update_param!(m_opt,:Res, Res)
run(m_opt)
return m_opt[:economy, :welfare]
end

JuMP.register(PRIDED, :eval_PRIDED, 101, eval_PRIDED, autodiff=true)

objective PRIDED Max begin # third at-sign not possible in this post for some reason
eval_PRIDED()
end

optimize!(PRIDED)

Obviously, this returns an error for “update_param!(m_opt,:Res, Res)”:

“Cannot update parameter Res; expected array of type Union{Missing, Float64} but got VariableRef [the type of JuMP variables].”

My questions:

  • In general, do you think this approach could work? Optimizing parameters by using JuMP?
  • Do you know a workaround for my specific problem? Is there any way to update Mimi parameters by solving the model for optimal values of endogenous variables?

If you have any suggestions, I’d be grateful to hear them. Thanks in advance for your help!

Hi @jgrunau, thank you for your question! We’re a little under water this week with end of year work, but I will bring up your question at our team meeting on Monday and then get back to you.

1 Like

Hello again! I posed your question to @FrankErrickson and @davidanthoff on our team Slack, as they have worked more with optimization within Mimi than I have, including BlackBoxOptim.jl. Their first response is below. Unfortunately our weekly meeting got pushed this week, but I will look into this more tomorrow and discuss with the team this coming Tuesday.


I was under the impression you couldn’t optimize a Mimi model with JuMP, you’d basically just need to recode the entire thing to work with the JuMP framework (basically the first model this user on the forum coded up).

You can pick search ranges in BlackBoxOptim (https://discourse.julialang.org/t/blackboxoptim-beginners-questions/37013). The README has examples of setting the search range, but it’s embedded within other examples so maybe the forum user just missed it.

Not sure about constraints with BlackBoxOptim. You can do constraints in NLopt, but it doesn’t work too great. Two or more constraints is tricky, and if your model is reasonably complicated it won’t really converge. Basically it’d work if you said something like, “Optimize DICE with a 2 degree temperature constraint.” Not sure if that would work with FUND though.