Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Simula
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Simulation === Simula includes a [[simulation]]<ref name="CommonBase"/>{{rp|14.2}} package for doing [[discrete event simulation]]s. This simulation package is based on Simula's object-oriented features and its [[coroutine]]<ref name="CommonBase"/>{{rp|9.2}} concept. Sam, Sally, and Andy are shopping for clothes. They must share one fitting room. Each one of them is browsing the store for about 12 minutes and then uses the fitting room exclusively for about three minutes, each following a normal distribution. A simulation of their fitting room experience is as follows: Simulation '''Begin''' '''Class''' FittingRoom; '''Begin''' '''Ref''' (Head) door; '''Boolean''' inUse; '''Procedure''' request; '''Begin''' '''If''' inUse '''Then''' '''Begin''' Wait (door); door.First.Out; '''End'''; inUse:= '''True'''; '''End'''; '''Procedure''' leave; '''Begin''' inUse:= '''False'''; '''Activate''' door.First; '''End'''; door:- '''New''' Head; '''End'''; '''Procedure''' report (message); '''Text''' message; '''Begin''' OutFix (Time, 2, 0); OutText (": " & message); OutImage; '''End'''; Process '''Class''' Person (pname); '''Text''' pname; '''Begin''' '''While''' '''True''' '''Do''' '''Begin''' Hold (Normal (12, 4, u)); report (pname & " is requesting the fitting room"); fittingroom1.request; report (pname & " has entered the fitting room"); Hold (Normal (3, 1, u)); fittingroom1.leave; report (pname & " has left the fitting room"); '''End'''; '''End'''; '''Integer''' u; '''Ref''' (FittingRoom) fittingRoom1; fittingRoom1:- '''New''' FittingRoom; '''Activate''' '''New''' Person ("Sam"); '''Activate''' '''New''' Person ("Sally"); '''Activate''' '''New''' Person ("Andy"); Hold (100); '''End'''; The main block is prefixed with <code>Simulation</code> for enabling simulation. The simulation package can be used on any block and simulations can even be nested when simulating someone doing simulations. The fitting room object uses a queue (<code>door</code>) for getting access to the fitting room. When someone requests the fitting room and it's in use they must wait in this queue (<code>Wait (door)</code>). When someone leaves the fitting room the first one (if any) is released from the queue (<code>'''Activate''' door.first</code>) and accordingly removed from the door queue (<code>door.First.Out</code>). Person is a subclass of <code>Process</code> and its activity is described using hold (time for browsing the store and time spent in the fitting room) and calls procedures in the fitting room object for requesting and leaving the fitting room. The main program creates all the objects and activates all the person objects to put them into the event queue. The main program holds for 100 minutes of simulated time before the program terminates.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Simula
(section)
Add topic