0% found this document useful (0 votes)
6 views28 pages

Stroboscope Construction Simulation Guide

Strobo Query

Uploaded by

bao004nhan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views28 pages

Stroboscope Construction Simulation Guide

Strobo Query

Uploaded by

bao004nhan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CENTER FOR

CONSTRUCTION
ENGINEERING
AND
MANAGEMENT

STROBOSCOPE
STATE- AND RESOURCE-BASED SIMULATION
OF CONSTRUCTION PROCESSES

QUICK REFERENCE GUIDE

Photios G. Ioannou
Julio C. Martinez

Civil and Environmental Engineering Department


UNIVERSITY OF MICHIGAN
Ann Arbor, Michigan
April 8, 2018
STROBOSCOPE QUICK REFERENCE GUIDE

DATA TYPES
Stroboscope has three data types,

1. Numbers (all are double-precision floating-point numbers)


2. Strings
3. Objects (more precisely, pointers to objects)

Any variable or property can hold a number as well as a string as well as an object (pointer).

Numbers: For maximum accuracy, all numbers, and the results of computations that return
numbers, are always double-precision floating-point numbers.

Logical values: Stroboscope does not have dedicated True and False logical values. Instead,
True and False are represented by numbers as follows:
• Any positive or negative number different from 0 (zero) has the logical value True.
• Only the number zero is considered to have the logical value False.

Operators and functions that return logical values return the numbers (0,1) as follows:
• When the result is True, Stroboscope returns the number 1 (one).
• When the result is False, Stroboscope returns the number 0 (zero).

Examples: !3.5 (i.e., Not[3.5] = Not[True] = False) returns the value 0 (i.e., False).
!0 (i.e., Not[0] = Not[False] = True) returns the number 1 (i.e., True).

Strings: A string is any text enclosed in double quotes, e.g., "This is a string".
Stroboscope does not have string operators. It supports only the two logical operators that check
for string equality as illustrated in the following examples:
DISPLAY ' "This" == "This" '; / This returns the number 1 (one)
DISPLAY ' "This" == "That" '; / This returns the number 0 (zero)
DISPLAY ' "This" != "This" '; / This returns the number 0 (zero)
DISPLAY ' "This" != "That" '; / This returns the number 1 (one)

Objects: An object is any user-defined globally-accessible simulation model element (e.g., a


gentype, a chartype, a subtype, a comptype, a queue, a combi, a normal, a fork, a dynafork, an
assembler, a disassembler, a link, a savevalue, an array, a variable, a collector, etc.). Pointers to
objects can be used to create resources of a particular type dynamically during simulation. They
can also be used to automate the creation of collectors and the collection of statistics. The uses of
pointers are explained further later. The following illustrate a few examples:
COMBI myCombi;
SAVEVALUE combiSV myCombi; / This savevalue holds a pointer to myCombi
SAVEVALUE stringSV "myCombi"; / This savevalue holds the string "myCombi"
DISPLAY "The string, " stringSV ", and combi, "combiSV ", print the same.";
/ Result: The string, myCombi, and combi, myCombi, print the same.
DISPLAY "Are they the same? "'stringSV==combiSV' " = No!";
/ Result: Are they the same? 0 = No!

P.G. Ioannou & J.C. Martinez -2- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

OPERATORS AND THEIR PRECEDENCE

Operator Name Precedence


$< >$ Preprocessor replacement 1 (highest)
() Parentheses 2
[] Function call 2
[] Array subscripts 2
! Logical NOT 3
- Negation 3
^ Power 4
/ Division 5
* Multiplication 5
- Subtraction 6
+ Addition 6
>= Greater than or equal to 7
> Greater than 7
<= Less than or equal to 7
< Less than 7
!= Not equal to 8
== Equal to 8
& Logical AND 9
| Logical OR 10
?: Conditional (IF) 11 (lowest)

Stroboscope operators and expressions are similar to those in C. Operators with higher
precedence are evaluated first. If two operators have the same precedence then the evaluation is
done from left to right. Stroboscope expressions that include white-space (spaces, tabs, or
carriage returns) must be enclosed in single quotes as shown in the example below.

Note that the conditional operator is ternary (i.e., it involves three expressions). It takes the form:
LogicalExpression ? ExpressionIfTrue : ExpressionIfFalse
This operator first checks the value of LogicalExpression. If it is true, it returns the value of
ExpressionIfTrue. Otherwise, it returns the value of ExpressionIfFalse. Thus, this conditional
operator is equivalent to the following IF(.) function found in many spreadsheets (such as
Excel):
IF(LogicalExpression, ExpressionIfTrue, ExpressionIfFalse)
The Stroboscope conditional operator does not require parentheses and thus makes it easy to
write very long nested conditional expressions. This makes it very easy to use the inverse
cumulative method and generate random numbers that follow a discrete CDF (cumulative
distribution function). For example, the following Stroboscope variable models the toss of a
single die (a discrete random variable) and returns an integer from 1 to 6 with equal probability:

VARIABLE DieOutcome 'Rnd[] <= 1/6 ? 1:


LastRnd[] <= 2/6 ? 2:
LastRnd[] <= 3/6 ? 3:
LastRnd[] <= 4/6 ? 4:
LastRnd[] <= 5/6 ? 5: 6';

P.G. Ioannou & J.C. Martinez -3- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

STROBOSCOPE STATEMENTS
RESOURCE DEFINITION (Element Definition Statements)
Statement Arguments Pg.1
GENTYPE GenType; 53
CHARTYPE CharType [Property] [...]; 166
SUBTYPE CharType SubType [Expression] [...]; 166
COMPTYPE CompCharType; 233
SAVEPROP[S] CharType Property [Property] [...]; 167
VARPROP CharType Property AnonymouslyCursoredExpression; 169

NETWORK ELEMENTS (NODES & LINKS) (Element Definition Statements)


QUEUE Queue ResourceType; 54
COMBI Combi; 54
NORMAL Normal; 54
CONSOLIDATOR Consolidator; 154
LINK Link Predecessor Successor [ResourceType]; 54

NETWORK NODE ATTRIBUTES (Attribute Statements)


DISCIPLINE CharQueue CursoredExpression; 198
DURATION Activity Expression; 56
PRIORITY Combi Expression; 98
SEMAPHORE Combi BooleanExpression; 102
ALWAYSENOUGH Combi; -
CONSOLIDATEWHEN Consolidator BooleanExpression; 155

LINK ATTRIBUTES FOR DRAWING RES. FROM QUEUES (Attribute Statements)


ENOUGH OutOfQueueLink BooleanExpression; 87
DRAWAMT OutOfQueueGenLink Expression; 88
DRAWDUR OutOfQueLink Expression; 92
DRAWUNTIL OutOfQueLink Expression; 90
DRAWORDER OutOfQueueCharLink CursoredExpression; 207
DRAWWHERE OutOfQueueCharLink CursoredExpression; 209
REVORDER CharLinkOutOfQueue|CharReleaseLink [LogicalExp]; 204

LINK ATTRIBUTES FOR RELEASING RESOURCES (Attribute Statements)


