Skip to content

update_param! dirties the model definition #753

@davidanthoff

Description

@davidanthoff

When I do this:

julia> m = MimiFUND.get_model()
Mimi.Model
  Module: Mimi
  Components: 
    ComponentId(MimiFUND.scenariouncertainty)
    ComponentId(MimiFUND.population)
    ComponentId(MimiFUND.geography)
    ComponentId(MimiFUND.socioeconomic)
    ComponentId(MimiFUND.emissions)
    ComponentId(MimiFUND.climateco2cycle)
    ComponentId(MimiFUND.climatech4cycle)
    ComponentId(MimiFUND.climaten2ocycle)
    ComponentId(MimiFUND.climatesf6cycle)
    ComponentId(MimiFUND.climateforcing)
    ComponentId(MimiFUND.climatedynamics)
    ComponentId(MimiFUND.biodiversity)
    ComponentId(MimiFUND.climateregional)
    ComponentId(MimiFUND.ocean)
    ComponentId(MimiFUND.impactagriculture)
    ComponentId(MimiFUND.impactbiodiversity)
    ComponentId(MimiFUND.impactcardiovascularrespiratory)
    ComponentId(MimiFUND.impactcooling)
    ComponentId(MimiFUND.impactdiarrhoea)
    ComponentId(MimiFUND.impactextratropicalstorms)
    ComponentId(MimiFUND.impactforests)
    ComponentId(MimiFUND.impactheating)
    ComponentId(MimiFUND.impactvectorbornediseases)
    ComponentId(MimiFUND.impacttropicalstorms)
    ComponentId(MimiFUND.vslvmorb)
    ComponentId(MimiFUND.impactdeathmorbidity)
    ComponentId(MimiFUND.impactwaterresources)
    ComponentId(MimiFUND.impactsealevelrise)
    ComponentId(MimiFUND.impactaggregation)
  Built: false


julia> m = MimiFUND.get_model()^C

julia> m.md.dirty
true

julia> run(m)

julia> m.md.dirty
false

julia> update_param!(m, :co2pre, 270)
true

julia> m.md.dirty
true

What this means is that code like this:

for i=1:10
  update_param!(m, :foo, rand())
  run(m)
end

will rebuild the model instance in every loop.

That is not how it should be, right? We want to be able to update external parameter values and rerun without rebuilding, it seems to me?

Or do we need to manually construct a model instance in that case and then update the parameter values only in the model instance?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions