Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Simula
(section)
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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)