Products & Services Solutions Academia Support User Community Company

Learn more about SimEvents   

Counting Entities

Counting Departures Across the Simulation

Use the #d or #a output signal from a block to learn how many entities have departed from (or arrived at) a particular block. The output signal also indicates when departures occurred. This method of counting is cumulative throughout the simulation. These examples use the #d output signal to count departures:

Counting Departures per Time Instant

Suppose you want to visualize entity departures from a particular block, and you want to reset (that is, restart) the counter at each time instant. Visualizing departures per time instant can help you:

Use the Instantaneous Entity Counting Scope to plot the number of entities that have arrived at each time instant. The block restarts the count from 1 when the time changes. As a result, the count is cumulative for a given time instant, but not cumulative across the entire simulation.

Example: Counting Simultaneous Departures from a Server

In this example (open model), the Infinite Server block sometimes completes service on multiple entities simultaneously. The Instantaneous Entity Counting Scope indicates how many entities departed from the server at each fixed time instant during the simulation.

Resetting a Counter Upon an Event

Suppose you want to count entities that depart from a particular block, and you want to reset the counter at arbitrary times during the simulation. Resetting the counter can help you compute statistics for evaluating your system over portions of the simulation.

The Entity Departure Counter block counts entity departures via a resettable counter. To configure the block:

  1. Decide which type of events you want to reset the counter. The choices are:

    • Sample time hits

    • Trigger edges

    • Value changes

    • Function calls

    These resources can help you choose which type of events:

  2. In the Entity Departure Counter block, indicate which signal-based events cause the counter to reset:

    • To reset upon sample time hits of an input signal, set Reset counter upon to Sample time hit from port ts.

    • To reset based on a trigger edge in an input signal, set Reset counter upon to Trigger from port tr. Then set Trigger type to Rising, Falling, or Either.

    • To reset based on a change in the value of an input signal, set Reset counter upon to Change in signal from port vc. Then set Type of change in signal value to Rising, Falling, or Either.

    • To reset upon function calls, set Reset counter upon to Function call from port fcn.

  3. If you want to specify an explicit priority for the reset event, select Resolve simultaneous signal updates according to event priority. Then enter the priority using the Event priority parameter.

  4. Click OK or Apply. The block now has a signal input port.

  5. Connect a signal to the signal input port.

During the simulation, the block counts departing entities and resets its counter whenever the input signal satisfies your specified event criteria.

Example: Resetting a Counter After a Transient Period

This example (open model) counts entity departures from a queuing system, but resets the counter after an initial transient period.

Associating Each Entity with Its Index

Use the Entity Departure Counter block with Write count to attribute set to On to associate entity counts with the entities that use a particular path. The Nth entity departing from the Entity Departure Counter block has an attribute value of N.

For an example, see Example: Setting Attributes.

For an example in which the Entity Departure Counter block is more straightforward than storing the #d output signal in an attribute, see Example: Sequence of Departures and Statistical Updates.

  


Free SimEvents Evaluation Kit

Learn how you can use SimEvents discrete-event simulation capbilities through these technical resources.

Get free kit

Trials Available

Try the latest version of discrete-event simulation products.

Get trial software
 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS