Generate Multiple Entities at Time Zero
In a discrete-event simulation, an event is an observation of an instantaneous incident that may change a state variable, an output, and/or the occurrence of other events.
Suppose that you want to:
Preload a queue or server with entities at the start of the simulation, before you analyze queueing or processing delays.
Initialize the capacity of a shared resource before you analyze resource allocation behavior.
These scenarios require multiple entity generation at the simulation start.
In these scenarios, you can simultaneously generate multiple entities at the start of the simulation. You can then observe the behavior of only those entities for the remainder of the simulation.
Build the model
To generate multiple entities at time 0
, use MATLAB® code in the Entity Generator block.
To open the example model without performing the configuration steps, see
A
Simple Example of Generating Multiple Entities
.
In a new model, from the SimEvents® library, drag the Entity Generator, Entity Terminator, and Dashboard Scope blocks.
Double-click the Entity Generator block.
From the Time source drop-down list, select
MATLAB action
.In the Intergeneration time action field, use MATLAB code to enter the number of entities that you want to generate. For example, you could use 8. In that case, at simulation time
0
, the Entity Generator block generates 8 simultaneous events.persistent count igt; if isempty(count) igt=[0 0 0 0 0 0 0 0 inf]; count = 1; end dt = igt(count); count = count + 1;
In the Events action tab, randomize the entity attribute. Select the Generate event action and, in the Generate action field, enter the MATLAB code:
entity.Attribute1=rand();
The output of the Dashboard Scope block shows that the software
generates multiple entities at time 0
.
See Also
Entity Generator | Entity Queue | Entity Server | Entity Terminator
Related Examples
- Generate Entities When Events Occur
- Specify Intergeneration Times for Entities
- Working with Entity Attributes and Entity Priorities
- Inspect Structures of Entities
- Count Simultaneous Departures from a Server