Documentation Center

  • 評価版
  • 製品アップデート

Count Entities

Count Departures Across the Simulation

Use the #d or #a output signal from a block to learn how many entities have departed (or arrived at) the 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:

Count 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:

  • Detect simultaneous departures

  • Compare the number of simultaneous departures at different time instants

  • Visualize the departure times while keeping the plot axis manageable

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.

Count Simultaneous Departures from a Server

In this example (open modelmodel), 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.

Reset 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 an event-based 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.

Reset a Counter After a Transient Period

This example (open modelmodel) counts entity departures from a queuing system, but uses a step block to reset the counter after an initial transient period.

Associate Each Entity with Its Index

Use the Entity Departure Counter block with Write count to attribute check box selected 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 Set Attributes.

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

Was this topic helpful?