Skip to content

Clarify events in algorithms, and add examples.#3837

Open
HansOlsson wants to merge 4 commits intomodelica:masterfrom
HansOlsson:AlgEvent
Open

Clarify events in algorithms, and add examples.#3837
HansOlsson wants to merge 4 commits intomodelica:masterfrom
HansOlsson:AlgEvent

Conversation

@HansOlsson
Copy link
Collaborator

No description provided.

@HansOlsson HansOlsson added the clarification Specification of feature is unclear, but not incorrect label Feb 19, 2026
@HansOlsson HansOlsson requested a review from casella February 19, 2026 13:50
@HansOlsson HansOlsson linked an issue Feb 19, 2026 that may be closed by this pull request
Comment on lines +638 to +651
\begin{lstlisting}[language=modelica]
model AlgorithmEvent2
Real x[n](start = 2:4);
parameter Integer n = 3 annotation(Evaluate=true);
Boolean b[n];
equation
der(x) = -2*x;
algorithm
for i in 1:n loop
b[i] := x[i] > 1;
end for;
end AlgorithmEvent2;
\end{lstlisting}
Here we get one crossing function for each element of \lstinline!x!, three in total.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really make such a big point of how a for-statement works when we don't have an example with a for-equation? For me, it would make more sense to just split the example in two, and make the second one primarily about for-equations, possibly also mentioning that for-statements are similar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see reasons for making a big point about for-statements, but I wouldn't mind a for-equation example.

The reason is that traditionally for-equations were normally expanded, and adding crossing functions to expanded equations seems kind of trivial. For-statements are different (as they are not expanded), so one "line" in the source-code leads to multiple crossing functions. Both as a user and implementor I find that significant enough to have a special example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split into two example-sections, and add that for-equation text in second example-section.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
@HansOlsson HansOlsson added this to the 2026-March milestone Mar 4, 2026
@HansOlsson HansOlsson requested a review from henrikt-ma March 12, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clarification Specification of feature is unclear, but not incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State events generated inside algorithm sections

2 participants