Delete component in MimiGIVE

I’m working through the new how to guide on how to add a new damage sector in MimiGIVE. I’d like to delete one component after adding the new one as follows: delete!(m, :CromarMortality).

However, it looks like there are still some stray parameters in the damage aggregator. How should I proceed here?

I see this discussion on stray parameters and I’m wondering if that’s applicable here?

2 Likes

Hi @naomishimberg thanks for the question!

Good find on the discussion of stray parameters. While I think in your case using the deep keyword argument, which was what we added in response to that Issue (ie. delete!(m, :CromarMortality, deep = true) is a good idea in this case, I do not believe will fully solve your Error here. That will clean up isolated Parameters that are not connected to anything anymore, but you need to solve the sort of reverse problem. You have removed a Component that used to calculate Variables that became inputs to other Components.

What I would do is take a look at the original MimiGIVE.get_model function, and look for places where components are taking values from :CromarMortality via connect_param! as close for where you need to make more modifications in the Model. For example:

connect_param!(m, :DamageAggregator => :damage_cromar_mortality, :CromarMortality => :mortality_costs)

which I think is actually causing your problem, and maybe is the only connection but you should double check the model.

So what you need to do here is one of two things. First of all, and mostly cleanly, replace! the :DamageAggregator component with one that does not need an input from :CromarMortality ie. remove the line

damage_cromar_mortality = Parameter(index=[time,country], unit="US\$2005/yr")

from that component and also clean up any places that the Component uses that Parameter, or a derivative of the data from it in intermediate Variables. The second option could be to use a dummy parameter I you want, for example, to just set it to all zeros with something like:

update_param!(m, :DamageAggregator, :damage_cromar_mortality, zeros(length(1750:2300), 184))

I would probably not recommend that path, except as a patch, just since it’s not as clean and leaves around meaningless Parameters etc. that could confuse you later.