Chapter 20 - Tying Up Loose Ends

The Complete Environment and Where to Go From Here

The system facilities of SIMULA

The system facilities of SIMULA which are always present are attributes of class Environment and Environment class BasicIO. In addition, the attributes of class SIMSET and SIMSET class SIMULATION, which are declared in Environment, can be made available by using one of these as a prefix. We have considered all the attributes of SIMSET (chapter 17) and SIMULATION (chapter 19) and most of the attributes of BasicIO (chapter 7 and chapter 15). The first part of this chapter completes BasicIO and gives a complete list of the contents of Environment, only some of which have been covered so far.

The contents of both BasicIO and Environment have been enlarged considerably in recent years. It is likely that further extensions, such as new subclasses of File, will be made in the next year or two. The lists given here cover the attributes defined in the 1985 SIMULA Standard.

It is important to check the documentation for the SIMULA system that you are using against the lists given here. Some features may be missing and extra ones may be present. The preceding chapters have tried, with the exceptions of ByteFile and some parts of DirectFile which are new in this standard, to use only the most generally available features in examples.

Terminate_Program - the missing part of BasicIO

As well as the File features described in chapter 7 and chapter 15, BasicIO contains a system procedure called Terminate_Program. This has no parameters.

When Terminate_Program is called the program ends as if a goto had been made to the final end of the program. Where the program is prefixed, the final end refers to the end of the prefixing class body.

Where the program is prefixed by a class containing an inner statement, this is the only way to guarantee that it stops immediately, except by forcing a deliberate runtime error.

The complete environment

Parts of the environment have been described earlier, some in mathematical appendices. The following is a complete list of the attributes of class Environment, to allow easy reference. Where a description has already been given, only a reference to this is given. Where it is mentioned for the first time, a brief definition is supplied.

Basic arithmetic operations

