Clarify role of when-clause conditions in event iteration#3862
Open
henrikt-ma wants to merge 2 commits intomodelica:masterfrom
Open
Clarify role of when-clause conditions in event iteration#3862henrikt-ma wants to merge 2 commits intomodelica:masterfrom
henrikt-ma wants to merge 2 commits intomodelica:masterfrom
Conversation
This also fixes a problem with nested non-normative sections.
HansOlsson
reviewed
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3813.
While I do think that this should be sufficient to consider #3813 fixed, it leaves me a bit uneasy that my intuition about the event iteration is not captured in any non-normative section. That is, the intuition is that event iteration must be continued when some computed solution to the model equations becomes invalid due to some of the updates taking place after the evaluation of the model equations. The intuition is also that once none of the computed solutions become invalidated, it should in principle be a no-op to evaluate the model equations one more time, so tools should err on the side of iterating one extra time rather than one time too little.
The two things taking place after evaluation of the model equations are the
pre(v) := vupdates and the execution ofreinitstatements. Thus, a tool erring on the side of iterating one time too much could simply test whether there is any change to apre(v)or a state updated by areinit. By noting that execution of areinitimplies that there is apre(v)which will be updated from false to true, the condition may be simplified to the current rule in the specification.However, the intuition about invalidated solutions to the model equations is a more intuitive starting point for optimizing the iteration, and in my opinion also a more useful way to abstractly understand what it is that the event iteration achieves:
In view of the text proposed in this PR, it is particularly worth noting that the intuition does not suggest that a triggered
when-clause should necessarily trigger continued iteration; the usual sorting of equations is sufficient, except forreinitwhich may change a state after it has been used. Hence, the conceptual idea of introducing implicit variables for thewhen-clause conditions is neither helpful for tools that want to avoid unnecessary iterator nor for users who are trying to understand optimized tool behavior.