Could I get an explanation why there needs to be a distinction between set_param! and update_param!? I noticed that @ckingdon95 has started to use the pattern:
try
set_param!(m, :param, value)
catch e
update_param!(m, :param, value)
end
which makes me think that we need a function that is essentially set_or_update_param! with this logic (though maybe with a call to has_parameter rather than the try-catch). In fact, I’ve now started using such a function. But why do we need this distinction at all?
In v1.0 of Mimi, we made stricter rules for the set_param! function. If a model already has an external parameter called :param1 and you try to call set_param!(m, :param1, val) it will error. Instead, update_param! must be used if :param1 already exists in the model’s list of external parameters.
The reason this is showing up in the PAGE compute_scc function is that the model m that gets passed to the function might or might not already have a value set for ptp or emuc.
I agree it’s a bit cumbersome to have to set up a bunch of these try/catch statements though. I can raise the idea of set_or_update_param! to the broader group tomorrow. Another option might be to add a keyword override or update to the set_param! function which if set to true would tell it to just update instead of erroring if the parameter name already exists in the models list. (I haven’t fully thought through the implications of this)
I understand the difference between the set_param! and update_param! functions, but not the motivation. We aren’t doing functional programming, so it feels out of place. If it isn’t required by some underlying Mimi logic, it would be preferable to remove this distinction and just make these functions synonyms (and ultimately deprecate update_param!).