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!