integer procedure Mod(I,J); integer I,J,;
Returns the arithmetic modulo of I with respect to J, i.e.
       zero if I=J
       I-(I//J)*J if I and J have the same sign
       J+I-(I//J)*J if I and J have different signs.
integer procedure Rem (I,J) integer I,J;
Returns the remainder of I integer divided by J, i.e.
       I-(I//J)*J.
type procedure Abs (I); type I;
Returns the absolute value of I, where I may be of any type and the result will be of the same type, i.e.
       if I>=0 then result =I
       if I<0 then result =-I.
integer procedure Sign (I); type I;
Returns zero if the parameter, which may be of any type, is zero, plus one if it is positive and minus one if it is negative.
integer procedure Entier (R); real R;
Returns the integer value nearest to and less than or equal to R, i.e. 1.8 gives 1, -1.8 gives -2.
(long) real procedure AddEpsilon (R); (long) real R;
Returns the nearest real or long real value greater than the real or long real R, that the particular system is capable of distinguishing. See appendices A and B.
(long) real procedure SubEpsilon (R); (long) real R;
Returns the nearest real or long real value less than the real or long real R, that the particular system is capable of distinguishing. See appendix A and appendix B.

Basic text and character handling

The following are described in chapter 5:

text procedure Copy (T); text T;
text procedure Blanks (L); integer L;

The following are described in chapter 12:

integer procedure Rank (C); character C;
integer procedure ISORank (C); character C;
character procedure Char (I); integer I;
character procedure ISOChar (I); integer I;
Boolean procedure Digit (C); character C;
Boolean procedure Letter (C); character C;

The following are described in appendix B:

character procedure LowTen (C); character C;
Returns the current floating poit exponent marker and resets it to C.
character procedure DecimalMark (C); character C;
Returns the current decimal point character in real texts and resets it to C.

There are two further text handling procedures.

text procedure UpCase(T); text T;
Converts all characters which are letters in T to upper case, leaving T with its Pos at the end of the text frame. Returns a new reference to the text frame of T, with its Pos at the start of the frame.
text procedure LowCase(T); text T;
Converts all characters in T which are letters to lower case, leaving the Pos of T at the end of the text frame. Returns a new reference to the text frame of T, with its Pos at the start of the frame.

Mathematical functions

SIMULA posses a fairly extensive library of mathematical functions. Most are assumed here to be self-explanatory. All may be passed either real or long real parameters. The values returned match the type of the parameters.

[long] real procedure SqRt(R); [long] real R;
Square root;
[long] real procedure Sin(R); [long] real R;
Sine;
[long] real procedure Cos(R); [long] real R;
Cosine;
[long] real procedure Tan(R); [long] real R;
Tangent;
[long] real procedure CoTan(R); [long] real R;
Cotangent;
[long] real procedure ArcSin(R); [long] real R;
Arcsine;
[long] real procedure ArcCos(R); [long] real R;
Arccosine;
[long] real procedure ArcTan(R); [long] real R;
Arctangent;
[long] real procedure ArcTan2(Y,X); [long] real Y,X;
ArcTAn2 returns a value in the range -Pi to +Pi. If Y is positive, the value returned is positive. If Y is negative the value returned is negative. If Y is zero, the value returned is also zero if X is positive or Pi if X is negative. If both X and Y are zero a runtime error error occurs. The value is generally the same as ArcTan(Y/X).
[long] real procedure SinH(R); [long] real R;
Hyberbolic Sine;
[long] real procedure CosH(R); [long] real R;
Hyperbolic Cosine;
[long] real procedure TanH(R); [long]real R;
Hyperbolic Tangent;
[long] real procedure LN(R); [long] real R;
! Natural logarithm;
[long] real procedure Log10(R); [long] real R;
Base 10 logarithm;
[long] real procedure Exp(R); [long] real R;
e to the power R;

Extremum functions

type procedure Max(V1, V2); type V1, V2;
type procedure Min(V1, V2); type V1, V2;
These return respectively the larger or smaller of the values of their two parameters. Legal types are character, text, long real, real, short integer and integer. The type returned matches the evaluated parameters, following the rules given for types of evaluated expressions in chapter 3.

Environmental constants

Environmental constants allow programs to find out information about the particular SIMULA system on which they are running. This can be of great help in writing portable programs.

The first set reveal the range of arithmetic values and internal character values.

integer MaxRank
is the highest internal representation of a character using the normal collating sequence of the system.
integer MaxInt
is the longest value that can be held in an integer on the system.
integer MinInt
is the smallest negative value that can be held in an integer on the system.
long real MaxLongReal
is the largest value that can be held in a long real on the system.
long real MinLongReal
is the smallest negative value that can be held in a long real on the system.
real MaxReal
is the largest value that can be held in a real on the system.
real MinReal
is the smallest negative value that can be held in a real on the system.

The others give information recorded by the compiler.

text procedure SIMULAId
returns a text which identifies the current SIMULA system, the installation on which it is running and so on. For the details of what can be learned about a particular system, consult its documentation.
integer procedure SourceLine
returns the line number in the SIMULA source where it is called. User defined errors can be signalled by calling the following:
procedure Error (T); text T;
This causes the program to stop as if an error had occurred. The text T is printed as the runtime error message.

Array characteristics can be found from the following:

integer procedure UpperBound (A,I); type array A; integer I;
Returns the upper bound of dimension I in array A. A can be of any type.
integer procedure LowerBound (A,I); type array A; integer I;
Returns the lower bound of dimension I in array A. A can be of any type.

Date and time information are given by the following:

text procedure Date_Time;
Returns a text containing the current date and time in the form
YYYY-MM-DD HH.MM.SS.sss...
An example is 1985-11-26 08.39.23.00
long real procedure CPUTime;
Returns the number of processor seconds used so far by the program.
long real procedure ClockTime;
Returns the number of seconds since midnight.

Random numbers and drawing

There is an extensive library of random number generating functions. All use a basic drawing from a uniform distribution from 0 to 1. This drawing uses an integer seed, which is passed by name to the appropriate function. The variable U is always used to represent this seed in the following descriptions. The matching actual parameter must always be an integer variable, which is set to the desired seed value before the first call and is never, normally, assigned to again in the program.

The use of the negative value of a seed as the seed to a second series of drawings will produce an antithetic series of random numbers. For suitable sizes of seeds, consult the documentation for your system.

Boolean procedure Draw (A,U); name U; long real A; integer U;
Returns true or false. A is the probability that true will be returned.
integer procedure RandInt (A,B,U); name U; integer A,B,U;
Returns an integer in the range A to B with uniform probability.
long real procedure Uniform (A,B,U); name U; long real A,B; integer U;
Returns a long real in the range A to B, not including B, with uniform probability. A must be less than B.
long real procedure Normal (A,B,U); name U; long real A,B; integer U;
Returns a long real value normally distributed about mean A, with standard deviation B.
long real procedure NegExp (A,U); name U; long real A; integer U;
Returns a long real value from the negative exponential distribution with mean 1/A, defined by -LN(d/A), where d is a basic drawing.
integer procedure Poisson (A,U); name U; long real A; integer U;
Returns an integer value from the Poisson distribution with parameter A. If A is negative, the result is 0.
long real procedure Erlang (A,B,U); name U; long real A,B; integer U;
Returns a long real value from the Erlang distribution with mean 1/A and standard deviation 1/A*SqRt(B).
integer procedure Discrete (A,U); name U; long real array A; integer U;
A is a one dimensional long real array holding values corresponding to a step function. It is augmented by an extra value, corresponding to an imaginary element A(UpperBound(A,1)+1). This extra value is assumed to be 1. The step function is a cumulative distribution, rising from 0 to 1.

An integer in the range LowerBound(A,1) to UpperBound(A,1)+1 is returned. It is the lowest value of I such that A(I) is greater than some basic drawing.

long real procedure Linear (A,B,U); name U; long real array A,B; integer U;
Returns a long real value from a cumulative distribution function, F. This is found by a linear interpolation in a non-equidistant table defined by A and B, such that A(I) = F(B(I)).

A and B must be one dimensional long real arrays and have equal numbers of elements. The first element of each must be 0 and the last 1.

integer procedure HistD (A,U); name U; long real array A; integer U;
A is a one dimensional long real array assumed to represent a histogram. A value in the range LowerBound(A,1) to UpperBound(A,1) is returned, according to the relative frequencies of the values in the histogram.

Finally there is one statistical reporting procedure:

procedure Histo (A,B,C,D); real array A,B; real C,D;
Updates a histogram defined by one dimensional real arrays A and B, according to observation C with weight D.

Formally, A(LowerBound(A,1)+I) is increased by D, where I is the smallest integer such that C<= B(Lowerbound(B,1)+I). A should normally be one element longer than B. If it is not the system reacts in any appropriate way.

The highest element of A corresponds to observations larger than all elements of B.

Going on with SIMULA

And so here we are. This book has covered most of what SIMULA contains. Any omissions have been of features which originated in Algol 60 and are now generally regarded as out of date. For those who wish to check for themselves, there are still plenty of Algol 60 text books available. What is more important is which way to go to develop the really powerful features unique to SIMULA.

Only a handful of text books have been written describing SIMULA. Several are not available in English. The only one that I can unreservedly recommend is SIMULA BEGIN (see bibliography) and even that is rather behind on the new developments in the language. What it does have is a marvellous feel for what is special about SIMULA.

For up to date information on the world of SIMULA users, the Association of SIMULA Users (ASU) publishes a quarterly newsletter, organises conferences and workshops, etc. They are also a pleasant, sociable bunch who are delighted to help newcomers.

Simulation with SIMULA

In some ways SIMULA's name gives a misleading impression. It is, as has been stressed, a general purpose language which suits the development of simulation packages uniquely well. It is not a simulation language. (Indeed, a group of us were driven at a recent SIMULA Standards Group meeting to propose that SIMULA should be seen as the acronym for SIMple Universal LAnguage.)

On the other hand SIMULA has been used very extensively in simulation work, particularly in dicrete event and combined simulation. When I proposed writing this book, some people expressed disappointment that it was not going to be about simulation in SIMULA. There are two answers to them. Firstly, maybe one day I will write such a book, but this is needed more urgently. Secondly, there already exist some excellent books on the subject. I would like to recommend two in particular.

Discrete Event Modelling on SIMULA, by Graham Birtwistle, describes both a rudimentary amount of SIMULA and how the DEMOS simulation package can be used to extend SIMULA and make discrete event simulation easy. The package is a joy to use and constitutes what class SIMULATION would be like if it were to be written today. To use it you have to buy the package, but it is a good investment. If you are interested, contact E.R.C.C. (see implementors list).

The Process View of SIMULATION, by Bill Franta, is a seminal work on this area. It outlines a general theory of simulation using a process based approach and shows how it could be implemented in SIMULA. Well worth reading, perhaps after some experience with DEMOS, but using only SIMULA.

The development of SIMULA

SIMULA has been fully standardised since it was first formulated, around 1968. From the start the name was trademarked and can only be applied to implementations meeting the standard. It is hoped to gain acceptance for the 1985 SIMULA Standard as an ISO standard.

This helps to guarantee that nearly all programs which run on one machine will run on any other which has a SIMULA system. It does not, however, mean the SIMULA is rigidly fixed. Extensions are made regularly to add to its power.

The guarding of the standard is the responsibility of the SIMULA Standards Group (SSG) which contains representatives of all the recognised implementations. Changes and additions have to be approved by this body.

Working with the SSG is the SIMULA Development Group (SDG), which is responsible for investigating new features and problems with existing features. It contains the SSG members plus other interested parties and is less formal than the SSG.

If you have suggestions for changes or would like to raise problems you have found which you think are due to bad design of SIMULA, you should write to the chairman of the SSG. If you want to become involved in this work yourself, you should write to the chairman of the SDG. Both can be contacted at the address given for the ASU.

Good luck

I hope you find this book as interesting to read as I did to write. I certainly learned a lot that I did not expect to. On the other hand, I hope reading it has not been as hard a task as writing it. The rest is up to you.