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
Formalize 'evaluable parameter' #2754
Formalize 'evaluable parameter' #2754
Conversation
This includes updating the relation to Evaluate = true.
With separation of normal and structural parameters, it seems possible to give a more imperative meaning of Evaluate, removing some room for ambiguities and unexpected differences between tools.
In OpenModelica we define a parameter as structural if it must be evaluated by our frontend at compile time, such as a parameter used to define an array dimension in a simulation model. Your definition seem to be slightly different in that you define all parameters to be structural unless there's a reason for them not to be. Our implementation is somewhat incompatible in this regard since we require structural parameters to have a binding equation that can be evaluated at compile-time, like constants, while you allow them to be given a value during initialization. Of course, OM is stricter in this case than the specification, so it could be considered a tool issue if this is something we want to allow. Also, it seems to me like your definition is too broad for "structural" to be the correct word to use, since it will include a lot of parameters that don't actually affect the "structure" of the model. I don't have a better suggestion, but it's perhaps something to consider in order to avoid potentially confusing terminology. |
Yes, I know that the proposed nomenclature doesn't match exactly what many of us have in mind. I think it could be both good and bad to reuse terms that already have associate meanings outside the current specification:
I should have said it from the beginning: What is commonly thought of as a "structural parameter" today, would in the current proposal translate into a (structural) parameter required by a structural expression (and as you noted, such a parameter has to be structural). Often, however, I believe that a more interesting classification is an evaluated structural parameter, which doesn't have to do with where the structural parameter is used, but emphasizing that this structural parameter is determined at translation time. When choosing terminology, I'd like to start with the kind of expression variability that is required for things like array dimensions. Here, I think structural expression is a very natural name considering that we all seem to have some sort of "structural" in mind when it comes to these things. Then, we also need a name for a (more or less explicitly) declared variability associated with structural expression, and then structural parameter was the most natural I could think of.
This sounds like a misunderstanding, unless this is only confusion due to reuse of terminology. The point is that just like today's "unqualified" parameters, a structural parameter does not have to be determined during translation, but the intention is really that a structural parameter is something as easy to evaluate at translation time as a constant. Wherever the specification requires a structural expression, all parameters involved will need to be structural, and will be possible to determine during translation. Hopefully, tools will be able to agree on which the structural parameters are (this PR might not be sufficient to really get us there), and then only differ when it comes to which of those that become determined during translation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally agree with this proposal.
To not only write in defense of the proposed nomenclature, let's make a list of alternatives:
|
Co-authored-by: Gerd Kurzbach <Gerd.Kurzbach@esi-group.com>
I only scanned this pull request due to lack of time (and maybe missed essential points): If this proposal is just for making the specification clearer without changing existing models (and the existing semantics of the Modelica language), this is of course good. However, I fear that you plan to introduce restrictions on the language that are currently not present, and this in a core part of the language that is present in nearly every model, at least if arrays are declared. Please, can you confirm, that the current semantics of the Modelica language is not changed with your proposal and that it will not have any effect on existing models. |
The goal is to specify this in a way that doesn't require changing existing models, at least as long as one stays away from models that exhibit tool specific corner case behaviors. For example, since none of the MSL models should depend on such tool specific behaviors, it should work just like as before. Trying to summarize implications for semantics (let's assume #2754 (comment) is accepted):
Example of changed semantics for non-fixed parameter:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If people don't agree about the implications of this proposal it is clear that we need to change it.
Yes. I am doing my best to identify any implications causing disagreement, and find ways to adapt the proposal. The proposal is in Draft state for good reasons. :) |
Addressing use case suggested by Hans.
Removed Draft status to indicate that this seems to have converged to something where at most some minor remarks remain to be resolved. |
I think we might need to revisit this again in detail the next year, as we are getting user requests for allowing at least some more attributes to be non-evaluated parameters. (Currently Dymola forces all attributes except It shouldn't prevent us from formalizing structural parameters - and it may even make it easier to describe as it reduces the need to have parameters as structural. However, when glancing through the proposal I couldn't see anything related to these attributes, which makes me a bit confused. On one hand it seems in line with not requiring some of the attributes to be evaluated, but on the other hand at least the A minor note is that Dymola also allow |
This is a correct observation. The first step is to formalize the concept. The next step is to apply the new concept in selected places, and then we might need to have separate issues about different places of application. |
Design meeting: Gerd: Elena: "normal" is a very overloaded word. Alternatives with poll:
Henrik: Good to at least include array size as first case of an evaluable expression. Language group: Include array size as first example. Hans: There are two lists of things today that should be required evaluable: things that are explained one way or another today, and things where nothing related to evaluability is said today. Examples of the first: Plan:
|
7d99775
to
3b05128
Compare
The terminology has been updated to non-evaluable parameter, the problem with @HansOlsson, you have a very old review that is still blocking this. Could you please provide a fresh review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ok, except for some minor issues.
As suggested by Hans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comment, but seems good enough.
The need for formalization of evaluable parameter is far from new, and has recently come up again in different issues:
initial
sections. #2602 – Clean definition of variability insides initial sections needs distinction between evaluable variability and parameter variability.This PR proposes definitions of evaluable parameter and evaluable expression (corresponding variability) in a way that I hope is more or less in line with how these things work in tools already today (therefore hoping that this doesn't need to be considered MCP content). The three issues above are just some examples of things that would be clarified, making the specification easier to digest for uses, and more straight-forward to implement for tool makers.
At the time of setting up this PR, the changes are restricted to the following essential parts:
Evaluate
annotation.Once we agree what these should be, it remains to update the specification to say evaluable expression rather than parameter expression everywhere something needs to be known at translation time.
I'd be interested to know what other tool makers are willing to share regarding support for these variants, in case that would reveal more things that should actually be locked down by the specification:
Evaluate = false
for a constant.Evaluate = true
are used in simplifications when verifying the acyclic binding rule.Original formulation with structural parameter terminology
The rest of this comment shows what this first comment looked like before the change of terminology from structural parameter to evaluable parameter. It might be good to be aware of this original variant in order to be able to make sense of some of the subsequent comments…
The need for formalization of structural parameter is far from new, and has recently come up again in different issues:
initial
sections. #2602 – Clean definition of variability insides initial sections needs distinction between structural variability and parameter variability.This PR proposes definitions of structural parameter and structural expression (corresponding variability) in a way that I hope is more or less in line with how these things work in tools already today (therefore hoping that this doesn't need to be considered MCP content). The three issues above are just some examples of things that would be clarified, making the specification easier to digest for uses, and more straight-forward to implement for tool makers.
At the time of setting up this PR, the changes are restricted to the following essential parts:
Evaluate
annotation.Once we agree what these should be, it remains to update the specification to say structural expression rather than parameter expression everywhere something needs to be known at translation time.
I'd be interested…