-
Notifications
You must be signed in to change notification settings - Fork 41
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
Change so that all variables in initial algorithms are treated the same #3562
base: master
Are you sure you want to change the base?
Conversation
Note this is already how it works in Dymola. I'm not aware of any tool that implemented the semantic that lead to a loop for any variable with a when-clause also assigned in an initial algorithm. |
As I wrote in #3472, this is also how I understand it works in OMC already. @phannebohm, @kabdelhak, can you please confirm? |
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 still haven't had time to test implement, but I believe we want the new initialization to also apply to a "non-initial
" algorithm
when treated as part of the initialization problem. Is this what the tools with test implementations currently do?
Check what happens if a normal algorithm ends up in an initial system of equations (seems only problematic if there is a when-clause for the variable as well). |
At first I thought that the proposed changes of this PR only seemed relevant for obscure cases. However, investigating more the conclusion is that it would be a breaking change with unknown consequences. The issue would occur if we have a discrete variable assigned in a when-equation (see later for when-algorithm) and also assigned in a normal algorithm. That would mean something like:
The idea is here to solve the algorithm for However, for an algorithm we could have a case such as:
The description states for For |
Sure, that's why we need a concrete proposal that can be evaluated against existing libraries on our radars. |
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 don't know what kind of review that is expected of me at this time. My impression was that you @HansOlsson would test a couple of variants to see how they work, and then make a concrete suggestion for new algorithm initialization rules based on that. Once there is such a proposal that looks sensible, the rest of us can test implement it to see how it works with the libraries in our test suites.
The concrete proposal is that only "initial algorithm" is changed, so when the proposed text says "initial algorithm" it only means "initial algorithm". The alternative would have been any algorithm executed during initialization, and as indicated that would cause problems, while only providing a benefit for models that still wouldn't work - so no need to test-implement that. The change for "initial algorithm" doesn't impact algorithms with "when", and it still keeps "initial equation" and start-attributes in sync - it also seems to be implemented in OpenModelica and Dymola. |
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.
As far as I understand (but I guess we'll need some testing) I agree with @HansOlsson's current proposal in this PR, i.e., replacing
A discrete-time variable \lstinline!v! is initialized with \lstinline!pre(v)!.
with
A discrete-time variable \lstinline!v! in a non-initial algorithm is initialized with \lstinline!pre(v)!.
which leaves open the option of using an explicit initial algorithm to initialize it. However, with this modification it is not clear to me how discrete-time variables would be initialized in initial algorithms, i.e., what value they get before the algorithm starts. I guess it should be the start attribute, and maybe this is already clear because of some other rule regarding algorithms. Maybe we should say it explicitly anyway?
See line 41. |
Closes #3472