Skip to content

Monte Carlo and default params #755

@lrennels

Description

@lrennels

Frank

I'm doing a Monte Carlo with SNEASY and there are a couple parameters with default values. When I try to do an update_param! on them, it throws the error: Cannot update parameter; CO₂_0 not found in composite's external parameters. So to do a Monte Carlo, I have to first do a set_param! with a fake value, and then I can carry out the Monte Carlo runs with the update_param! syntax. Am I misunderstanding how this should work? If so, it seems like default values should only be used for things you never plan to change?

Here's some code to show what I'm talking about.

This errors

using Mimi
using MimiSNEASY
m = MimiSNEASY.get_model()
co2_vals = [281.0, 282.5]
for i = 1:2
	update_param!(m, :CO₂_0, co2_vals[i])
	run(m)
end

This works

using Mimi
using MimiSNEASY
m = MimiSNEASY.get_model()
set_param!(m, :rfco2, :CO₂_0, 10000.0)
co2_vals = [281.0, 282.5]
for i = 1:2
	update_param!(m, :CO₂_0, co2_vals[i])
	run(m)
end

David

Actually, I think I remember now why we did it the way it is right now: the alternative design would be that if one adds a component to a model, and that component has a parameter with a default value, we add an external parameter to the model with that name, set it to the value from the component, and then connect things up. So far so good, but if one then adds another component that has a parameter with the same name that also has a default value, then it is unclear how we would handle that.

Maybe we need a function that "elevates" a default parameter from a component to the model level...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions