-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to set_param! #524
Comments
Maybe also need: set_param!(m, [:compA, :compC, :compD], :p1, 23)
set_param!(m, [:compA=>:p1, :compC=>:p3], :p_ext_3, 34.)
connect_param!(m, :compA, :p1, :p_ext_3) |
set_param!(m, :compA, :p1, 34.)
set_param!(m, :compB, :p1, 12.) error. Rollout is: we add the new fancy functions with better names first, tag a release. Then we migrate models over to that. Then we start to throw errors in a future Mimi release for the buggy |
@davidanthoff, The current design defines This is necessary since a component might have external params and it can't be aware of external params of the same name defined elsewhere in the model. To connect these knowledgeably, I suggest we provide a function that lists all the external params of a given name, ideally with a documentation string, so the modeler can learn whether all the params named Should this method apply only to unbound params? What if you want to join together parameters The existing We will also need a method for disconnecting individual component's parameter from a joined set, or at least to delete the external parameter and all connections to it, forcing the user to recreate a set with fewer parameters. |
@davidanthoff, @ckingdon95, @lrennels: I feel like the overall design of the composites is getting away from me / us. We have a number of discussion threads, but it's hard to distill a set of design decisions from all of this. This is the main stumbling block to finishing the implementation. I think we may want to do one or both of the following:
|
Some of the guidance above doesn't account for hierarchy, e.g. set_param!(m, [:compA, :compC, :compD], :p1, 23)
set_param!(m, [:compA=>:p1, :compC=>:p3], :p_ext_3, 34.) A single symbol is not an adequate descriptor for a component in a hierarchical model. These would have to become either Just checking that I've not misunderstood the intention. |
I definitely agree that the design is getting away from us, and I think we should discuss it in depth this Friday! While I'm thinking about it now, though, I'm just going to respond to your second comment about hierarchy. This is how I was interpreting our intention: we would no longer use ComponentPath's to set parameters, because all parameters that are not resolved by internal connections automatically get "bubbled up" to the namespace of the parents. So you would only call I think the way that I wrote the composite version of DICE is consistent with this: https://github.com/anthofflab/MimiDICE2010.jl/pull/24/files you'll see that all of the calls to |
This is exactly what you said in your comment on Jun 17 on that other thread. I repeat, yes this is getting away from us!! |
Thanks, Cora. I'll have to review all these threads and extract actual decisions so we can review them. |
Yes, I think @ckingdon95 has it right: I think we never need to deal with nested external parameter problems. If I use a composite component, then from the outside it should look exactly like a leaf component, i.e. at no point should I be exposed to the fact that internally it is a composite. So that in particular means that I should never be exposed to external parameters that are deeper down in the tree. Happy to have a meeting dedicated to all of this. |
I’ll look over this today, but agree I’m happy to dedicate a good amount of Friday's meeting to this so we’re all on the same page! |
@rjplevin mentioned over in #651 (comment) that set_param!(m, :example, :p1, 1:5)
set_param!(m, :example, :p2, reshape(1:15, 5, 3)) wouldn't work going forward. I think the only breaking change to |
Unsure what a "simple"
But as per yesterday's discussion, I think the way to go is the "smart" |
As I wrote in #651,
I think the best approach is the first one above, i.e., the "import on demand". I thought we decided this form (with component named) was deprecated:
Since we're allowing setting params only at the model level. |
No, the spec we came up with is at the top of this issue here, and it does not deprecate this. I can't find any discussion where we said this would be deprecated (that would be a massively, massively breaking change, so that is just generally not an option). The only thing we said would change is that this situation will throw an error is there is an ambiguity, the details of that are described at the top of this issue.
I don't understand this, in particular not that At the model level, the only change we want is what is described at the top of this issue, no other breaking changes. I think all of that is entirely independent of the composite stuff, because from the point of view of a model, it really shouldn't matter whether something is a leaf or composite component, from the model composition point of view they should really look the same. |
I've implemented the core functions described by @davidanthoff in the first comment. Now moving this issue to milestone v1.1 because the methods described in David's second and third comment are not implemented yet, but can be added later as an enhancement. |
The methods in David's 3rd comment and one from the 2nd comment, PR #800 implements |
Closing for now since most will be taken care of in new issues, @wingfactor those methods will still be useful we can just incorporate them into the upcoming work! |
The core functions are:
And the shortcuts are:
This function would look at all the components in the model, find all the unbound parameters named
p1
, create an external parameter calledp1
, set its value to23
, and create connections from all the external unbound parameters that are namedp1
to the external parameterp1
. If there is already ap1
in the external parameter list, it errors.This function creates a new external parameter called
p1
(if that already exists, it errors), sets its value to34.
, and then connectscompA/p1
to this external parameterp1
.The text was updated successfully, but these errors were encountered: