This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Entities in a SimEvents Model

Entities are discrete items of interest in a discrete-event simulation. By definition, these items are called entities in SimEvents® software. Entities can pass through a network of queues, servers, gates, and switches during a simulation. Entities can carry data, known in SimEvents software as attributes.

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.

Note

Entities are not the same as events. Events are instantaneous discrete incidents that change a state variable, an output, and/or the occurrence of other events. See Role of Events in a SimEvents Model for details.

Meaning of Entities in Different Applications

You determine what an entity signifies, based on what you are modeling. The table lists example entity representations in various applications.

Context of Sample ApplicationEntities
Airport with a queue for runway accessAirplanes waiting for access to runway
Communication networkPackets, frames, or messages to transmit
Bank of elevatorsPeople traveling in elevators
Conveyor belt for assembling partsParts to assemble
Computer operating systemComputational tasks or jobs

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 and another attribute to represent a property.

Note

SimEvents entities are fundamentally the same as Stateflow® messages.

Visualize Entities

Entities do not appear explicitly in the model window. A graphical block can represent a component that processes entities, but entities themselves do not have a graphical representation. However, you can gather information about entities using Simulink® scopes. You cannot branch an entity connection line. If your application requires an entity to arrive at multiple blocks, use Entity Replicator block to create copies of entities.

Data and Role of Entity Attributes

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.

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 in a SimEvents Model

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

Create Time-Based Entities

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