Is your feature request related to a problem? Please describe.
Currently in Uppaal Stratego, derivatives of clock values are not observable in simulate queries (and possible other queries as well). If you try to use a clock derivatie in the simulate query, you get the error "Integer or clock expected" (which is, btw, an incorrect statement, see #48).
Consider a model with clock variable x
and a location invariant describing its derivative as x' = some_function()
where some_function()
is a user-defined function. In validating the model, the simulate query can be used to observe the behavior of x
. But in case the behavior is counter-intuitive, further investigation can benefit from also displaying the values from x'
or `some_function()' directly.
Describe the solution you'd like
Clock derivatives should be allowed in the syntax of (some specific) queries.
Describe alternatives you've considered
A workaround is to explicitly create a reporting mechanism. For example:
Declare in the same template as x
a double der = 0.0
, const double P = 1.0
, and clock p
, where der
is the variable storing the value of the derivative, P
is the reporting interval (which of course can have different values, but a user should keep the option value for 'Discretization step for hybrid systems' in mind), and p
the clock keeping track of the reporting intervals.
Add to the location with the derivative of x
an uncontrollable selfloop labeld with guard p == P
and update der = some_function(), p = 0
. Also add to the same location the invariant p <= P
.
Now the variable der
can be used in the simulate query to obtain the value of x'
once every period P
.
In some rare cases, the reported value can be different from the actual value of x'
. Consider the case that once p==P
holds, also somewhere else in the model a transition is enabled and the effect of that transition changes the value of some_function()
. Now the order of dealing with stuff in the simulation might be that we first do the reporting selfloop, then the other transition, and then the calculation of x'
. In this case, 'der != x'`.