Role of Events in a SimEvents Model

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. Events can correspond to changes in the state of an entity.

Overview of Events

Specify event actions based on entity status. A typical event sequence in a SimEvents® model is:

  1. The generation of an entity.

  2. The advancement of an entity from an Entity Generator block to an Entity Server block.

  3. The completion of service on an entity in a server.

  4. The exit of an entity from one Entity Server block to an Entity Terminator block.

  5. The destruction of an entity.

Viewing Events

Events do not have a graphical representation. However, you can associate actions with events. The SimEvents software maintains an event calendar to schedule events. For more information about observing the event calendar, see Debug SimEvents Models. You can also interact with the event calendar using simevents.SimulationObserver methods. You can create a custom event observer using this class and its methods. For more information, see Use SimulationObserver Class to Monitor a SimEvents Model.

Actions for Events

SimEvents lets you create custom actions to happen when an event occurs for an entity. Every event can have a corresponding action. You can write actions for many events using MATLAB® code or Simulink Functions. For more information, see Events and Event Actions.

Event Actions Assistant for Events

SimEvents lets you select from a list of statistical distributions that generate template code for simulating stochastic event actions. Also, you can automatically generate MATLAB code that allows for simulating repeated sequences of event actions.

  1. Open a new model and add the Entity server block from the SimEvents library.

  2. In the block dialog box, from the Insert pattern list, select Repeating sequence or Random number if you want to insert event action code from a template.

    • Repeating sequence allows you to:

      • Fix the sequence by settingSequence value

      • Select a Output after the final value of the sequence toRepeat, Set to zero, or Set to infinity

      • Select a variable to Assign output to

    • Random number allows you to:

      • Provide an initial value to the random generator engine by setting the Seed

      • Select Distribution to select from a list of statistical distributions

      • Select a variable to Assign output to

  3. Code is automatically generated in the block dialog box

See Also

| | | | | | |

Related Topics