RELEASEAMT GenReleaseLink Expression; 95
RELEASEUNTIL CharReleaseLink BooleanExpression; 213
RELEASEORDER CharReleaseLink CursoredExpression; 212
RELEASEWHERE CharReleaseLink CursoredExpression; 212

1Page numbers refer to the printed Ph.D. dissertation submitted by J.C. Martinez. The corresponding pages for the
electronic version of the dissertation ([Link]) are found by adding 22 to the page numbers shown here.

P.G. Ioannou & J.C. Martinez -4- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

FILTERS FOR SELECTING RESOURCES (Element Definition & Attribute Statements)


FILTER Filter CharType CursoredExpression; 216
FILTEREXP Filter CursoredExpression; 216

FORKS AND DYNAFORKS (Element Definition & Attribute Statements)


FORK Fork ResourceType [Stream]; 142
DYNAFORK Fork ResourceType [Stream]; 144
STRENGTH OutOfForkLink Expression; 147

ASSEMBLERS & DISASSEMBLERS (Element Definition & Attribute Statements)


ASSEMBLER Assembler CompCharTypeAssembled; 237
DISASSEMBLER Disassembler CompoundCharTypeDisassembled; 241
ASMBASELINK Link Predecessor Assembler; 238
DISASMBASELINK Link DisAssembler Successor; 241
DUALBASELINK Link DisAssembler Assembler; 244

VARIABLE AND FUNCTION DEFINITIONS (Element Definition Statements)


VARIABLE Variable Expression; 69
FUNCTION NameInStrobo DllName NameInDll nArguments [const]; 381

SIMPLE PRINTING OF SIMULATION RESULTS (Control Statements)


REPORT [Outfile]; 59
DISPLAY [QuotedString | SingleQuotedExpression] [...]; 72

P.G. Ioannou & J.C. Martinez -5- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

ACTION-EVENTS (Element Definition Statements)


BEFOREDRAWS Activity [Action] ActionTarget TargetArguments; 116
ONDRAW OutOfQLink [Action] ActionTarget TargetArguments; 116
ONSTART Activity [Action] ActionTarget TargetArguments; 116
BEFOREEND Activity [Action] ActionTarget TargetArguments; 116
ONRELEASE ReleaseLink [Action] ActionTarget TargetArguments; 116
ONENTRY Queue [Action] ActionTarget TargetArguments; 116
ONEND Activity [Action] ActionTarget TargetArguments; 116
ONASSEMBLY Assembler [Action] ActionTarget TargetArguments; 240
ONDISASSEMBLY Disassembler [Action] ActionTarget TargetArguments; 243
ONFLOW Link [Action] ActionTarget TargetArguments; 152
BEFOREACTINGON Object ActionEntirelyContainedInAFunction; New
AFTERACTINGON Object ActionEntirelyContainedInAFunction; New
BEFORETIMEADVANCE [Action] ActionTarget TargetArguments; New
AFTERTIMEADVANCE [Action] ActionTarget TargetArguments; New
ACTIONS (Control Statements)
ASSIGN ActionTarget TargetArguments; 113
CALL TargetActionFunction; New
COLLECT ActionTarget [TargetArgument] [...]; 113
PRINT ActionTarget [TargetArgument] [...]; 113
DATA STORAGE (ASSIGN ActionTargets) (Element Definition Statements)
SAVEVALUE Variable[*] Expression; 1 119
ARRAY ArrayName Size [{ InitValue InitValue ...}]; 120
ARRAY MatrixName Rows Columns [{ InitValue InitValue ...}]; 121
STATS COLLECTORS (COLLECT ActionTargets) (Element Definition Statements)
COLLECTOR Collector[*]; 124
BINCOLLECTOR BinnedCollector[*] NumberOfBins TopOfFirst 424
BottomOfLast;
BINWGTCOLLECTOR BinnedWeightedCollector[*] NumberOfBins TopOfFirst New
BottomOfLast;
BINTMWGTCOLLECTOR BinnedTmWgtCollector[*] NumberOfBins TopOfFirst New
BottomOfLast InitialValueExpression;
BINQUEUE BinnedQueue ResourceType NumberOfBins TopOfFirst New
BotOfLast;
MVAVGCOLLECTOR MvAvgCollector[*] MaxSamplesExpression; 125
WGTCOLLECTOR WgtCollector[*]; 128
TMWGTCOLLECTOR TmWgtCollector[*] InitialValueExpression; 132
OUTPUT FILES (PRINT ActionTargets) (Element Definition Statements)
OUTFILE Alias DiskFileName; 134
APPFILE Alias DiskFileName; 134

1User-defined identifiers whose name ends in a * (when first defined) are not reset to their initial values by CLEAR
or RESETSTATS. When used later, the names of these identifiers must be omit the * from their end.

P.G. Ioannou & J.C. Martinez -6- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

RANDOM NUMBERS – VARIANCE REDUCTION (Control Statements)


STREAMS NumberOfRandomNumberStreams; 352
SEED Expression; 352
SEEDALL Expression [SeparationInHundredThousands]; 353
SEEDN Stream Expression; 353
ANTITHETICS [BooleanExpThatTurnsOnOrOffAntitheticSampling]; 354
ANTITHETICSOFF; New
ANTITHETICSON; New

INITIALIZATION OF QUEUES (Control Statements)


INIT GenQueue PositiveFloatExpression; 58
INIT SimpleCharQueue PositiveIntExpression SubType; 171
INIT CompoundCharQueue PositiveIntExpression; 234

SIMULATION CONTROL STATEMENTS (Control Statements)


SIMULATEUNTIL BooleanExpression; 78
SIMULATE; 59
CLEAR; 325
RESETSTATS; 314
SILENTREPLICATE [BooleanExpThatTurnsOnOrOffSilentReplications]; 346
DEBUGOFF; -
DEBUGON; -

PROGRAMMING AT THE SOURCE-FILE LEVEL (Control Statements)


LOADADDON AddOnDllName; 373
STATEMENT Alias DllName NameInDll; 380
IF IfExpression; 274
ELSE; 274
ELSEIF IfExpression; 274
ENDIF; 274
WHILE WhileExpression; 276
WEND; 277
BREAK; 278
CONTINUE; 278
ENDMODEL; 273

P.G. Ioannou & J.C. Martinez -7- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

MATHEMATICAL AND STATISTICAL FUNCTIONS


Important: Stroboscope identifiers are case-sensitive. Stroboscope functions must be
capitalized exactly as shown in the tables. This rule also applies to all user-defined identifiers
such as variable names, queue names, property names, etc. For example, the following variable
names are all different: Height, height, HeighT, etc.

Array Reference Functions Description


ArrayName[index] Value stored at position index in array ArrayName
Matrix[row, column] Value stored in row, column within array Matrix

Mathematical Functions Description


Abs[val] Absolute value of val
Exp[val] Exponential function of val
Int[val] Integral part of val
Ln[val] Natural logarithm of val
Log[val] Base_10 logarithm of val
Max[val1,val2] Maximum of val1 and val2
Min[val1,val2] Minimum of val1 and val2
Mod[val,div] Remainder of val / div
Round[expression,decimals] Round to decimal places (which can be negative)
Sqrt[val] Square root of val

