Rate Triggered Event

Rate triggered event is used to model a stream of independent events (Poisson stream). It is frequently needed to model independent arrivals: e.g. customer arrivals in queueing systems, transaction arrivals in server-based network models, etc.

Such an event is executed periodically with time intervals distributed exponentially with the parameter rate, i.e. if the rate is 5, the event will occur on average 5 times per time unit.

The figure below illustrates a rate triggered event modeling customer arriavals. The inter-arrival time of this event is distributed exponentially with mean 1/1.5 = 0.67:


 To add a rate triggered event
  1. Drag the Event  element from the  Agent palette onto the diagram of agent.
  2. Once the event is created, you can specify its name in the text line editor opened on the right of the element in the graphical editor. When finished, press Enter and go to the Properties view.  
  3. Choose Rate from the Trigger type drop-down list.
  4. Specify the rate in the Rate edit box below.
  5. Specify the event’s action in the Action property. There you can write Java code to be executed on the event occurrence. Probably it would be more convenient to define this code as a function or as an action chart and just place the function call here.

Properties

General properties

Name – The name of the event. The name is used to identify and access the event.

Show name – If selected, the name of the event is displayed on a presentation diagram.

Ignore – If selected, the event is excluded from the model.

Visible - If selected, the event is visible on a presentation at runtime.

Trigger type – The event's trigger type:

Timeout – The event is timeout triggered. The event occurs according to the chosen Mode.

Rate – The event is rate triggered. The event occurs with the specified Rate.

Condition – The event is condition triggered. The event occurs when the specified boolean Condition becomes true.

Mode – [Visible if Trigger type is Timeout] Choose here the mode of the timeout triggered event:

User control – The event will work in manual mode. It will occur only when the user calls the event’s restart function passing the timeout as the argument, for instance myEvent.restart(15).
 If the timeout is fixed, you can define it once in the Timeout property and simply call myEvent.restart() without specifying the timeout as a function parameter.

Occurs once – The event will occur only once exactly in the specified  (absolute) or Occurence date. You can define the occurrence time as a calendar date (choose Use calendar dates) or as a number of model time units to be passed from the model start (choose Use model time).
Please note that here you define the absolute time and in the case the event will be created after the specified time, it will never occur.

Cyclic – The event will occur cyclically. You define the First occurrence time (absolute) or Occurrence date and the Recurrence time for an event. The first occurrence time can be defined either as a calendar date (choose Use calendar dates), or as a number of model time units to be passed from the model start (choose Use model time).
Please note that you define absolute times. If you want to use relative times (i.e. count the first occurrence time from the moment this event will be created), use time() function in the First occurrence time (absolute) property. time() will refer to the moment this event was created at..

Timeout – [Visible if Trigger type is Timeout and Mode is User control] The expression evaluating the timeout that should pass from the moment when the user starts the event by calling its restart() function.

Use model time - [Visible if Trigger type is Timeout and Mode is Occurs once or Cyclic] If selected, the event will occur at the specified model time. 

Use calendar dates - [Visible if Trigger type is Timeout and Mode is Occurs once or Cyclic] If selected, the event will occur at the specified calendar date.

Occurrence time (absolute) – [Visible if Trigger type is Timeout, Mode is Occurs once and Use model time is selected] The absolute time of event occurrence defined as a number of model time units to be passed from the model start.

Occurence date - [Visible if Trigger type is Timeout, Mode is Occurs once or Cyclic and Use calendar dates is selected] The calendar date and time of the event.

First occurrence time (absolute) – [Visible if Trigger type is Timeout, Mode is Cyclic and Use model time is selected] The absolute time of the first occurrence of the cyclic event, defined as a number of model time units to be passed from the model start.

Recurrence time – [Visible if Trigger type is Timeout and Mode is Cyclic] The recurrence time of the cyclic event.

Rate – [Visible if Trigger type is Rate] The rate triggering the event. Event will occur with the timeout distributed exponentially with the parameter rate. I.e. if the rate is 5, event will occur on average 5 times per time unit.

Condition – [Visible if Trigger type is Condition] The condition triggering the event. Event will occur when the specified Boolean expression is true. 

Log to database – If selected, information on all event occurrences will be logged into the model execution log events_log

Action

Java code to be executed on event occurrence.

Changing the event's rate at runtime

The event's rate can change dynamically at the model runtime, e.g. as a result of changing value of the parameter specified as the Rate. If the rate changes (and new rate is not equal to the actual one), the event occurrence gets re-scheduled, i.e. the currently scheduled event is canceled and the next occurrence is scheduled according to the new Rate.

Such changes may only be noticed when something changes in the agent:

 Actually, a rate is a form of updatable exponential timeout and thus a rate triggered event is equivalent to a cyclic timeout triggered event with recurrence time 1/rate. However, there is one essential difference: timeout for the timeout triggered event is calculated only once at the event startup, and cannot be changed later on. 

Controlling events manually

You can control the rate triggered event programmatically via its API

boolean isActive() - Returns true, if the event is currently scheduled, false otherwise. 

void reset() - Cancels the currently scheduled event, if any. The cyclic execution would not resume until restart() is called. 

void restart() - Cancels the currently scheduled event, if any, and schedules the next occurrence according to the Rate

void onChange() - Should be called when something changes in the object (and probably the rate changes). Re-schedules the event with re-calculated rate. 

double getRest() - Returns the time remaining before the scheduled occurrence of the event, in model time units.
If the event is not scheduled, the function returns infinity.

double getRest(TimeUnits units) - Returns the time remaining before the scheduled occurrence of the event, in given time units
If the event is not scheduled, the function returns infinity.
Parameter: units - time unit constant

Example: event.getRest(MINUTE) will return the remaining time in minutes.


Related topics

 Event

 Timeout triggered event

 Condition triggered event

 Dynamic event

API reference: EventRate class