The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Reference
Revision History
March 2007Online onlyRevised for Version 2.0 ( Release 2007a). Previously part
of SimEvents
®
User’s Guide.
September 2007 Online onlyRevised for Version 2.1 (Release 2007b)
March 2008Online onlyRevised for Version 2.2 (Release 2008a)
October 2008Online onlyRevised for Version 2.3 (Release 2008b)
March 2009Online onlyRevised for Version 2.4 (Release 2009a)
September 2009 Online onlyRevised for Version 3.0 (Release 2009b)
March 2010Online onlyRevised for Version 3.1 (Release 2010a)
Function Reference
1
Library and Models ................................1-2
Contents
Simulation Settings
Debugger
Debugger Session
Simulation Control
State Inspection
Breakpoints
Debugger Information
SimEvents Pane Overview
Execution order
Seed for event randomization
...................................5-5
..........................5-4
........................5-6
Maximum events per block ..........................5-7
Maximum events per model
.........................5-8
SimEvents Diagnostics Pane
Diagnostics Pane Overview
Attribute output de layed relative to entities
Response to function call delayed relative to entities
Statistical output delayed relative to entities
Modification of attribute values used for decision
making
Identical seeds for random number generators
........................................ 5-17
........................5-9
......................... 5-10
............ 5-11
..... 5-13
........... 5-15
.......... 5-19
Glossary
Index
vii
viiiContents
Function Reference
Library and Models (p. 1-2)Open the library and example
models
Simulation Settings (p. 1-3)Configure models for discrete-event
simulation
1
Debugger (p. 1-4)
Seed Management (p. 1-7)Manage seeds of random n umber
Run and examine simulations in
debug mode
generators
1 Function Reference
Library and Models
simeventsdocex
simeventslib
Open SimEvents
example model
Open SimEvents library
®
documentation
1-2
Simulation Settings
simeventsconfigAssign model settings for
Simulation Settings
discrete-event simulation
simeventsstartup
Set default model settings for
discrete-event simulation
1-3
1 Function Reference
Debugger
Debugger Session (p. 1-4)Start and stop the debugger
Simulation Control (p. 1-4)Stop, suspend or resume the
simulation
State Inspection (p. 1-5)Query the model for information
about the simulation
Breakpoints (p. 1-5)Create and manage breakpoints in
the debugger
Debugger Information (p. 1-6)Start a n d configure the debugger
Debugger Session
sedb.quit
sedebugDebug discrete-event simulation
dbopts
se_get
Simul
sedb.
sedb
sed
ation Control
cont
.runtoend
b.step
Quit discrete-event simulation
debugging session
SimEvents debugger options
structure
Continue simulation until next
breakpoint
Run until end of discrete-event
simulation
Single step in discrete-e ven t
simulation
1-4
State Inspection
sedb.blkinfoBlock information in discrete-event
simulation
Debugger
sedb.blklist
sedb.currentop
sedb.eninfoEntity information in discrete-event
sedb.evcal
sedb.evinfoEvent information in discrete-event
sedb.gceb
sedb.gcebid
sedb.gcen
sedb.gcev
sedb.simtime
Blocks and their identifiers in
discrete-event simulation
Current operation in discrete-event
simulation
simulation
Event calendar of discrete-event
simulation
simulation
Name of currently executing block in
discrete-event simulation
Identifier of currently executing
block in discrete-event simulation
Identifier of entity currently
undergoing operation
Identifier of current event
Current time in discrete-event
simulation
Breakpoints
sedb.bdeleteDelete breakpoints in discrete-event
simulation
edb.blkbreak
s
sedb.breakpointsList breakpoints in discrete-event
Set breakpoint for discrete-event
simulation block
simulation
1-5
1 Function Reference
sedb.disableDisable breakpoints in discrete-event
simulation
sedb.enableEnable breakpoints in discrete-event
simulation
sedb.evbreak
sedb.tbreak
Debugger Information
help
sedb.detail
Setbreakpointforexecutionor
cancelation of event
Set timed breakpoint in
discrete-event simulation
Help for debugger functions
Customize debugger simulation log
in discrete-event simulation
1-6
Seed Management
Seed Management
se_getseeds
se_randomizeseedsRandomize seeds to make them
se_setseeds
Seed values of random number
generators in blocks
unique
Set seed values for blocks with
random number generators
1-7
1 Function Reference
1-8
Alphabetical List
2
help
PurposeHelp for debugger functions
Syntaxhelp
help sedb
help functionname
Descriptionhelp, at the SimEvents debugger command prompt, displays a
summary of debugger commands in the Command Window.
help sedb also displays a summary of debugger commands. This
syntax is valid at either the SimEvents debugger command prompt or
the MATLAB
help functionname displays a brief description and the syntax for
functionname in the Command Window.
How To• “Starting the SimEvents Debugger”
• “Overview of the SimEve n ts Debugger”
®
command prompt.
2-2
se_getdbopts
PurposeSimEvents debugger options structure
Syntaxopts_struct = se_getdbopts
Descriptionopts_struct = se_getdbopts returns an empty options structure that
you can configure and then use as an input to the
You can set the
StartFcn field of opts_str uct to a cell array of strings
representing commands that the debugger executes after the debugger
session begins.
ExamplesSet breakpoints upon starting the debugger:
1 At the MATLAB command prompt, create an options structure to
4 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Alsosedebug
How To• “Debugger Efficiency Tips”
2-4
se_getseeds
PurposeSeed values of random number generators in blocks
Syntaxseedstruct = se_getseeds(sysid)
Descriptionseedstruct = se_getseeds(sysid) returns the names and seed
values of all SimEvents blocks that you previously config ured to use
random num ber generators.
specifying a system name, subsystem path name, or block path name.
Before invoking this function, load or open the system.
sysid indicates the scope of the search by
Output
Arguments
seedstruct
Structure with these fields:
•
system —Valueofthesysid input to se_getseeds
• seeds — Structure array, of which each element has these
fields:
- block — Path name of a block that uses a random number
generator, relative to
system
- value — Numeric seed value of the block
See Alsose_setseeds | se_randomizeseeds
Tutorials• Se ed Management Workflow for Random Number Generators
How To• “Making Results Repeatable by Storing Sets of Seeds”
Descriptionse_randomizeseeds(obj) or se_randomizeseeds(obj, 'Mode','All')
assignstheseedsofallSimEventsblocksthatuserandomnumber
generators within blocks indicated by
are unique. The input
block path name, or ce ll array of such names . If
or subsystem, the function assigns seeds in subsystems of
depth. Before invoking this function, load or open the system where
you want to assign seeds.
se_randomizeseeds(obj,'Mode','Identical',) changes only those
seeds in the system or subsystem
obj is a system name, subsystem path name,
obj, making sure that the seeds
obj represents a system
obj at any
obj that appear multiple times in obj.
se_randomizeseeds(obj,'Mode','SpecifySeeds',sv) changes only
those s eeds whose current value appears in the vector
se_randomizeseeds(...,'GlobalSeed',seed) specifies a global seed
that the function uses to generate seed values in a repeatable way.
is a nonnegative integer. When you use this syntax, it is repeatable for
agiven
in
guarantee uniqueness of generated se ed values.
se_randomizeseeds(...,'Verbose',verbosity),ifverbosity is
'on', explicitly reports the status of each seed change.
seed value, assuming the underlying systems or blocks specified
obj do not change. To ensure repeatability, this syntax does not
See Alsose_getseeds | se_setseeds
Tutorials• Avoiding Identical Seeds for Random Number Generators
• Seed Management Workflow for Random Number Generators
2-6
sv.
seed
se_randomizeseeds
• “Example: Varying the Number of Servers Using MATLAB Code”
How To• “Varying Parameters Between Simulation Runs Using MATLAB
Code”
2-7
se_setseeds
PurposeSet see d values for blocks with random number generators
Deleted b2 : Breakpoint for f irst operation at or after time 1.000000
Disabled b3 : Breakpoint for firs t operation at or after time 1.500000
Disabled b1 : Breakpoint for firs t operation at or after time 0.500000
Enabled b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
IDTypeValueEnabled
b1Timed0.5no
b3Timed1.5yes
4 Run the simulation until the first enabled breakpoint:
cont
The partial output shows that b3 is the breakpoint at which the
debugger stops. The debugger ignores the disabled breakpoint,
and doe s not consider the previously deleted breakpoint,
Hit b3 : Breakpoint for first operation at or after time 1.500000
4 Examine the source of the new value, 1. In the R eceive r subsystem,
the blocks and signal connections indicate that the p signal arises
from a computation in the Discrete Event Subsystem block. The
computationinvolvesanattributeofanentity. TheGetAttribute
block dialog box indicates that the name of the attribute is
crc_check. To determine which entity has the attribute in this
particular computation, use the output from the preceding step. An
entity with identifier
Inspect the attributes of this entity, as follows:
en2 departed from the Get Attribute blo ck.
eninfo en2
The output shows a crc_c heck value of 0. According to the main
description of the model, a CRC value of
Entity (en2) Current StateT = 1.100000000000000
Location: Receiver/Zero Delay
Attributes:
NameValue
crc_check 0
seqNum1
Timeouts, Timers: None
0 indicates an e rror.
2-15
sedb.blkbreak
5 Proceed in the simulation to the next operation of the switch b lock:
cont
The switch block is about to respond to the new value of the p input
signal by scheduling a p ort selection event:
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
6 Proceed further in the simulation to the next operation:
cont
2-16
The output shows that the switch block is about to execute the port
selection event. Exe cu ti n g that event causes the switch to se le ct
the entity output port corresponding to the new value of the p input
signal.
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
9 Disable the breakpoint for the Output Switch block by referencing
0, indicating an error:
its breakpoint identifier:
disable b1
2-17
sedb.blkbreak
Disabling a block breakpoint, when you are done investigating the
block, helps you focus on operations that are relevant to you. The
output confirms the disabling of the block breakpoint:
Disabled b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
10 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Alsosedb.bdelete | sedb.blklist | sedb.breakpoints | sedb.cont
How To•“DefiningaBreakpoint”
2-18
sedb.blkinfo
PurposeBlock information in discrete-event simulation
Syntaxblkinfo(blkid)
blkinfo(blkname)
blk_struct = blkinfo(...)
Descriptionblkinfo(blkid) displays informati on about the SimEvents block with
identifier
sedb.blklist.
blkinfo(blkname) displays information about the SimEvents block
with path name
blk_struct = blkinfo(...) returns a structure that stores
information about the block.
The following blocks are exceptions that do not provide information:
• Conn
• Discrete Event Inport
blkid. To obtain a list of blocks and their identifiers, use
blkname.
Output
Arguments
• Discrete Event Outport
• Event-Based Random Number
• Event-Based Sequence
• Initial Value
• Subsystem Configuration
blk_struct
Structure that stores information about the block. The following
table describes the
each field appears.
blk_struct fields and the blocks for which
2-19
sedb.blkinfo
FieldBlock
Time
Block
BlockID
BlockType
Capacity
All blocksCurrent simulation time
All blocksPath name of the block
All blocksBlock identifier
All blocksType of block
All queue and s erver
blocks
SelectedInputPort
SelectedOutputPort
GateStatus
InputEntity
CurrentReplica
Status
Input SwitchIndex of selected entity input port
Output SwitchIndex of selected entity output port
Enabled Gate
Replicate
Replicate
Replicate, Entity
Combiner, and
Entity Splitter
Description
Number of entities that the block can
store at any one time
'open' or 'closed'
Identifier of the entity that the block is
replicating
Identifier of the copy of the input
entity that the block created and that
is about to advance
Status of block.
Values for Replicate Block:
•
'Inactive'
2-20
• 'Replicating X/Y'. X is the index
of the entity output port through
which the replica will depart.
Y
is the Number of entity output
ports parameter of the block
Values for Entity Combine r B loc k:
•
'Inactive'
• 'Combining'
Values for Entity Splitter Block:
•
'Inactive'
sedb.blkinfo
FieldBlock
MemoryValue
Count
Entities
Signal LatchValue of the internal memory of the
Entity Departure
Counter
All blocks that
possess an entity
input port
Description
• 'Splitting'
block
Number of entities th at have departed
from this block and arrived at
subsequent storage b locks, since the
simulation start or the last reset,
whichever occurred later.
Structure array, of which each element
has these fields:
•
ID — Entity identifier
Status (queue and server blocks
•
only) — Status of the en tit y with
respect to the block.
Entity Status Values in Queue
Blocks:
- 'Advancing'
- 'Queuing'
- 'Queued'
- 'Timed Out'
Entity Status Values in Server
Blocks:
- 'Advancing'
- 'In Service'
- 'Service Completed'
- 'Preempted'
- 'Timed Out'
2-21
sedb.blkinfo
FieldBlock
ExamplesView information about a block:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_start_timer_read_timer')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 2.51
cont
Description
• Event (server blocks only) —
Identifier of the service completion
event for the entity
•
EventTime (server blocks only) —
Time of the service completion event
for the entity
•
TimeInQueue (queue blocks only) —
Length of time the entity has been
in the queue
2-22
The partial output indicates that the server is about to execute a
service completion event:
Hit b1 : Breakpoint for first operation at or after time 2.510000
5 Use the identifier, blkid, to get information about the block and
the status of entities in it:
% Display information in Command Win dow.
blkinfo(blkid)
% Store information in str uct ure.
blkdetails = blkinfo(blkid)
% Store status of entities in cell array.
blkentities = {blkdetails.Entities.Status}'
The output is:
2-23
sedb.blkinfo
Infinite Server Current StateT = 2.581301297500028
3 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Alsosedb.blkbreak | sedb.tbreak | sedb.evbreak
How To•“DefiningaBreakpoint”
• “Using Breakpoints During Debugging”
sedb.cont
2-33
sedb.currentop
PurposeCurrent operation in discrete-event simulation
Syntaxcurrentop
Descriptioncurrentop displays the most recent message in the simulation log.
If this message represents a depe nde nt operation, the output also
includes a message about the most recent independent operation in
the simulation log.
DefinitionsIndependent Opera tion
An independent operation is one of these operations:
• Initialization of the mode l or any Time-Bas ed Entity Generator blocks
in the model. For more information, see “Initialization Messages”.
• Execution of an event on the event calendar. How ev er, if the
application executes an event without scheduling it on the event
calendar, the event cannot be the basis of an independent operation.
To learn which events are on the event calendar, see “Role of the
Event Calendar”.
• Detection by a reactive port or a monitoring port o f a relevant update
in a time-based i n put sign al. You can think of these relevant updates
as zero crossings or level crossings. However, if the input signal is an
event-based signal or if the input port is not a reactive or monitoring
port, the update is not an independent operation.
For more information, see “Independent Operations and Consequences
in the Debugger”.
Dependent Operation
A dependent operation is a consequence of an independent operation.
ExamplesCompare the current operation display with the simulation log:
The output shows that the display of the current operation includes the
last entry in the simulation log, which is the current operation. The
display a lso includes the last unindented entry in the simulation log,
representing the latest independent operation.
2-35
sedb.currentop
y
*** SimEvents Debugger ***
Functions | Quick Start | Debugger Help
%==============================================================================%
Initializing Model sedemo_event_priorities
%==============================================================================%
Initializing Time-Based Entity Generators
configures the debugger to show or omit
certainkindsofmessagesinthesimulationlog. Youcanspecifyone,
two, or three pairs of parameter names,
values,
detail displays the current detail settings.
curr = detail returns a structure that describes the current detail
paramvalueN.
paramnameN,andparameter
settings.
2-37
sedb.detail
Input
Arguments
paramnameN
Name of detail setting.
'ev'
'en'
'cal'
paramvalueN
Value of detail setting.
0
1
Event operations, except if at least
one detail setting is 1, independent
operations representing event
executions appear. The exception holds
true even if the
Entity operations
Event calendar information
Omit messages, except upon reaching a
breakpoint. Omitting entity messages
or event messages also means that you
cannot rely on the
to an operation that corresponds to an
omitted message.
Show messages.
'ev' setting is 0.
step function to step
Output
Arguments
2-38
struc
Structure having three fields describing the detail settings that
you want. Field names are the same as the names in the table
that describes the
as the values in the table that describes the
curr
Structure that describes the current detail settings. Field
names a re the same as the names in the table that describes the
paramnameN input. Field values are the same as the values in the
table that describes the
paramnameN input. Field values are the same
paramvalueN input.
paramvalueN input.
prev
Structure that describes the pr evious detail settings before
changing them. Field names are the same as the names in the
table that describes the
paramnameN input. Field values are the
same as the values in the table that describes the
input.
ExamplesConfigure displays for breakpoints and stepping:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2 Proceed in the simulation, suppressing the simulation log until the
debugger reaches a breakpoint. At the
tbreak 2
prev = detail('none')
cont
sedebug>> prompt, enter:
sedb.detail
paramvalueN
The output ends with the context of the simulation at T =2:
Set b1 : Breakpoint for first operation at or after time 2.000000
prev =
ev: 1
en: 1
cal: 0
Hit b1 : Breakpoint for first operation at or after time 2.000000
Deleted b2 : Breakpoint for f irst operation at or after time 1.000000
Disabled b3 : Breakpoint for firs t operation at or after time 1.500000
Disabled b1 : Breakpoint for firs t operation at or after time 0.500000
Enabled b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
IDTypeValueEnabled
b1Timed0.5no
b3Timed1.5yes
4 Run the simulation until the first enabled breakpoint:
cont
The partial output shows that b3 is the breakpoint at which the
debugger stops. The debugger ignores the disabled breakpoint,
and doe s not consider the previously deleted breakpoint,
Hit b3 : Breakpoint for first operation at or after time 1.500000
Deleted b2 : Breakpoint for f irst operation at or after time 1.000000
Disabled b3 : Breakpoint for firs t operation at or after time 1.500000
Disabled b1 : Breakpoint for firs t operation at or after time 0.500000
Enabled b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
2-46
IDTypeValueEnabled
b1Timed0.5no
b3Timed1.5yes
4 Run the simulation until the first enabled breakpoint:
cont
The partial output shows that b3 is the breakpoint at which the
debugger stops. The debugger ignores the disabled breakpoint,
and doe s not consider the previously deleted breakpoint,
Hit b3 : Breakpoint for first operation at or after time 1.500000
akpoint that causes the debugger to stop when it is about
utetheservicecompletionevent,
ev4:
evbreak ev4
The output confirms the operation:
Set b1 : Breakpoint for execu tion or cancelation of event ev4
5 Run the simulation until the breakpoint:
cont
The partial output shows that the debugger proceeds through a
different event at T=1, and stops upon hitting the breakpoint at event
ev4. Because that event is not the first event the simulation executes
at that time, the example shows how an event breakpoint differs
from a timed breakpoint. A timed breakpoint at T=1 would have
caused the debugger to stop upon the first event at this time,
6 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Alsosedb.evcal | sedb.cont | sedb.breakpoints | sedb.bdelete
How To•“DefiningaBreakpoint”
2-56
sedb.evcal
PurposeEvent calendar of discrete-event simulation
Syntaxevcal
cal_struct = evcal
Descriptionevcal displays the list of events on the event calendar. The listing
for the event in progress or the event selected for execution includes
the characters
identifier. The display includes this event unless all its immediate
consequences are complete.
cal_struct = evcal returns a structure that stores information about
the event calendar.
=>. These characters appear to the left of the event
Output
Arguments
cal_struct
Structure that stores information about the event calendar. The
cal_struct fields are in the following table.
Field
Time
ExecutingEvent
Description
Current simulation time
Structure that describes the event in progress
or selected for execution. The structure has
these fields:
•
ID —Eventidentifier
EventType — Type of event
•
EventTime — Scheduled time of event
•
Priority —Priorityofevent
•
Entity — Identifier of entity associated
•
with the event
•
Block — Path name of block that executes
the event
2-57
sedb.evcal
Field
PendingEvents
Description
Structure array that describes events that are
not in progress or selected for execution. Each
structure in the array has these fields:
•
ID —Eventidentifier
EventType — Type of event
•
EventTime — Scheduled time of event
•
Priority —Priorityofevent
•
Entity — Identifier of entity associated
•
with the event
•
Block — Path name of block that executes
the event
ExamplesView the event calendar and then manipulate a structure variable that
storesthesameinformation:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2-58
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 2
detail none
cont
Theoutputendswithamessagedescribingthecontextof
simulation at T=2:
Set b1 : Breakpoint for first operation at or after time 2.000000
Event Operations (ev): off
the
sedb.evcal
Entity Operations (en): off
Event Calendar(cal) : off
Hit b1 : Breakpoint for first operation at or after time 2.000000
5 Use the identifier, blkid, to get information abo
ut the block and
the status of entities in it:
% Display information in Command Win dow.
blkinfo(blkid)
% Store information in str uct ure.
blkdetails = blkinfo(blkid)
% Store status of entities in cell array.
blkentities = {blkdetails.Entities.Status}'
The output is:
Infinite Server Current StateT = 2.581301297500028
5 Use the identifier, blkid, to get information abo
ut the block and
the status of entities in it:
% Display information in Command Win dow.
blkinfo(blkid)
% Store information in str uct ure.
blkdetails = blkinfo(blkid)
% Store status of entities in cell array.
blkentities = {blkdetails.Entities.Status}'
The output is:
Infinite Server Current StateT = 2.581301297500028