Trigonometric Functions Description


Acos[val] ArcCosine of val
Asin[val] ArcSine of val
Atan[val] ArcTangent of val
AtanXdivY[x,y] ArcTangent of x/y
Cos[val] Cosine of val
Cosh[val] Hyperbolic cosine of val
Sin[val] Sine of val
Sinh[val] Hyperbolic sine of val
Tan[val] Tangent of val
Tanh[val] Hyperbolic tangent of val

Statistical Functions Description


Antithetics[] Status of system antithetic sampling generation
Confidence[SD,lvl,nSamples] Half-width of a confidence interval
NormalInv[mean,stdev,Cumulative] Inverse of the normal distribution
StdNormalInv[Cumulative] Inverse of the standard normal distribution
tInv[alpha,DegFreedom] Inverse of the t Distribution

P.G. Ioannou & J.C. Martinez -8- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Random Number Fns (*) Description


Beta[a,b] Sample from a unit Beta distribution
Beta[a,b,s] Sample from a unit Beta distribution using stream s
Erlang[order,mean] Sample from an Erlang distribution
Erlang[order,mean,s] Sample from an Erlang distribution using stream s
Exponential[mean] Sample from an Exponential distribution
Exponential[mean,s] Sample from an Exponential distribution using stream s
Gamma[a,b] Sample from a Gamma distribution
Gamma[a,b,s] Sample from a Gamma distribution using stream s
LastRnd[] Retrieve the last number returned by Rnd[]
LastRnd[s] Retrieve the last number returned by Rnd[] using stream s
Normal[mean,stdev] Sample from a Normal distribution
Normal[mean,stdev,s] Sample from a Normal distribution using stream s
OffSetSeed[seed,positions] The seed separated by positions from the supplied seed
Pert[p0,mode,p100] Sample from PERT Beta distribution
Pert[p0,mode,p100,s] Sample from PERT Beta distribution using stream s
Pertpg[p5,mode,p95] Sample from Perry & Grieg Beta distribution
Pertpg[p5,mode,p95,s] Sample from Perry & Grieg Beta dist. using stream s
Rnd[] Sample a number uniformly distributed between 0 and 1
Rnd[s] Sample a number uniformly from 0 to 1 using stream s
ScaledBeta[low,high,a,b] Sample from a scaled Beta distribution
ScaledBeta[low,high,a,b,s] Sample from a scaled Beta distribution using stream s
sSeed[s] The current seed for stream s
Triangular[low,mode,high] Sample from a Triangular distribution
Triangular[low,mode,high,s] Sample from a Triangular distribution using stream s
Uniform[low,high] Sample from a Uniform distribution
Uniform[low,high,s] Sample from Uniform distribution using stream s

(*) For backwards compatibility with previous versions of Stroboscope, random number
functions that use streams can also be written with the prefix “s” before the function name. For
example, Uniform[low,high,s] can also be written as sUniform[low,high,s].

P.G. Ioannou & J.C. Martinez -9- April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

SYSTEM-MAINTAINED VARIABLES

ABBREVIATION STANDS FOR


Activity Combi, Consolidator, Normal
CursorSupporter Assembler, Characterized Dynafork, Characterized Link,
Characterized Queue, DisAssembler, Filter
Customer SubType, Compound Resource Type
MultiReceiver Activity, Assembler
HeteroHolder MultiReceiver, DisAssembler
Hotel Activity, Characterized Queue, Compound Resource Type

Global variables:
CurSeed
RelTime
SimTime
Activity.{AveDur | AveInter | CurInst | FirstStart | LastStart | MaxDur | MaxInter | MinDur |
MinInter | RelTotInst | SDDur | SDInter | TotInst }
[Link]
[Link].{AveEnts | AvTotTm | AvVstTm | SDVstTm | MnVstTm | MxVstTm}
[Link]
[Link].[AveVal | MaxVal | MinVal | SDVal | SumVal]
[Link].[AveVal | MaxVal | MinVal | SDVal | SumVal]
[Link]
CharType.{AveLife | MaxLife | MinLife | SDLife}
CharType.{AvePp | CurPp | MaxPp | MinPp | SDPp | TotPp}
Collector.{AveVal | MaxVal | MinVal | nSamples | SDVal | SumVal }
[Link]
[Link]
[Link]
[Link]
Queue.{AveCount | AveWait | CurCount | MaxCount | MinCount | SDCount | TotCount}
SubType.{AveLife | MaxLife | MinLife | SDLife}
SubType.{AvePp | CurPp | MaxPp | MinPp | SDPp | TotPp}
[Link]
TmWgtCollector.[AveVal | MaxVal | MinVal | SDVal | TtlWgt]
WgtCollector.{AveVal | MaxVal | MinVal | SDVal | TtlWgt}
{Savevalue | TmWgtCollector}.Obj

P.G. Ioannou & J.C. Martinez - 10 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

New Global variables:


The following global variables are new and were added to Stroboscope to support the needs of
writing animation trace files or performing animations while the simulation runs.

NextSimTime
New: Returns the time to which the clock would be advanced, if the clock advance phase
took place immediately.
When the FEL is empty (i.e., there is no next simulation clock time), it returns -1.

SetNextSimTime[NextSimTimeValue]
New function: Returns the prior value of NextSimTime and then sets the value of
NextSimTime to the provided NextSimTimeValue.

[Link]
New: Returns the text (as a string) that was last printed to OutFile via the PRINT
statement, action, or function. Output to StdOutput via DISPLAY or to any outfile via
REPORT does not affect the LastPrintText predefined string variable.

[Link].[Value | Count | AveVal | MaxVal | MinVal | SDVal | SumVal]


New: A Filter can now be applied to the entire population of resources of a type using
the above forms.
'[Link]' can be used when exactly one resource passes the Filter; and if
the Property is a SaveProp, its value can be changed.
Note: It is necessary to add '.Value' to differentiate from '[Link]' which returns
the Property of the resource cursored by the Filter (and which is a cursor variable and
not a global variable).

P.G. Ioannou & J.C. Martinez - 11 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

ABBREVIATION STANDS FOR


Activity Combi, Consolidator, Normal
CursorSupporter Assembler, Characterized Dynafork, Characterized Link,
Characterized Queue, DisAssembler, Filter
Customer SubType, Compound Resource Type
MultiReceiver Activity, Assembler
HeteroHolder MultiReceiver, DisAssembler
Hotel Activity, Characterized Queue, Compound Resource Type

Instance variables:
Activity.{Duration | Instance | StartTm}
[Link].[AveVal | MaxVal | MinVal | SDVal | SumVal]
[Link]
[Link].[AveVal | MaxVal | MinVal | SDVal | SumVal]
[Link]
[Link]
OutOfQueLink.{AveDrawDur | MaxDrawDur | MinDrawDur | nDraws | SDDrawDur |
SumDrawDur}

Cursor variables:
[CursorSupporter.]BirthTime
[CursorSupporter.]ResNum
[CursorSupporter.]SaveProp
[CursorSupporter.]SubTypeProperty
[CursorSupporter.]TimeIn
[CursorSupporter.]VarProp

