04-simulation with awesim
DESCRIPTION
Materi pak AmrilTRANSCRIPT
SIMULATION WITH AWESIM
Simulation
Methodology for conducting experimentsusing a mathematical model of a real system.
System
Experimentwith actual
system
Experimentwith a modelof the system
Physicalmodel
Mathematicalmodel
Analyticalsolution
Simulation
Deterministic Stochastic
Simple
Complex
Spreadsheets
Queuing Systems
Simulation
Discrete Event Digital Simulation with SLAM II
Visual SLAM II is a graphical computer languagethat modelers use to describe systems and processes.
The power of SLAM II lies not in its ability todocument but in its ability to describe how thedocumented system behaves.
The Network
There are three basic components to all SLAM II networks
1. Entities are units transformed by the system over time. Entities are not part of, but move through, the network.
2. Nodes are network functions that change the state of thesystem. Networks are constructed from several differentkinds of nodes. Each type of node performs a uniquefunction.
3. Arcs are network elements that control the routing and
service of entities. Nodes are connected to one another byarcs (also called activities).
SLAM II models are executed within an environment called AweSim.
The Network
The Entity
Simulation models are built from the perspective of an entity (e.g., the customer).
It is helpful if during network construction the modeler is able to think like an entity.
All entities that flow through a specific network need not be identical.
SLAM II provides each entity with three sets of attributes
Variable Name DefinitionATRIB[I] Real Attribute I of a current entity. Max I defined on
LIMITS control statement.LTRIB[I] Integer Attribute I of a current entity. Max I defined on
LIMITS control statement.STRIB[I] String Attribute I of a current entity. Max I defined on
LIMITS control statement.
The Control Statements
Control statements are required by any SLAM II model executed within theAweSim environment.
GEN,”JENSEN”,”FUN WITH QUEUES”,8/1/2002,1,YES,YES;LIMITS,1,3,4,5,8,2,50;NETWORK,READ;INIT,0,1000,NO;FIN;
The CREATE Node
Input Format: CREATE,TBC,TF,MV,MC,M;
Input Field Options DefaultTBC Time Between Creations infinity
Non-negative constant, SLAM II variableor SLAM II random variable
TF Time of First Creation 0Constant
MV Marking Variable noneSLAM II variable
MC Maximum Creations 10 millionPositive integer
M Maximum Emanating Activities infinityPositive integer
MV
MC
MTF
TBC
2.5
0.0
INF1
Expon(3)
Expon(5)
120
2Atrib[1]
The QUEUE Node
Input Format: QUEUE,IFL,IQ,QC,BLOCK or BALK(NLBL),{SLBL,repeats};
Input Field Options DefaultIFL Integer File Number error
Between 1 and MFIL or ATRIB(I)=J,KIQ Initial Queue Length 0
Non-negative integer QC Queue Capacity infinity
Non-negative integer greater than or equal to IQBLOCK or Block or Balk Incoming Entities noneBALK (NLBL) Block or balk to node labeled NLBLSLBLs Select or Match Labels none
I Q
Q C
I F L
The QUEUE Node
0
INF1
0
51
Hold_A_Cust
Out
0
51
0
51
The TE RM INA TE Node
Input Format: TERM INATE,TC;
Input Field Options DefaultTC Term inat ion Count 10 million
Posit ive integer
The G OON Node
.
Input Format: GOON ,M ;
Input Field Options DefaultM M aximum E manating A ctivities infinity
Positive integer
T C
T CM
M
The TE RM INA TE Node
1
3
INF
1002
The ACTIVITY
Input Format: ACTIVITY,A,DUR,PROB,NLBL,N,ID;
Input Field Options DefaultN Number Of Servers 1
Positive integersA Activity Number none
Positive integerDUR Duration 0
Constant, SLAM II variable, SLAM II randomvariable or simple expression
PROB Probability 1 Constant, SLAM II variable or SLAM II random variable. Must be between 0 and 1.
NLBL Node Label next node The label of the end node of the activity
ID Identifying Name blankFirst 12 characters are significant
DUR , PROB
AN
Too_bigRnorm[12,2] , atrib[1] > 5
1
Atrib[3]<=10 Too_small
1
0
INF2
Expon(12)
3 1Exit
Expressions
Expressions are used to state mathematical relationships. SLAM IIexpressions are logical groupings of parentheses, operators, global functions,random functions, global variables, and entity variables.
Operators
used by most expressions to perform some type of inquiry, assignment ormanipulation. Algebraic and conditional operators are both provided.
Commonly used algebraic operators include: multiplication (*), division (/), modulus (%), addition (+), subtraction (-)
Commonly used conditional operators include:less than (<), less than or equal (<=), greater than (>), greater than or equal(>=), equal (==), not equal (!=), logical AND (&&), logical OR (||)
Expressions
SLAM II entity variables
ATRIB[I] Real Attribute I of a current entity *
LTRIB[I] Integer Attribute I of a current entity *
STRIB[I] String Attribute I of a current entity *
ENUM Integer identifier of current entity
* Maximum I must be identified on LIMITS statement
Note that these two statements perform different functions:
Atrib[1] = 12 is an assignment of 12 to the variable Atrib [1]
Atrib[1] = = 12 asks if the current value of Atrib[1] is 12
Translate the following Atrib[5] >= Atrib[8]
Atrib[1] < 10 && Atrib[2] > 14
Atrib[3] => Atrib[5] * 7 – Atrib[3]
Atrib[2] < 10 && Atrib[2] > 20
Ltrib[2] = Atrib[3] / 7
A few important SLAM II functions
MAX(VAL1,VAL2) Returns the larger of VAL1 and VAL2
MIN(VAL1,VAL2) Returns the smaller of VAL1 and VAL2
NNQ(I) Returns the number of entities in File I
PROB(P) Returns true if random number between 0.0 and 1.0 is less than P
EXPON(XMN,IS) Returns a random number selected from pseudo-random number stream IS shaped from an exponential distribution with mean XMN.
RNORM(XMN,STD,IS) Returns a random number selected from pseudo-random number stream IS shaped from a normal distribution with mean XMNand standard deviation STD.
The ASSIGN Node
Input Format: ASSIGN,{{VAR,value},repeats},M;
Input Field Options DefaultVAR Variable error
SLAM II Variables. For example: Atrib(index), SS(index), DD(index), XX(index),STOPA, or II, where index is a positive integer or II, or ARRAY(I,J) where I, J, may be positive integers, II, Atrib(index), or XX(index).
Value An Arithmetic Expression errorMay contain constants, SLAM II variables or SLAM II random variables. Up to 10 operations
may be performed in each expression. Parentheses are allowed only to denote subscripts.
M Maximum Emanating Activities infinityPositive integer
VAR = Value
M
The ASSIGN Node
Atrib[1]=121
2Atrib[1]=expon(3)Atrib(2)=atrib[1]+50XX[1]=xx[1]+1Customer_traits
The COLCT Node
Input Format: COLCT,N,VALUE,ID,NCEL/HLOW/HWID,M;
Input Field Options DefaultN Statistics Integer error
Positive integerVALUE Variable Value Collected error
Records the value of a SLAM II variable ID Identifying Label
Maximum of 16 characters beginning blankswith an alphabetic character
NCEL Number of Histogram Cells nonePositive integer
HLOW Lower Limit on First Cell 0.0Constant
HWID Cell Width 1.0Positive constant
M Maximum Emanating Activities infinityPositive integer
Atrib[1] 1
Tnow- Atrib[1] 1“system_time”
10/0/100
Data_collection1
Expressions
Expressions are used to state mathematical relationships. SLAM IIexpressions are logical groupings of parentheses, operators, global functions,random functions, global variables, and entity variables.
Operators
used by most expressions to perform some type of inquiry, assignment ormanipulation. Algebraic and conditional operators are both provided.
Commonly used algebraic operators include: multiplication (*), division (/), modulus (%), addition (+), subtraction (-)
Commonly used conditional operators include:less than (<), less than or equal (<=), greater than (>), greater than or equal(>=), equal (==), not equal (!=), logical AND (&&), logical OR (||)
Expressions
Functionsbuilt-in operations that perform different kinds of tasks or assignments on AweSimvariables. Each function uses a very a specific syntax. Intrinsic Function DefinitionFunction ABS(RVAL) Absolute value of RVAL
FMOD(RV1,RV2) Returns remainder of RV1 / RV2INT(RVAL) Truncate RVAL and return integerLOG(RVAL) Natural logarithm of valueLOG10(RVAL) Common logarithm of valueMAX(VAL1,VAL2) Returns maximum of VAL1 and VAL2MIN(VAL1,VAL2) Returns minimum of VAL1 and VAL2MOD(IVAL,IBASE) Returns remainder of IVAL / IBASENINT(RVAL) Round RVAL to nearest integerPOW(RV1,RV2) Calculates RV1 raised to the power of RV2
Global Functions
NNACT(I) Number of active entities in Activity I at current time.NNCNT(I) The number of entities that have completed Activity I.NNQ(I) Number of entities in File I at current time.PROB(P) Only legal in condition field of ACTIVITY. Returns TRUE if
random number between 0.0 and 1.0 is less than P. AAAVG(I) Average utilization of Activity I since last clearing of stats.AAMAX(I) Maximum utilization of Activity I since last clearing of stats.AASTD(I) Standard dev of utilization of Activity I.AATLC(I) Time of the last change of the utilization of Activity I.FFAVG(I) Average length of File I since last clearing of statistics.FFAWT(I) Average waiting time of File I since last clearing of statistics.FFMAX(I) Maximum length of File I since last clearing of statistics.FFPRD(I) Time period of File I since last clearing of statistics.FFSTD(I) Standard dev of length of File I since last clearing of stats.FFTLC(I) Time of last change of length of File I
0
INF2
0
INF4
1, N
NQ(2)<NNQ(4)
0
INF2
0
INF4
1
, FFAWT(2)<FFAWT(4)
Random Functions
EXPON(XMN,IS) Exponential distribution with mean XMN usingrandom number stream IS.
UNFRM(ULO,UHI,IS) Uniform distribution in the interval ULO to UHIWEIBL(BETA,ALPHA,IS) Weibull distribution with scale parameter BETA
and shape parameter ALPHATRIAG(XLO,XMODE,XHI,IS) Triangular distribution in the interval XLO to
XHI with mode XMODE RNORM(XMN,STD,IS) Normal distribution with mean XMN and
standard deviation STDRLOGN(XMN,STD,IS) Lognormal distribution with mean XMN and
standard deviation STDERLNG(EMN,XK,IS) Erlang distribution which is the sum of XK
exponential samples each with mean EMNGAMA(BETA,ALPHA,IS) Gamma distribution with parameters BETA and
ALPHABETA(THETA,PHI,IS) Beta distribution with parameters THETA and
PHI NPSSN(XMN,IS) Poisson distribution with mean XMNDPROBN(IRCUM,IRVAL,IS) Probability mass function where the
cumulative probabilities are in row IRCUM ofARRAY and the sample values are in rowIRVAL of ARRAY
Random Functions
Global Variables(read & write) XX[I] Real system or global vector.
LL[I] Integer system or global vector. SZ[I] String system or global vector. II An integer global variableARRAY[I,J] System or Global Array - defined
on an ARRAY control.MSTOP May be set to -1 to stop simulation.
(read only) NNRUN Number of current simulation run.MATRIB Largest legal ATRIB index as
defined on LIMITS control.NNRNS Number of runs as defined on GEN
control.SCENARIO String containing the name of the
current scenario.TNOW Current simulation time.TTBEG Simulation start time as defined on
INITIALIZE control.TTFIN Simulation end time as defined on
INITIALIZE control.
Entity Variables
ATRIB[I] Real Attribute I of a current entity. Max I defined on LIMITS.
LTRIB[I] Integer Attribute I of a current entity. Max I defined on LIMITS.
STRIB[I] String Attribute I of a current entity. Max I defined on LIMITS.
ENUM Read-only unique integer identifier ofcurrent entity.
Entity Variables
Control Statements
The FIN statement denotes the end to all AweSim input statements. All remaining runswill be executed without further control data input by AweSim. The FIN statement has nofields.
The GEN statement is usually the first statement in a set of AweSim inputs. It providesgeneral information identifying the model, the number of executions, and certain globalflags.
Input Field Description DefaultName Analyst's name string. noneProject Project name string. noneDate Identifying date string. noneNumber of runs Number of runs to be made. 1Execution YES to attempt execution YES
NO to stop after input processingWarning YES to warn of destroyed entities YES
NO to ignore destroyed entitiesMax Error Number of errors before simulation is halted. 1
The INITIALIZE statement is used to specify the beginning and ending times for asimulation and to reset initialization options for clearing statistics.
Input Field Description DefaultTTBEG Beginning time of a run. 0.0TTEND Ending time of a run. . INFClear? YES to clear statistical arrays between runs. YES
NO otherwise.NCCLR The first collect variable does not apply
Control Statements
The LIMITS statement is used to define the size of global variable arrays and the number of attributesdefined for all entities. The LIMITS statement must precede any use of the global arrays.
Input Field Description DefaultMax XX The maximum index defined for the XX global array -1 (no XX)Max LL The maximum index defined for the LL global array. -1 (no LL)Max SZ The maximum index defined for the SZ global array. -1 (no SZ)Max ATRIB The maximum index defined for the ATRIB array. -1 (noATRIB)Max LTRIB The maximum index defined for the LTRIB array. -1 (no LTRIB)Max STRIB The maximum index defined for the STRIB array. -1 (no STRIB)Max Entries Maximum number of entries expected in all files at any INF
one time. If more entries are actually filed, a fatal execution error (file storage space exceeded) will result.
The EQUIVALENCE statement is used to assign names to AweSim variables and random variables inorder to make a model more readable and facilitate changes in the model.
Input Field Description DefaultSymbol A character string beginning with an alphabetic error
character. Must be a constant and may not contain spaces.Equals Any string that will be substituted for the Symbol. error
The NETWORK statement is used to denote the use of a network description. This statement may alsobe used to specify the saving or reloading of a decoded network description. Input processing may take asignificant amount of time for large models, and it is convenient to bypass this processing when thenetwork does not change from run to run.
Input Field Description DefaultOption READ to read the network description attached to READ
the current scenario. SAVE to write out the decoded network. LOAD to read in a decoded network.
File The name of the external file to save the decoded error if SAVEnetwork to or to load the decoded network from. or LOADMust be a constant string.
The AWAIT Node
Input Format:AWAIT,IFL{{RESorGATE,UR},repeats},RULE,QC,FULLCOND,M;
Input Field Options DefaultIFL Integer File Number first IFL in
Expression which evaluates between 1 and the listnumber of files.
RESorGATE Name previously defined on a RESOURCE errorstatement or a GATE statement or expression that evaluates to a resource or gate number.
UR Units Required 1Positive SLAM II variable, SLAM II random variable or positive integer
RULE Resource Allocation Rule AllALL if all resources are required ONE(expresion) if the first available resource should be allocated.
QC Queue Capacity infinityPositive integer
FULLCOND Block or Balk Incoming Entities noneBlock or balk to node labeled NLBL
M Maximum Emanating Activities infinityPositive integer
MIFL
QC
RULERESorGATE,URrepeats
1
INF
ALLworker, 2 1
4
INF
ALLworker, 2pallet, 1
1
2
INF
ONE (atrib[1])worker, 2pallet, 1
1
2
2
ONE (atrib[1])workerA, 1 1
3
INF
ALLworkerB, 1 1
The FREE Node
Input Format: FREE,{{RES,UF},repeats},M;
Input Field Options DefaultRES Resource Name error
Previously defined on a resource statement or expression that translates to a resource number.
UF Units to Free 1Positive integer, SLAM II variable or SLAM II random variable. Real values are truncated.
M Maximum Emanating Activities infinityPositive integer
MRES , UF
The FREE Node
1
INF
ALLWorkerA, 1WorkerB, 2
1 WorkerB1
110
Free10
WorkerA1 1
10 WorkerB1
1
Free
The RESOURCE Block
Input Format: RESOURCE,NUM,RLBL,CAP,{IFL,repeats};
Input Field Options DefaultNUM Integer Resource Type next sequentialRLBL Resource Name error
A string of alpha/numeric characters. CAP Initial Capacity 1
Non-negative integerIFLs AWAIT node files error
Integer between 1 and MFIL
NUM RLBL CAP IFL1 IFL2
The RESOURCE Block
1 Work 2 5 6
2 Machine 3 6 7
6
INF
ALLwork, 1machine, 1
1
5
INF
ALLwork, 2 1
7
INF
ONE (atrib[1])machine, 1 1
1INF
ALLWork,1 1
1 Work 1 1
Expon(10) Work 1 1
Segment 1
0
INF1
Expon(10)
Segment 2
What are the functional differences between these two segments?
0
INF1
Expon(10)
ASSERT(Atrib[2],1,4)INF
0 Expon(10)
1 ASSERT(Atrib[2],1,4)OUT
1 1OUT
0
INF2
Expon(10)
1 2OUT
0
INF3
Expon(10)
1 3OUT
0
INF4
Expon(10)
1 4OUT
Note that variables can be used as references into file numbers