18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Discrete Simulation Concepts<br />

If the random number drawn is 0.95, SAMPLE = 42.6<br />

Random values defined as linear can only be real-valued. Interpolations are done in real<br />

arithmetic, and the accuracy is determined by the machine representation. Rounding is done in the<br />

above examples for illustration only.<br />

If the mode of random variables does not agree with the background mode, the mode must be specified<br />

in a define statement. This define statement may also be used to specify a random number<br />

stream other than the default stream (number 1). On some implementations, this stream number<br />

may be declared to be a variable, which must evaluate to the number of a valid stream, whenever<br />

used.<br />

Example:<br />

Define SAMPLE as a random attribute of an entity JOB. The values of SAMPLE are real. Sampling<br />

is done using linear interpolation and random stream 6.<br />

every JOB has a SAMPLE random linear variable<br />

define SAMPLE as a real, stream 6 variable<br />

Sampling is always automatic. That is, a random variable behaves as a right-hand function. Whenever<br />

a random variable appears, a routine that performs sampling is executed. <strong>SIMSCRIPT</strong> <strong>II.5</strong><br />

generates these routines using random number stream 1 unless otherwise specified.<br />

5.4.3 Programmer-Defined Random Variables<br />

If the you require a type of sampling other than step or linear, you must omit the words step or<br />

linear from the definition of the random variables and provide your own sampling function.<br />

Three system functions are provided for sampling (table 5-7). They correspond to the type of<br />

lookup previously described.<br />

Table 5-7. System Sampling Functions<br />

Function Mode Arguments Description<br />

istep.f integer v,e Returns a random sample from table v using stream<br />

e.<br />

lin.f real v,e Returns a random sample from table v using interpolation<br />

and stream e.<br />

rstep.f real v,e Returns a random sample from table v using stream<br />

e.<br />

Because of the special storage assigned to random variable sample values and probabilities, special<br />

input treatment is necessary. When a variable defined as random appears in a free-form read statement,<br />

the following occurs:<br />

1. Pairs of free-form data values are read until a mark.v character appears.<br />

221

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!