-
Notifications
You must be signed in to change notification settings - Fork 43
Describe 'delay' as event-generating operator #3730
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
Conversation
|
@henrikt-ma You looking for an implementation in other tools: in SimulationX both |
gkurzbach
left a comment
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.
It is fine for me.
|
For me there are two different use cases:
I don't see a need to generalize spatialDistribution to non-Reals yet; but I see that the second case also applies for spatialDistribution. The issues with events for Reals as I see it are:
If we later refine the delay-operator's description we might revisit this. |
While I don't have a test implementation for this, I don't see that it would be more difficult than supporting it for |
If the
Yes, so it is important that a tool doesn't forget to support
It was not my intention that the text should be interpreted this way. The way I see it, the key change here is that |
Since both you and @HansOlsson bring up the non- |
My experience with handling spatialDistribution is that it is already quite complicated to get a good result; and since I see no real use case of non-Real spatialDistribution I think that will be an excessive burden for something for no real gain. |
|
I just realized that |
For me there are some issues:
Since it is a trivial to write cases where generating events for discrete variables will cause an infinite explosion in smaller and smaller discontinuities, I think we should be careful and not add something "just in case".
I can understand that delay of a non-Real needs to be a discrete-time expression (even if the delayTime is continuous-time) to not generate non-discrete-time Integer (etc), but I don't see a similar need for Reals. |
HansOlsson
left a comment
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 indicated should not require an event for Reals, and support non-Real.
Could change to "next significant discontinuous change" and saying that changes for non-Reals are always significant.
I would say all of them should be automatically vectorized, and see also: #3728 |
|
How about expressing the value simply as |
This is not a good reason to not let
But this is not the way it will work for non- |
Interesting question - it's more complicated, at least Dymola seem to x.start for delay(x, 1) - and not the value of x at the start-time. I think that should be discussed separately. |
I am just extrapolating from what I learnt when working on |
OK. System Modeler is also making the (a little bit stretched) interpretation that Edit: Reported this as #3733. |
Discrete-time Integer and discrete-time Real variables are quite different, and thus many Real expression that only change at events are not formally discrete-time. Additionally, I thought we wanted Added So a Real expression are often sort of discrete-time without being formally discrete-time; that's not the case for Integer expressions. |
Yes, absolutely! The variability of
I know this is the case, but to me there is only one natural way of defining the variability semantics of |
To me the important part for Real expressions is that discontinuities are propagated (with an event that cannot be observed internally), not that the call is discrete. |
Oh, so you mean that we should state more clearly that discontinuities should be preserved in the non-discrete-time case? Clarifying that wouldn't sound like a bad idea to me. |
Also OMC reproduces events that were present at the input of
To me this was the primary motivation to add events to |
casella
left a comment
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.
LGTM
|
The remaining issue (apart from merge conflict) is the variability of delay for a parameter expression, in particular
Status (for
Checking in Dymola 2026x I notice that we don't make it parameter-variability and no-one has noticed, so I don't think delaying parameters is used in any widely distributed libraries. |
|
The column for 👀 does not capture the intention of at least discrete-time. When I wrote that, I would still have expected
|
|
Language group: Seems preference for delay only variability-depending on first argument. |
|
Here are some simple tests for this. (Updated.) |
Co-authored-by: Hans Olsson <HansOlsson@users.noreply.github.com>
There are several violations due to not providing The should all be changed to something like this: Apart from that, the example simulates fine in System Modeler. |
Now updated. |
HansOlsson
left a comment
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 now.
|
The conflicts must, however, be resolved. |
Done. |
In #3640 it was noted that both
delayandspatialDistributionshould be event-generating, so that they can preserve discontinuities. This is particularly useful for dealing with discrete-valued signals, and opens up for also supporting non-Realsignals.We have now a test implementation of event-generating
delay, and I'd say it works great. At the moment, describingdelayaccordingly is the only thing this PR does. For the much less frequently usedspatialDistributionwe don't have a test implementation at the moment, but would be ready to also go ahead and change the specification based on test implementations in other tools.Some questions to think about when making this change:
delay(1.0, delayTime, delayMax)a constant expression.spatialDistributionif we were to add event generating semantics?