18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

remain clear of any explicit statements which might obscure the logic of the model. A statement of<br />

the form:<br />

tally compute list of name<br />

performs computations similar to those of the compute statement, but in a global manner, over<br />

time, rather than locally to an instance of its use. Each time the named variable changes value, appropriate<br />

actions are taken to collect the statistics requested in the compute list. Name may be the<br />

name of an unsubscripted global variable, unsubscripted system attribute, or an attribute of a temporary,<br />

permanent, or permanent compound entity. If name is an attribute of a permanent entity, as<br />

many variables are reserved to store the statistical counters as there are elements of name. If name<br />

is an attribute of a temporary entity, each entity record is generated with statistical counter-variable<br />

attributes. Name cannot be a function attribute, a random variable, or a dimensioned array.<br />

Some examples illustrate the use of the tally statement and the attributes and functions generated<br />

by it.<br />

1. Use of tally with an unsubscripted global variable:<br />

Preamble:<br />

preamble<br />

define TIME as a real variable<br />

.<br />

.<br />

tally MEAN.TIME as the mean,<br />

and VAR.TIME as the variance of TIME<br />

.<br />

.<br />

Preamble generates:<br />

(a) A statistics-gathering function routine, which is called whenever an assignment is<br />

made to TIME anywhere in the program. The function counts the number of times<br />

TIME changes value, and records the sum and sum of squares of the values of TIME.<br />

(b) Global variables [A.1, A.2, A.3] to record the number, sum, and<br />

sum.of.squares of TIME for the computations of mean and variance.<br />

(c) Functions MEAN.TIME and VAR.TIME which use the values of the global counters<br />

to compute mean and variance whenever they are referenced.<br />

The tally variables may be used in statements such as:<br />

print 1 line with MEAN.TIME AND VAR.TIME as follows<br />

MEAN = **.*** VARIANCE = ***.***<br />

if (VAR.TIME/MEAN.TIME) le TOLERANCE<br />

.<br />

.<br />

224

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

Saved successfully!

Ooh no, something went wrong!