New Cursor variables:


The following cursor variables are new and were added to Stroboscope to support special needs,
such as writing animation trace files or performing animations while the simulation runs.
[CursorSupporter.][Link] (New) Returns the instance, node, link, or compound
resource where the resource is currently located.
[CursorSupporter.][Link] (New) returns (a pointer to) the instance, node, or link
where the resource is currently located. Differs from
WhereIs when the resource is contained in a compound
resource, in which case, it returns the instance, node or
link where the compound resource is located.
[CursorSupporter.][Link] (New) Returns (a pointer to) the resource itself.

P.G. Ioannou & J.C. Martinez - 12 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Timing of Action-Events
Action-Event Description
BEFOREDRAWS The event occurs after ActivityName is known to be able
ActivityName to start, but before a [Combi | Normal] [draws | receives]
any resources through its incoming links.
ONDRAW DrawLinkName The event occurs when a resource is moved from a Queue
to a Combi through Link DrawLinkName. When this
event occurs, the resource is inside the Link (it has left the
Queue but has not reached the Combi. The Draw Amount
and Draw Durations have already been determined.
ONSTART ActivityName The event occurs just after an instance of ActivityName
has been created. All the resources that will be part of this
instance have already been received and its duration has
been determined.
BEFOREEND ActivityName The event occurs just before an instance of ActivityName
is terminated, and before the instance releases resources
through its outgoing links.
ONRELEASE RelLinkName The event occurs when a resource is released from an
Activity through Link RelLinkName. If this Link is for
generic resources, the resource has already been created
by the Link but has not yet arrived at the successor. If this
Link is for characterized resources, the characterized
resource is inside the Link (it has left the Activity but has
not yet reached the successor node).
ONENTRY QueueName The event occurs when a resource enters the Queue
QueueName. The resource has entered the Queue is
already part of the Queue contents.
ONEND ActivityName The event occurs when an instance of ActivityName is
terminated, after the instance releases resources through
its outgoing links, but before it destroys any unreleased
resources.
ONFLOW LinkName The event occurs when a resource flows through a link
other than a Draw or a Release link. A characterized
resource is cursored by the link.
ONASSEMBLY The event occurs after the AssemblerName attaches all
AssemblerName resources received through its incoming links to the
compound resource (which is still cursored).
ONDISASSEMBLY The event occurs after the DisassemblerName releases any
DisassemblerName disassembled resources through its outgoing links. The
compound resource is still cursored. Unreleased resources
have not yet been destroyed, and if a disassembly-base
link exists, they have not yet been reattached back to the
compound resource that was received.

P.G. Ioannou & J.C. Martinez - 13 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Timing of Action-Events that support Preemption


The following events occur only if the following function is successful:
• Preempt[Act, InstNum, ActThatWillTakeOver]

Specifically, they occur


• From when the function Preempt has found the instance to preempt in the FEL
• To when the function Preempt finishes and returns the value 1 (true).

BEFOREPREEMPTED New: Applies to the instance of CurAct being preempted.


CurAct It occurs after the duration-related statistics of CurAct
have been corrected but before the instance count of
CurAct has been decremented.
If the BeforePreempted action-event was triggered by an
action-event of another activity, such as BeforeEnd
TriggeringAct, then both activity instances are in context:
i.e., the instance of CurAct about to be preempted and the
instance of TriggeringAct that triggered the preemption
and their attributes (duration, instance number, etc.) and
the resources in both instances are accessible.
AFTERPREEMPTING New: Applies to the new instance of NewAct, i.e., the
NewAct activity that takes over the resources and remaining
duration of CurAct. This event takes place after the
preemption has been completed.
If the AfterPreempting action-event was triggered by an
action-event of another activity, such as BeforeEnd
TriggeringAct, then both activity instances are in context:
i.e., the instance of NewAct just created and the instance
of TriggeringAct that triggered the preemption and their
attributes (duration, instance number, etc.) and the
resources in both instances are accessible.

Note: The function Preempt[Act, InstNum, ActThatWillTakeOver] requires the name of activity
Act, or a pointer to the activity, Act, and not a pointer to a particular instance of activity Act, such
as Act(1). The particular instance of activity Act to be preempted is provided separately as the
second argument, InstNum, to the function Preempt.

P.G. Ioannou & J.C. Martinez - 14 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Timing of Action-Events that support Special Needs


The following action events are new and were added to Stroboscope to support special needs,
such as writing animation trace files or performing animations while the simulation runs.

BEFOREACTINGON New: Allow new actions to be taken before or after an


Object action is applied to an object. The new action to be taken
AFTERACTINGON should be contained entirely in one expression (which
Object allows links to functions defined in AddOns).
BEFORETIMEADVANCE New: These statements allow the definition of actions to
AFTERTIMEADVANCE be taken before or after the simulation clock is advanced.
They may take place repeatedly with time advances of
zero if Combis are instantiated with a zero duration.
[Note: This does not happen when zero-duration Normals
are instantiated because a clock-advance phase does not
take place in that case.]

Examples
Example uses of new Action-Events:
This example duplicates what is printed to StdOutput into a text file:
OUTFILE StdOutDup c:\[Link];
AFTERACTINGON StdOutput Print[StdOutDup,[Link]];
PRINT StdOutput "This is also written in [Link]"

This example keeps track on the statistics associated with clock advances:
COLLECTOR tmAdvances;
BEFORETIMEADVANCE COLLECT tmAdvances NextSimTime-SimTime;

This example prints a time statement to an animation trace file every time the simulation
clock is advanced:
OUTFILE VitaTrace "[Link]";
AFTERTIMEADVANCE PRINT VitaTrace "TIME %f\;\n" SimTime;

P.G. Ioannou & J.C. Martinez - 15 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Action-Targets (to Action-Events)


Stroboscope Action-Events operate on Action-Targets. Some Action-Targets are predefined
(such as CALL, GENERATE, and StdOutput) while others come from the names of user-
defined objects (such as the names of Collectors or the names of SaveValues).

All Action-Event statements have the following form:

ActionEvent Element [Action] ActionTarget [PRECOND BooleanExpression] TargetArgs;

For example:
ONENTRY PersonQueue ASSIGN MaleCount PRECOND Gender==1 MaleCount+1

In this example, the ActionEvent is ONENTRY and the Element is PersonQueue. Thus, when a
resource (e.g., a Person) enters this queue, the Action is to ASSIGN and the ActionTarget of this
action is the SaveValue MaleCount (which stores the total number of male persons that have
entered the queue PersonQueue). The value assigned to MaleCount is given by TargetArgs
which in this case is MaleCount+1, i.e., the current value of MaleCount incremented by one unit.
MaleCount is incremented only when the PRECOND BooleanExpression is True. In this case,
this happens when the Gender property of the resource entering the queue equals the value 1 (it
is assumed that a Gender value of 1 indicates a male person, and a value of 0 indicates a female).
If the BooleanExpression is False, the entire statement is ignored (no action takes place).

Note that the operation to be performed at a particular Action-Event depends entirely on the type
of the Action-Target and the number and type of arguments that are passed to it. Thus, the use of
the [Action] verb (that could be any one of: ASSIGN, COLLECT, and PRINT) is completely
optional. It serves only to remind us of the intended action.

In particular, the predefined Action-Targets CALL and GENERATE are meant to be used
without a preceding Action verb. They can be preceded by the ASSIGN action, but the syntax
“ASSIGN CALL” or “ASSIGN GENERATE” makes the meaning of the statements harder to
understand. So, it is better for the action ASSIGN to be omitted.

A summary of the available Action-Targets appears below.

P.G. Ioannou & J.C. Martinez - 16 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Single Value ActionTargets:


The following are ActionTargets to ASSIGN or COLLECT that expect a single
double-precision value.
Arguments:
A single argument consisting of an expression, the result of which will be
ASSIGNed to, or COLLECTed by the target.
ActionTargets:
SaveProps (dynamically ASSIGNed properties of characterized resources)
[Link]
[Link]
[CursorSupporter.]SaveProp
[Link]
[Link]
SaveValues (dynamically ASSIGNed single-value storage locations)
SaveValue
Statistics Collectors (statistical calculators that COLLECT statistical data)
Collector
MvAvgCollector
TmWgtCollector

Weighted Collectors:
The following are ActionTargets to COLLECT that expect two double-precision
values as arguments, the first being the data and the second being the data weight.
Arguments:
Two arguments consisting of expressions, the result of the first expression is
added to the statistics kept by the target, with a weight determined by the result of
the second expression.
ActionTargets:
WgtCollector

Arrays (1-D Vectors):


The following are ActionTargets to ASSIGN. Arguments are a singly-indexed set
of double-precision values. A single value can be assigned to a particular element
given an index, or all the values in the array can be initialized at the same time.
Arguments:
When setting the value of a particular element: Two arguments consisting of
expressions; the first expression gets truncated to an integer that indicates the
index within the array; the result of the second expression will be assigned to the
indexed element in the array.
When setting values to all the elements: A list of expressions separated by white-
space enclosed in curly braces ‘{‘ and ‘}’. The result of each expression will be
assigned to the corresponding element in the array.
ActionTargets:
ArrayName

P.G. Ioannou & J.C. Martinez - 17 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Matrix (2-D):
The following are ActionTargets to ASSIGN. Arguments are a doubly-indexed
(row, column) set of double-precision values. A value can be assigned to a
particular element given a row and a column, or all the values in the matrix can be
initialized at the same time.
Arguments:
When setting the value of a particular element: Three arguments consisting of
expressions; the first expression gets truncated to an integer that indicates the row
within the matrix; the second expression gets truncated to an integer that indicates
the column within the matrix; the result of the third expression will be assigned to
the indexed element in the matrix.
When setting values to all the elements: A list of expressions separated by white-
space enclosed in curly braces ‘{‘ and ‘}’. The result of each expression will be
assigned to the corresponding element in the matrix.
ActionTargets:
MatrixName

CALL:
A predefined ActionTarget whose primary purpose is to invoke (i.e., call)
“statement functions” and “variable functions” to allow automation through
indirection. Notice that even though the ActionTarget CALL may be preceded by
the Action ASSIGN it is meaningless and bad practice to do so. Thus, the
optional [Action] is omitted.
Arguments:
Any expression involving any function.
Restrictions:
There are no restrictions. It can be used at any action-event. Moreover, it can be
used to start a new statement at the simulation file level without being preceded
by an Action (such as ASSIGN). Thus, CALL can behave like a Stroboscope
statement (even though strictly speaking it is an action-target). The main purpose
of CALL is to allow automation through indirection at the simulation file level (as
opposed to at simulation runtime).
Example:
CALL Assign[Sv,Value[Sv]*2];
In this example, Sv is a savevalue that holds the address of a time-weighted-
collector. The Assign function stores into the time-weighted-collector its value
multiplied by 2. Hence, the value of the time-weighted-collector is doubled.
Nothing happens to the savevalue Sv.

P.G. Ioannou & J.C. Martinez - 18 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

GENERATE:
A predefined ActionTarget that creates characterized resources. Notice that even
though the ActionTarget GENERATE may be preceded by the Action ASSIGN it
is meaningless and bad practice to do so. Thus, the optional [Action] is omitted.
Arguments:
An expression whose value gets truncated to an integer, followed by the name of
a SubType or Compound characterized type. The value of the expression
determines the number of resources of the specified SubType or Compound type
to be created.
Restrictions:
The GENERATE target can only be used in the BEFOREDRAWS and
BEFOREEND events. The created resources join the other resources held by the
starting Combi or ending Activity.
Example:
BEFOREEND Arrival GENERATE 3 MalePersons;
This example generates three characterized resources of the subtype (or
Compound type) MalePersons right before the activity Arrival ends and before it
releases any resources. The resources generated are added to the back of the other
resources already held by the ending instance of Arrival and are released in the
usual manner.

Outfiles:
The following are ActionTargets to PRINT that store formatted text output.
Arguments:
A Format String enclosed in double quotes is required as the first argument. One
additional argument consisting of an expression is required for each Format
Specifier in the Format String. Format Specifiers are substituted with the result of
the corresponding expression.
For a detailed explanation of the Format String and Format Specifiers see p. 431.
ActionTargets:
AppFile (alias of file to append text to)
OutFile (alias of file to create and send text to)
StdError (the default device or window to which error messages are written)
StdOutput (the default device or window to which output is written)
StdTrace (the default device or window to which the sim. trace is written)

P.G. Ioannou & J.C. Martinez - 19 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Target Arguments for OutFile Action-Targets


FormatStringInDoubleQuotes Expression1 Expression2 ...

FormatStringInDoubleQuotes = “[Text][Format1][Text][Format2]....”

Format = %[flags] [width] [.precision] type

flags = + | - | 0 | (space)
+ = Puts a + in front of a positive number
- = Left justify
Space = Puts a space before a positive number
Zero = Prints leading zeros (like in ZIP Codes)
width, precision = nonnegative integers
type = f | e | E | g | G | s
f = [-][Link]
e = [-][Link] e [+]ddd
E = [-][Link] E [+]ddd
g = “f” or “e” format, whichever is more compact
G = “f” or “E” format, whichever is more compact
s = used for printing a string; if used accidentally to print a number it prints
the string “a plain number” to indicate the error

Flags can be mixed and matched in any order to produce the desired format

Escape Characters
\n inserts a newline character (i.e., a carriage return)
\t inserts a tab character
\ddd inserts a character whose decimal ASCII code is ddd (0 - 255)
\\ inserts a backslash character (\)
%% inserts a percent character (%)

Example:
PRINT StdOutput “Value of Arg1 is \t%7.3f, \nand value of Arg2 is \t%f” Rnd[] Rnd[];
produces
Value of Arg1 is __0.153,
and value of Arg2 is 0.12345

P.G. Ioannou & J.C. Martinez - 20 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

FUNCTIONS—Equivalent to STATEMENTS or VARIABLES


(Intended primarily for special needs, such as animation. See notes and warning at end.)

Activity Instance Fns Equivalent Variable Description


InContext[HeteroHolder] [Link] Is there is an instance in context of the Activity,
assembler or disassembler? (0,1)
Instance[Activity] [Link] Instance number of the instance in context of Activity
CurInst[Activity] [Link] Current number of instances of Activity
RelTotInst[Activity] [Link] Total number of instances of Activity since last reset
TotInst[Activity] [Link] Total number of instances of Activity

Activity Duration Fns Equivalent Variable Description


Duration[Activity] [Link] Duration of the instance in context of Activity
AveDur[Activity] [Link] Average duration of Activity
SDDur[Activity] [Link] Standard deviation of duration of Activity
MaxDur[Activity] [Link] Maximum duration of Activity
MinDur[Activity] [Link] Minimum duration of Activity

Activity Start Time Fns Equivalent Var. Description


FirstStart[Activity] [Link] Time at which the first instance of Activity started
LastStart[Activity] [Link] Time at which the last instance of Activity started
AveInter[Activity] [Link] Average time between successive starts of Activity
SDInter[Activity] [Link] Std. dev. of time between successive starts of Activity
MaxInter[Activity] [Link] Maximum time between successive starts of Activity
MinInter[Activity] [Link] Minimum time between successive starts of Activity

Collector Creation Fns Equivalent Statement Description


NewCollector[ COLLECTOR Create a new collector named CollectorName
"CollectorName"] CollectorName;
NewCollector[ BINCOLLECTOR Create a new binned collector named
"CollectorName",nBins, CollectorName nBins CollectorName
TopOfFirst,BotOfLast] TopOfFirst BotOfLast;
NewMvAvgCollector[ MVAVGCOLLECTOR Create a new moving average collector named
"CollectorName",N] CollectorName N; CollectorName that keeps statistics on the last
N values stored
NewTmWgtCollector[ TMWGTCOLLECTOR Create a new time-weighted collector named
"CollectorName",InitValue] CollectorName InitValue; CollectorName with initial value InitVal
NewTmWgtCollector[ BINTMWGTCOLLECTOR Create a new binned time-weighted collector
"CollectorName",InitValue, CollectorName InitValue named CollectorName with initial value InitVal
nBins,TopOfFirst,BotOfLast] nBins TopOfFirst BotOfLast;
NewWgtCollector[ WGTCOLLECTOR Create a new weighted collector named
"CollectorName"] CollectorName; CollectorName
NewWgtCollector[ BINWGTCOLLECTOR Create a new binned weighted collector named
"CollectorName",nBins, CollectorName nBins CollectorName
TopOfFirst,BotOfLast] TopOfFirst BotOfLast;

Collector Action Functions Equivalent Statement Description


Collect[pCollector,value] COLLECT Collector Add value to the statistics of the collector
Value; pointed to by pCollector
WgtCollect[pCollector,value,weight] COLLECT Collector Value Add value with weight to the statistics of
Weight; the collector pointed to by pCollector
Reset[pCollector] New Discard all previous statistics collected by
the collector pointed to by pCollector

P.G. Ioannou & J.C. Martinez - 21 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Collector Stat Functions Equivalent Variable Description


nSamples[Collector] [Link] Number of values collected by Collector
AveVal[Collector] [Link] Average value collected by Collector
SDVal[Collector] [Link] Standard deviation of values collected by Collector
SumVal[Collector] [Link] Sum of values collected by Collector
MaxVal[Collector] [Link] Maximum value collected by Collector
MinVal[Collector] [Link] Minimum value collected by Collector

Collector Bin Functions Eqv. Var. Description


BinCount[Collector] New Number of bins in Collector
BinLow[Collector,bin] New Get the lower bound of bin
BinHigh[Collector,bin] New Get the upper bound of bin
CorrespondingBin[Collector,value] New Bin number where value would be collected
HitsAtBin[Collector,bin] New Get the number of values collected at bin
HitsAtOrBelowBin[Collector,bin] New Get the number of values in bin and all lower numbered bins
PctAtBin[Collector,bin] New Get the percentage of values collected by bin
PctAtOrBelowBin[Collector,bin] New Get the % of values in bin and all lower numbered bins
TtlWgt[Collector] New Total weight of values collected by Collector
WgtAtBin[Collector,bin] New Get the weight collected at bin
WgtAtOrBelowBin[Collector,bin] New Get the weight collected at bin and all lower numbered bins

Cursored Value Functions Equivalent Var. Description


HasCursor[CursorSupporter] CursorSupporter Returns true if CursorSupporter is cursoring
.HasCursor
Value[QueueActivityAsmOrDisAsm, See individual Value of CursoredExpression (which can be very
ChartypeSubtypeOrFilter, cases below: complex and not just a Property) for the only
CursoredExpression] resource of the corresponding class in node.
Value[CharQue,Chartype, CharQue. Value of CursoredExpression for the only resource
CursoredExpression] Property of CharType in CharQue (not just a Property)
Value[CharQue,SubType, [Link]. Value of CursoredExpression for the only resource
CursoredExpression] Property of SubType in CharQue (not just a Property)
Value[CharQue,Filter, [Link]. Value of CursoredExpression for the only resource
CursoredExpression] Property in CharQue that passes Filter (not just a Property)
Value[Heteroholder,Chartype, HeteroHolder.C Value of CursoredExpression for the only resource
CursoredExpression] [Link] of CharType in Activity Asm or DisAsm
y
Value[Heteroholder,SubType, [Link] Value of CursoredExpression for the only resource
CursoredExpression] [Link] of SubType in Activity Asm or DisAsm
Value[Heteroholder,Filter, [Link] Value of CursoredExpression for the only resource
CursoredExpression] [Link] in Activity Asm or DisAsm that passes Filter
AveVal[QueueActivityAsmOrDisAsm, See above for Average of the values of CursoredExpression
ChartypeSubtypeOrFilter, Value[] aggregated over all the resources of the
CursoredExpression] corresponding class in node
SDVal[QueueActivityAsmOrDisAsm, See above for Standard deviation of the values of
ChartypeSubtypeOrFilter, Value[] CursoredExpression aggregated over all the
CursoredExpression] resources of the corresponding class in node
SumVal[QueueActivityAsmOrDisAsm, See above for Sum of the values of CursoredExpression
ChartypeSubtypeOrFilter, Value[] aggregated over all the resources of the
CursoredExpression] corresponding class in node
MaxVal[QueueActivityAsmOrDisAsm, See above for Maximum of the values of CursoredExpression
ChartypeSubtypeOrFilter, Value[] aggregated over all the resources of the
CursoredExpression] corresponding class in node
MinVal[QueueActivityAsmOrDisAsm, See above for Minimum of the values of CursoredExpression
ChartypeSubtypeOrFilter, Value[] aggregated over all the resources of the
CursoredExpression] corresponding class in node

P.G. Ioannou & J.C. Martinez - 22 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Link Draw / Release Fns Equivalent Variable Description


LastAmtDrawn[GenDrawLink] [Link] The last amount drawn by GenDrawLink
LastAmtReleased[GenRelLink] [Link] The last amount released by GenReleaseLink
nDraws[Drawlink] [Link] Number of draws through Drawlink in
current process
AveDrawDur[Drawlink] [Link] Average draw duration through Drawlink in
current draw process
SDDrawDur[Drawlink] [Link] Std deviation of draw durations through
Drawlink in current draw process
SumDrawDur[Drawlink] [Link] Sum of draw durations through Drawlink in
current draw process
MaxDrawDur[Drawlink] [Link] Maximum draw duration through Drawlink
in current draw process
MinDrawDur[Drawlink] [Link] Minimum draw duration through Drawlink
in current draw process

Queue Contents Functions Equivalent Variable Description


LastAmtReceived[GenQueue] [Link] The last amount received by GenQueue
CurCount[queue] [Link] Current content of queue
AveCount[queue] [Link] Average content of queue
AveWait[queue] [Link] Average wait at queue
MaxCount[queue] [Link] Maximum content of queue
MinCount[queue] [Link] Minimum content of queue
SDCount[queue] [Link] Standard deviation of content of queue
TotCount[queue] [Link] Total content of queue

Resource Count Functions Equivalent Variable Description


Count[Queue,ResourceType] [Link] Amount of GenType or CharType in Queue
Count[Queue,Subtype] [Link] Number of corresponding Subtype in Queue
Count[Queue,Filter] [Link] Number of resources in Queue that pass Filter
Count[HeteroHolder,ResType] [Link] Amount of GenType or CharType in Activity,
Ass. or Disass.
Count[HeteroHolder,Subtype] [Link] Number of Subtype in Act., Ass. or Disass.
Count[HeteroHolder,Filter] [Link] Number of resources in Activity, Ass. or
Disass. that pass Filter

Res. Population Functions Equiv. Variable Description


CurPp[SubtypeOrChartype] [Link] Number of resources of SubtypeOrChartype
currently in the system
TotPp[SubtypeOrChartype] [Link] Number of resources of SubtypeOrChartype
created in the system so far
AvePp[SubtypeOrChartype] [Link] Average number of resources of
SubtypeOrChartype that have simultaneously
existed in the system
SDPp[SubtypeOrChartype] [Link] Standard deviation of same (see above)
MaxPp[SubtypeOrChartype] [Link] Maximum number of same (see above)
MinPp[SubtypeOrChartype] [Link] Minimum number of of same (see above)

P.G. Ioannou & J.C. Martinez - 23 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Resource Life Functions Equivalent Variable Description


AveLife[SubtypeOrChartype] [Link] Average life of resources of SubtypeOrChartype
SDLife[SubtypeOrChartype] [Link] Standard deviation of life of resources of
SubtypeOrChartype
MaxLife[SubtypeOrChartype] [Link] Maximum life of resources of
SubtypeOrChartype
MinLife[SubtypeOrChartype] [Link] Minimum life of resources of
SubtypeOrChartype

Resource Visit Functions Equivalent Variable Description


AveEnts[Hotel,Customer] [Link] Average number of entries of Customer (i.e.,
subtype, or compound type) to Hotel (i.e., char.
queue, activity, or compound type)
AvTotTm[Hotel,Customer] [Link] Average total time spent by Customer (i.e.,
subtype, or compound type) in Hotel (i.e., char.
queue, activity, or compound type)
AvVstTm[Hotel,Customer] [Link] Average of visit durations by Customer (i.e.,
subtype, or compound type) in Hotel (i.e., char.
queue, activity, or compound type)
SDVstTm[Hotel,Customer] [Link] Standard deviation of visit durations by Customer
(i.e., subtype, or compound type) in Hotel (i.e.,
char. queue, activity, or compound type)
MxVstTm[Hotel,Customer] [Link] Maximum visit duration by Customer (i.e., subtype,
or compound type) in Hotel (i.e., char. queue,
activity, or compound type)
MnVstTm[Hotel,Customer] [Link] Minimum visit duration by Customer (i.e., subtype,
or compound type) in Hotel (i.e., char. queue,
activity, or compound type)

Array/Matrix Fns Equivalent Variable Description


GetArrayElement[Array,I] Array[I] Returns the requested element of a 1D Matrix
GetArrayElement[Array,I,J] Array[I,J] Returns the requested element of a 2D Matrix
GetMatrixSize[Array] New Returns the size of a 1D Matrix
GetMatrixSize[Array,dim] New Returns the size of a 2D Matrix in the provided dim.

Preemption Fns (New) Description


Preempt[Act,InstNum,ActThatWillTakeOver] Returns the instance number of the new instance of the
activity that took over
SetTmLeftInst[ Returns TRUE if the instance was found in the FEL
ActInstWithNewDur,InstNum,RemainingDuration] and its remaining time was updated

Pause & SimTime Fns (New) Description


Pause[NonZeroToPause] Pauses simulation and returns number of seconds in the pause
GetPauseCount[] Gets the number of Pauses in simulation that have occurred
SetPauseDelay[MillisecondsForPauses] Sets the number of msecs for pauses and returns the previous setting
SetPausesRcvd[PausesRcvd] Sets number of pauses received & returns number of pauses attempted
SetNextSimTime[NextSimTime] Returns prior val of NextSimTime & sets its value to that provided

Array/Matrix Fns Equivalent Variable Description


GetArrayElement[Arr,I] Arr[I] Returns the requested element of a 1D Matrix
GetArrayElement[Arr,I,J] Arr[I,J] Returns the requested element of a 2D Matrix
GetMatrixSize[Arr] New Returns the size of a 1D Matrix
GetMatrixSize[Arr,dim] New Returns the size of a 2D Matrix in the provided dim.

P.G. Ioannou & J.C. Martinez - 24 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

File Functions Equivalent Statement Description


OpenOutFile[OutFile,"szFileName", OUTFILE OutFile szFileName Map szFileName to OutFile
bAppend] APPFILE OutFile szFileName
CloseOutFile[OutFile] New Close the file associated with OutFile
Print[OutFile,Text] PRINT OutFile "Text" Text can be any string literal or
something containing a string.

Indirect Addressing Fns Equiv. Stmt Description


Assign[Savevalue,Value] New Assign Value to the object pointed to (in RAM) by Savevalue
Value[Savevalue] New Value of object pointed to (in RAM) by Savevalue. Applicable only
when Savevalue holds "the address to an object" (i.e., a pointer).

Warning: The above functions should not be used when an equivalent statement or variable is
available and can be used. The functions are much slower.
Important Notes: In general, the above functions can accept as arguments either an object or a
pointer to that object. I.e., the argument is not restricted. For example,
COMBI myCombi;
SAVEVALUE combiSV myCombi; / This savevalue holds a pointer to myCombi
DISPLAY "Object: " TotInst[myCombi] ". Pointer: " TotInst[combiSV];
/ Result: Object: 0. Pointer: 0
Exception: Statement and variable functions whose argument is a savevalue, an array, or a
tmwgtcollector, require a pointer to such an object. This is because in these cases using the
object’s name will return the value that the object contains and not a pointer to the object itself.
See examples in the following section on “indirection”.

P.G. Ioannou & J.C. Martinez - 25 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

Indirection & Probabilistic Generation of Resources


Savevalues, arrays, and variables, as well as the properties, saveprops and varprops of char.
resources, can store more than a number or string. They can store a pointer to another object:
A gentype, a chartype, a subtype, a comptype, a queue, a combi, a normal, a fork, a dynafork,
an assembler, a disassembler, a link, a savevalue, an array, a variable, a collector, etc.

One powerful use of this capability is to generate resources of a particular subtype based on a
random process. The model below first assigns to savevalue CoinToss either the subtype Tails or
the subtype Heads (with 50-50 chance) and then generates resources of that randomly chosen
subtype. Also, the savevalue pCoinStats holds a pointer to the collector CoinStats:
CHARTYPE CoinSide Val;
SUBTYPE CoinSide Tails 0;
SUBTYPE CoinSide Heads 1;
SAVEVALUE CoinToss 10; / Create CoinToss with initial value 10
DISPLAY CoinToss; / This will display the number '10'
COLLECTOR CoinStats;
SAVEVALUE pCoinStats CoinStats; /pCoinStats is a pointer to CoinStats

COMBI FlipCoin;
SEMAPHORE FlipCoin ![Link];
BEFOREEND FlipCoin ASSIGN CoinToss 'Rnd[] < 0.5 ? Tails : Heads';
BEFOREEND FlipCoin GENERATE 1 CoinToss; /This is the important statement
/ The next statement will display either "Tails Tails" or "Heads Heads"
BEFOREEND FlipCoin PRINT StdOutput "%s %s\n" CoinToss Value[[Link]];
BEFOREEND FlipCoin CALL Collect[pCoinStats,[Link]];

SIMULATEUNTIL [Link]==100; / Run for 100 coin tosses


REPORT;

How the example works: When used in an expression, a subtype (e.g., Tails) or a collector (e.g.,
CoinStats) returns a pointer to itself. Hence, when Tails or Heads is ASSIGNed to CoinToss, the
savevalue CoinToss actually contains a pointer to either the subtype Tails or the subtype Heads.
Thus, GENERATE 1 CoinToss is equivalent to GENERATE 1 Tails, or GENERATE 1 Heads.

Global Variables based on the *.Obj Selector


By design, when Savevalues and TimeWeightedCollectors are used in an expression, they do not
return a pointer to themselves, but return the numeric value that they contain. Thus, there is no
direct way to store their address in another Savevalue or Array.

To get around this behavior, Stroboscope defines the following two global variables that return
“the address of” (or “a pointer to”) the Savevalue or TimeWeigthedCollector:

[Link] and [Link]

In the above example, the function Value[[Link]] takes as argument the address
[Link] and returns the value stored at the address of the savevalue CoinToss, which is a
pointer to the subtype Tails (or Heads). The function Value[CoinToss] would try to use the
subtype (“Tails” or “Heads”) as an address (a pointer to memory) and would result in an error.

P.G. Ioannou & J.C. Martinez - 26 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

The Value[.] Function:


As illustrated in the coin-flipping example above, indirect addressing, i.e., the ability to store the
address of one object (such as a subtype) into another object (such as a savevalue), is useful for
generating resources during simulation runtime.

However, simple indirect addressing of this type cannot be used to return the value (as opposed
to the address) of the second object.

The function Value[Savevalue] addresses this problem. It returns the actual value (rather than
the address in RAM) of the object pointed to by the Savevalue. The function can be applied only
when Savevalue holds "the address to an object" (i.e., "a pointer"). Thus,
[Link] is equivalent to &X in C++
Value[Y] is equivalent to *Y in C++
Example:

SAVEVALUE aSV 100;


DISPLAY aSV "-" [Link] "-" Value[[Link]]; / This will display "100-aSV-100"

In general, the following are equivalent:

Value[[Link]] = SaveValue = contents of SaveValue = number or pointer

Thus, in the examples above, the following are equivalent:

Value[[Link]] = CoinToss = { Tails | Heads } = pointer


Value[[Link]] = aSV = 100 = number

The need for and usefulness of the Value[Savevalue] function is illustrated by the following
example. Here, TmWc is a time-weighted collector whose value we would like to double. Here is
a straightforward model that does not use indirect addressing:

TMWGTCOLLECTOR TmWc 10;


COLLECT TmWc TmWc*2;
DISPLAY "The current value of collector " [Link] " is " TmWc;
/ This produces: The current value of collector TmWc is 20

In this model we store the address of TmWc in savevalue Sv and use indirect addressing to
double the value of TmWc without using the identifier TmWc.
TMWGTCOLLECTOR TmWc 10;
/ Without the Obj selector, Sv would store the number 10 and not the address of TmWc
SAVEVALUE Sv [Link];
/ The CALL stmt below assigns to TmWc its current value times 2.
/ Sv remains containing a pointer to TmWc.
/ Not using Value[.] would assign to TmWc, a value twice its address in memory!
CALL Assign[Sv,Value[Sv]*2];
DISPLAY "Savevalue Sv points to " Sv " whose current value is " Value[Sv];
/ This produces: Savevalue Sv points to TmWc whose current value is 20

P.G. Ioannou & J.C. Martinez - 27 - April 8, 2018


STROBOSCOPE QUICK REFERENCE GUIDE

ASSIGN vs. Assign[.]:


The following action statements look very similar, yet they are very different in what they do:

ASSIGN Savevalue Val;


CALL Assign[Savevalue,Val];

The statement ASSIGN stores Val in Savevalue. Thus, the content of Savevalue does change.
Moreover, Savevalue must be the actual name of a Savevalue. It cannot be a pointer to a
Savevalue.

In contrast, the function Assign[Savevalue,Val] stores Val in the object pointed to by Savevalue.
In this case, it is the object that changes. The content of Savevalue (i.e., the pointer to the object)
does not change. If Savevalue does not hold a pointer to an object, Stroboscope reports an error.

COLLECT vs. Collect[.]:


The following action statements also look similar, but again they are different:

COLLECT Collector Val;


CALL Collect[pCollector,Val];

The statement COLLECT adds another value Val to Collector. The name Collector must be the
actual name of a Collector. It cannot be a Savevalue or an Array element that holds a pointer to a
Collector.

The function Collect[pCollector,Val] adds another value Val to the Collector pointed to by
pCollector. In this case, pCollector must be either a Savevalue or an Array element that holds a
pointer to a Collector. For example:

Collect[Savevalue,Val]
Collect[Array[Index],Val]

Stroboscope Examples Using Advanced Features


The standard distribution package for Stroboscope includes several examples that are very useful
for understanding the language.

In particular, the example [Link] models the arrivals to a service facility of airplanes
whose subtype is random. This example illustrates how to use dereferencing (indirect
addressing) to generate resources (airplanes) of particular subtypes during simulation runtime.

The example file [Link] models an elevator in a building where all people waiting for
the elevator, irrespective of which floor they are currently on, are kept in one waiting queue.
This example can model a building with any number of floors by using dereferencing (indirect
addressing) to automate the creation of any number of collectors (to match the number of floors)
and to automate the collection of statistical data for the people at each floor who are waiting to
use the elevator to go up or down.

P.G. Ioannou & J.C. Martinez - 28 - April 8, 2018

You might also like