Entity Generator

Generate Entities

  • Library:
  • SimEvents

Description

The Entity Generator block generates entities. Entities are discrete items of interest that you can define in a discrete-event simulation. An entity can carry scalar, bus, or vector data. The meaning of an entity depends on the model. Entity can represent customers in a queuing system, data packets from a remote controller to an actuator, or any discrete item you define.

By default the block entity generation method is Time-based. In this method, the block generates entities using intergeneration times specified by the Period, from an input signal or statistical distribution. See Entities in a SimEvents Model, for more information about creating time-based and randomized entities.

The block also creates event-based entities. Choose Event-based as the Generation Method for an external event to specify the entity intergeneration time. For an example, see Generate Entities When Events Occur.

To customize actions when the entity is generated or it exits the block, in the Event actions tab, in the Generate action, or Exit action field, enter MATLAB® code. For more information, see Events and Event Actions.

Ports

Input

expand all

Dependencies

To enable this port, click the Entity generation tab and select Event-based for the Generation method.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | enumerated | bus

Dependencies

To enable this port, click the Entity generation tab and select Time-based for the Generation method and Signal port for the Time source.

Data Types: double

Output

expand all

Output port for the generated entities departing the generator.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | enumerated | bus

Number of entities that have departed the block.

Dependencies

To enable this port, click the Statistics tab and select the box labeled Number of entities departed, d.

Data Types: double

Outputs 1 for a pending entity, and 0 otherwise.

Dependencies

To enable this port, select the Statistics > Pending entity in block, pe.

Data Types: double

Outputs the average time between generation of entities.

Dependencies

To enable this port, select the Statistics > Average intergeneration time, w.

Data Types: double

Parameters

expand all

Choose the entity generation method. Choose Time-based to generate entities using intergeneration times from an input signal or statistical distribution. Choose Event-based for an external event to determine the entity intergeneration time.

Programmatic Use

Block Parameter: GenerationMethod
Type: character vector
Values: 'Time-based' | 'Event-based'
Default: 'Time-based'

Specify the source for entity intergeneration time.

  • Select Dialog to specify a fixed period between entity generations.

  • Select Signal port to generate entities based on an input signal.

  • Select MATLAB action to define a MATLAB Script that defines the intergeneration time represented by dt.

For more information about specifying intergeneration times for entities, see Specify Intergeneration Times for Entities.

Dependencies

This parameter is visible when the Generation method is set to Time-based.

Programmatic Use

Block Parameter: TimeSource
Type: character vector
Values: 'Dialog' | 'Signal port' | 'MATLAB action'
Default: 'Dialog'

Specify the time between entity intergeneration. For instance, if the Period is 1, the block waits 1 simulation time in between entity generations. See, Specify Intergeneration Times for Entities for more information.

Tunable: Yes

Dependencies

This parameter is visible when Generation method is set to Time-based.

Programmatic Use

Block Parameter: Period
Type: character vector
Values: '1' | scalar
Default: '1'

Use MATLAB code to specify service time. dt specifies the time between entity generations. You can manually specify dt or use Insert pattern button to generate entities with a repeating sequence or from a distribution. The block uses this parameter every time it is ready for entity generation. For an example, see Specify Intergeneration Times for Entities.

Dependencies

This parameter is visible when Service time source is set to MATLAB action.

Programmatic Use

Block Parameter: IntergenerationTimeAction
Type: character vector
Values: MATLAB code
Default: 'dt = rand(1,1);'

Generates entity at the start of the simulation.

Programmatic Use

Block Parameter: GenerateEntityAtSimulationStart
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Choose the type of entity to generate.

  • The Anonymous type has one data value associated with it.

  • The Structured type (default) includes name and initial value attributes that you can specify.

    • You can attach more than one attribute to an entity by clicking .

    • You can delete attributes by clicking .

    • You can change the order of the attributes by clicking and .

    • You can convert a Structured type entity to a bus object by clicking

  • The Bus object type lets you generate bus objects as entities.

    Click Launch Bus Editor to open bus editor and to generate bus objects. A bus object can be an element of another bus object which can be used to create hierarchy in the data that is attached to an entity.

For more information, see Entities in a SimEvents Model.

Programmatic Use

Block Parameter: EntityType
Type: character vector
Values: 'Structured' | 'Anonymous' | 'Bus object'
Default: 'Structured'

Determines the priority of the generated entity. The lower the value the higher the priority For more information, see Entity Priorities.

Programmatic Use

Block Parameter: EntityPriority
Type: character vector
Values: '300' | scalar
Default: '300'

Determines the name of the generated entity.

Dependencies

This parameter is visible when Entity type is set to Bus object or Structured.

Programmatic Use

Block Parameter: EntityTypeName
Type: character vector
Values: 'Entity' | character vector
Default: 'Entity'

Set the anonymous entity data initial value. This value cannot be of type int64.

Dependencies

This parameter is visible when you set Entity type to Anonymous.

Programmatic Use

Block Parameter: DataInitialValue
Type: character vector
Values: '0' | scalar | vector | matrix
Default: '0'

Define entity attribute name.

Note

When done, you can export the structured entity type as a bus object, with the name Entity type name, to the base workspace. Export the bus object when using the MATLAB Discrete-Event System and Discrete Event Chart blocks.

Dependencies

This parameter is visible when Entity type is set to Structured.

Programmatic Use

Block Parameter: AttributeName
Type: character vector
Values: 'Attribute1' | character vector
Default: 'Attribute1'

Specify the entity attribute initial value. This parameter is visible when Entity type is set to Structured.

Programmatic Use

Block Parameter: AttributeInitialValue
Type: character vector
Values: 1 | scalar
Default: '1'

Define the behavior in the Event action parameter. The Generate action is called when an entity is generated and the Exit action is called just before an entity exits the block.

Programmatic Use

Block Parameter: GenerateAction, ExitAction
Type: character vector
Values: MATLAB code
Default: ''

Number of entities that have departed the block.

Programmatic Use

Block Parameter: NumberEntitiesDeparted
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Indicates whether an entity that is yet to depart is present in the block. The value is 1 for a pending entity, and 0 otherwise. This block can have at most one pending entity.

Programmatic Use

Block Parameter: PendingEntityInBlock
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Outputs the average time between generation of entities. Average intergeneration time, w is the ratio of the total generation time to the total number of generated entities.

Programmatic Use

Block Parameter: AverageIntergenerationTime
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Introduced in R2016a