Opened 12 years ago

Last modified 4 years ago

#2152 assigned enhancement

Handle time events efficiently

Reported by: Martin Sjölund Owned by: Karim Adbdelhak
Priority: blocker Milestone: 2.0.0
Component: Run-time Version: trunk
Keywords: Cc: Andreas Heuermann

Description (last modified by Francesco Casella)

The relations

time >= <discrete_expr>
time < <discrete_expr>

can be handled as time events without resorting to crossing functions, thus leading to more efficient simulation code (see Modelica Specification 3.2 rev1, sect. 8.5).

We can look for expressions containing only pre(discrete), constant, or parameter expressions. Then it is always possible to calculate the next exact time of this event indicator, by replacing >= (or <) with == and solving for time.

If time is <= current time, no more events occur, otherwise schedule next time event and deal with it as with sample()

Change History (17)

comment:1 by Martin Sjölund, 12 years ago

Owner: changed from somebody to Willi Braun
Status: newassigned

Would be good to fix this as soon as possible so we can the new tables implementation. I do believe it is working, but it needs better event detection to work properly.

comment:2 by Martin Sjölund, 12 years ago

Priority: highblocker

comment:3 by Martin Sjölund, 11 years ago

See also #2224

comment:4 by anonymous, 11 years ago

Owner: changed from Willi Braun to Lennart Ochel

comment:5 by Francesco Casella, 11 years ago

Description: modified (diff)
Summary: Find exact times of time eventsHandle time events efficiently

Changed description to reflect contents more accurately
Merged text with closed duplicate #2224

comment:6 by Lennart Ochel, 11 years ago

Milestone: 1.9.02.0.0

comment:7 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:8 by Lennart Ochel, 9 years ago

Priority: blockercritical

comment:9 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:10 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:11 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:12 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:13 by Francesco Casella, 7 years ago

Milestone: 1.12.01.13.0

@lochel, do you think you can take care of this for 1.13.0? It is particularly important to handle the simulation of systems with clocked variables efficiently

comment:14 by Francesco Casella, 7 years ago

Cc: Francesco Casella Bernhard Thiele added; fcasella removed

A good test case is reported in #2226

model Test1
   discrete Real next_t;
   discrete Real next_t2;
equation
   when time >= pre(next_t) then
     next_t = pre(next_t)+1;
   end when;
   when sample(0.5, 1.0) then
     next_t2 = pre(next_t2)+1;
   end when;
initial equation
   next_t = 1;
   annotation (experiment(StopTime=10));
end Test1;

Time events are generated by the sample() operator, but in fact time events could also be generated for the when time >= pre(next_t) conditions.

This would be very useful to handle delayed transitions in state machine models efficiently.

comment:15 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:16 by Francesco Casella, 5 years ago

Milestone: 1.14.02.0.0
Priority: criticalblocker

I think this definitely needs to be addressed, but not in 1.14.0

comment:17 by Francesco Casella, 4 years ago

Cc: Andreas Heuermann added; Willi Braun Lennart Ochel Francesco Casella Bernhard Thiele removed
Owner: changed from Lennart Ochel to Karim Adbdelhak

@Karim, @AnHeuermann, please decide among yourselves who wants to take care of this

Last edited 4 years ago by Francesco Casella (previous) (diff)
Note: See TracTickets for help on using tickets.