Documentation

Role of Entities in SimEvents Models

Entities are discrete items of interest in a discrete-event simulation. You determine what an entity signifies, based on what you are modeling. For more information, see What Is an Entity?.

SimEvents® models typically contain at least one source block that generates entities. Other SimEvents blocks in the model process the entities that the source block generates.

Meaning of Entities in Different Applications

An entity represents an item of interest in a discrete-event simulation. The meaning of an entity depends on what you are modeling. In this topic, examples use entities to represent abstract customers in a queuing system and data packets from a remote controller to an actuator on the system being controlled.

Entities do not have a graphical depiction in the model window the way blocks, ports, and connection lines do.

Vary the Interpretation of Entities

A single model can use entities to represent different kinds of items. For example, if you are modeling a factory that processes two different kinds of parts, you can:

  • Use two Entity Generator blocks to create the two kinds of parts.

  • Use one Entity Generator block and subsequently assign an attribute to indicate what kind of part each entity represents.

SimEvents entities are fundamentally the same as Stateflow® messages.

Data and Entities

You can optionally attach data to entities. Such data is stored in one or more attributes of an entity. You define names and numeric values for attributes. For example, if your entities represent a message that you are transmitting across a communication network, you might assign data called length that indicates the length of each particular message. You can read or change the values of attributes during the simulation.

Data and Signals

In SimEvents models, signals carry persistent value-based information such as statistics and states.

Introduction to Time-Based Entities

By default, the Entity Generator block creates time-based entities. Change the Time Source parameter to select the time source for the entity generation. You can create time-based entities using:

  • The Period parameter value. For more information, see Create a Time-based Entity.

  • A signal port. You can then connect a Simulink® source block, such as a Repeating Sequence block, to the signal port. The time value cannot be a negative number.

  • MATLAB® code. For more information, see Create Randomized Entities.

Role of Attributes in Models

You can optionally attach data to entities. Such data is stored in one or more attributes of an entity. You define names and numeric values for attributes. For example, if entities represent a message you are transmitting across a communication network, you might also assign data called length that indicates the length of each particular message. You can read or change the values of attributes during the simulation.

You can optionally specify the structure of an entity using a Simulink bus object. This capability is useful when defining complex entity structures that need to be defined once, but used in multiple locations in a model. In addition, the MATLAB Discrete-Event System and Discrete Event Chart blocks require that you specify entities as bus objects. For more information on bus objects, see When to Use Bus Objects (Simulink).

Create Entities

There are many ways to create entities. Two common ways are using a time-based method, and using a random number generator.

Create a Time-based Entity

Use the Entity Generation block to create time-based entities. The Entity Generation lets you specify a period at which it creates entities.

  1. Open the SimEvents block library. You can use the Simulink browser or type simevents at the MATLAB Command Window.

  2. Create a new model.

  3. From the SimEvents library, drag the Entity Generator block to the new model.

  4. From the SimEvents library, drag the Entity Queue block to the new model.

    • Connect the Entity Generator block to the input of the Entity Queue.

    • In the Entity Queue block, select Number of entities departed, d.

  5. From the Simulink Sinks library, drag a Scope block to the new model. Connect the Scope block to the d port of the Entity Queue block.

  6. From the SimEvents library, drag an Entity Terminator block to the new model. Connect the output of the Entity Queue block to the input of the Entity Terminator block.

Upon simulation, the scope displays the entities that depart the queue.

Note

You cannot connect a scope to a SimEvents line, as denoted by the thick double arrow line.

Create Randomized Entities

Use the Entity Generation block to create time-based entities. The Entity Generation lets you specify a randomization operation (such as the MATLAB rand function) to create entities at random times.

  1. Open the SimEvents block library. You can use the Simulink browser or type simevents at the MATLAB Command Window.

  2. Create a new model.

  3. From the SimEvents library, drag the Entity Generator block to the new model.

    1. Double-click the block and set the Time source parameter to MATLAB action.

    2. In the Intergeneration time action parameter, enter a call to a randomizer function, such as rand. For example:

      dt = rand(1,1);

  4. From the SimEvents library, drag the Entity Queue block to the new model.

    • Connect the Entity Generator block to the input of the Entity Queue

    • In the Entity Queue block, select Number of entities departed, d.

  5. From the Simulink Sinks library, drag a Scope block to the new model. Connect the Scope block to the d port of the Entity Queue block.

  6. From the SimEvents library, drag an Entity Terminator block to the new model. Connect the output of the Entity Queue block to the input of the Entity Terminator block.

Upon simulation, the scope displays the entities that depart the queue.

See Also

| | | | | | | | | | | | | | | |

Related Examples

More About

Was this topic helpful?