Department of Computer Science and Engineering

Computer Science 177:  Simulation and Modeling

Winter 2016

Course Information

Sample Midterms and Exams

Supplementary Lecture Notes

These notes describe the development of a "gas station" model as a detailed example of an event-driven simulation program. Beware that this example program is written in an obscure (but vastly underappreciated!) programming language called Turing. However, this same "gas station" program was later translated into several other languages that you may be more familiar with, namely:
Here is an online table of critical points for the Student's t-distribution and Standard Normal distribution. It has the same data as Table T.1 in our textbook except for simplifying the notation in the row and column headings.

Here is an online table of critical points for the Chi-Squared distribution. It has the same data as Table T.2 in our textbook except the column headings are inverted. Where our textbook labels each column by the area under the curve to the left of the critical point, this online table labels each column by the area to the right of the critical point.
These notes provide some programming details on how to generate Q-Q Plots, including the case where the theoretical distribution is discrete (which the textbook claims is not possible). Two examples are provided to show how the technique can be applied to real empirical data.

Information about Programming with CSIM

CSIM is an extension to C++ (or to C, since there are two versions available) with special features to make it easy to write simulation programs, including the generation of random variables with many commonly used distributions and a variety of built-in measurement constructs. Unlike "conventional" methods for programming an event driven simulation model (i.e, the time-driven or event-driven program structures) CSIM models rely heavily on concurrent programming techniques (similar to what you may have seen in CS153 and/or CS160), which in the simulation literature is known as the process-interaction  method for constructing a simulation model. What this means to you is that you must write a self-contained "program" (more properly a "process" or "thread") to describe the behavior of a single entity. The combined behavior of the simulation model is obtained by the magic of concurrent execution: we assume that each of the active entities are executing their respective "programs" concurrently, using the simulation clock and/or various inter-process communications programming constructs (such as signal/wait, mutual exclusion, etc) to coordinate their activities.
The complete CSIM reference manual is available online at the Mesquite Software website here.
This information has been updated following the installation of CSIM-19 in April 2003. The CSIM-19 installation package comes with many small example programs to illustrate the use of different language features. On the CS Department server "bass", they can be accessed through the directories:
/usr/csshare/pkgs/csim_cpp-19.0/examples  For C++ versions of the example CSIM programs
/usr/csshare/pkgs/csim_c-19.0/examples For C versions of the example CSIM programs
CSIM/C++ programs can be compiled on the local CS department computers with the following one-line command or, if you prefer, a Makefile set up for the airport shuttle example below.

Here is a discussion about some basic CSIM program features, using a trivial program that prints a series of "hello world" messages on the standard output.
Here is a CSIM program that simulates the shuttle bus to connect the airport terminal buildings with an offsite rental car center.
Here is a modification that uses mailboxes instead of events to control boarding.

Here I've written two versions (here and there) of a small CSIM program about a group of processes who compete for control of a few "podiums" (represented by a facility set), where they can give a short speech (represented by printing a message on the std output). I purposely chose all times to be integer valued, so multiple processes often try to reserve the same facility "simultaneously", and thus show that the "winner" of such a competition is unpredictable. The second version of the program shows the effect of checking the status of the facility (which never causes your process to be suspended) before trying to reserve it (which will suspend execution of your process if it is occupied).