Opened 11 years ago

Last modified 4 years ago

#2152 assigned enhancement

Handle time events efficiently

Reported by: sjoelund.se Owned by: Karim.Abdelhak
Priority: blocker Milestone: 2.0.0
Component: Run-time Version: trunk
Keywords: Cc: AnHeuermann

Description (last modified by 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 Changed 11 years ago by sjoelund.se

  • Owner changed from somebody to wbraun
  • Status changed from new to assigned

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 Changed 11 years ago by sjoelund.se

  • Priority changed from high to blocker

comment:3 Changed 11 years ago by sjoelund.se

See also #2224

comment:4 Changed 11 years ago by anonymous

  • Owner changed from wbraun to lochel

comment:5 Changed 11 years ago by casella

  • Description modified (diff)
  • Summary changed from Find exact times of time events to Handle time events efficiently

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

comment:6 Changed 11 years ago by lochel

  • Milestone changed from 1.9.0 to 2.0.0

comment:7 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.3 to 1.9.4

Moved to new milestone 1.9.4

comment:8 Changed 8 years ago by lochel

  • Priority changed from blocker to critical

comment:9 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.5

Milestone pushed to 1.9.5

comment:10 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.5 to 1.10.0

Milestone renamed

comment:11 Changed 7 years ago by sjoelund.se

  • Milestone changed from 1.10.0 to 1.11.0

Ticket retargeted after milestone closed

comment:12 Changed 7 years ago by sjoelund.se

  • Milestone changed from 1.11.0 to 1.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:13 Changed 6 years ago by casella

  • Milestone changed from 1.12.0 to 1.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 Changed 6 years ago by casella

  • Cc casella bthiele 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 Changed 5 years ago by casella

  • Milestone changed from 1.13.0 to 1.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:16 Changed 5 years ago by casella

  • Milestone changed from 1.14.0 to 2.0.0
  • Priority changed from critical to blocker

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

comment:17 Changed 4 years ago by casella

  • Cc AnHeuermann added; wbraun lochel casella bthiele removed
  • Owner changed from lochel to Karim.Abdelhak

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

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