CS245 - CS II Chapter 8 - Simulation

8.1 Reasons for Simulation

Simulation - fake or give the appearance of something else.

Forecasting or Predicting the Future
Time Compression is necessary when forecasting or predicting the future. It is equivalent to speeding up the clock.

Use a model to represent reality.

Predictions are only as good as the model which is used in the simulations!

Simulation of the Inaccessible or Impossible
ex. Oklahoma Bombing Simulation
Controlling Experimentation and Testing
Testing the simulated model of a complicated system is sometimes more feasible than testing the real thing. (Ex. Boeing's design of the 757)

Education and Training
Simulations allow greater flexibility in education and training.

List of applications - Figure 8.2 (pg. 208)

8.2 Models of Systems

model - something which imitates or gives the appearance of a system.
Models of continuous systems have quantities which vary smoothly or in a continuous manner.
Models of discrete systems have quantities which vary in steps or jumps.
Predictable systems have models which predict exactly what will happen.
Probabilistic systems have models which contain unpredictable features.
Systems or models which feed results back to the input are referred to as feedback systems.

8.3 Monopoly Game Simulation

continuous or discrete?
Predictable or probabilistic?
Feedback system?

Activities
toss dice & move game pieces
allow purchases (real estate, houses, hotels)
draw card (Chance / Community Chest)
roll again if doubles
go to jail if 3rd doubles
collect $200 if pass GO
check for rent payment
allow mortgaging
jet out of jail (roll doubles / after 3rd try)
go to jail from GOTO JAIL square
pay tax (luxury / income)

Figure 8.4 - The flow of play showing getting out of jail

Figure 8.5 - Probability of landing on each square (Illinois - .0355236)

Determine rate of return vs. capital investment (Fig. 8.7 & Fig. 8.8)

Developing a Winning Strategy

Peasant Strategy - assumes small amounts of money will be invested for development
Orange monopoly, Blue monopoly and Railroads; invest small amounts early in the game

Tycoon Strategy - assumes large amounts of investment capital will be available
Green monopoly (highest return on investment), delay and block investment until sufficient funds are available

8.4 Balance of the Planet: A Computer Simulation

Playing the Game
player - High Commissioner of the Environment
1990-2035
Positive Points and Negative Points
each yield CAUSE and EFFECTs
e.g. Skin Cancer Points CAUSED by UV Light CAUSED by CFC Production
can be decreased by an increase in CFC Tax

Underlying Principles of the Game
has a very complex system of mathematics equations governing the interactions

Various Biases and Modifying the Simulation
Q: Should allowing more widespread use of pesticides be considered good or bad?
Can adjust coefficients in equations

The game of LIFE by John Conway ­ a simulation of bacterial life
(\\JARING\CS245\Life2.BAS - requires a BASIC interpreter/compiler)

The population increases and decreases according to fixed rules which affect the birth and death of individual bacterium. A rectangular grid (2­dimensional matrix) will be shown on the screen.
Each cell in the grid can contain a bacterium or be empty. Each cell has 8 neighbors except that cells on the boundary have less than 8 neighbors. The existence of cells from one generation to the next is determined by the following rules:
1. A bacteria with 2 or 3 neighbors survives from one generation to the next. A bacterium with fewer neighbors dies of isolation. One with more neighbors dies of overcrowding.
2. An empty cell spawns a bacteria if it has exactly three neighboring cells which contain bacteria.

MICMAC by John Donaldson - a simulation of the micro-programming level of a computer (\\JARING\CS245\MICMAC)

The MicMac Simulator is a program written for the IBM PC to simulate the Mic-1 and Mac-1 machines as described in Tanenbaum's Structured Computer Organization. It can be used to test microprograms written for the Mic-1 machine and programs written for the Mac-1 machine.

To start the simulator, enter the command "micmac" to DOS. When the simulation begins, the current contents of all registers will be displayed on the screen. These values will be continuously updated as the simulation runs. At the bottom of the screen, line 24 is used to enter commands to the simulator, and line 25 is used for error messages and the output of some commands. The user may enter commands on the command line to modify the machine's registers and memory, execute microinstructions, etc. The simulation proceeds until the command "ex" is entered, and control returns to DOS.

The Command Language

Each command entered on the command line consists of a two-letter operation specifier and 0 or more operands. The operands are either register names (PC, AC, etc.), file names, or unsigned numbers.

8.5 Design and Implementation of Computer Simulations

  1. Determine that the problem requires simulation. The critical factors are the cost, the feasibility of conducting real-world experiments, and the possibility of mathematical analysis.
  2. Build a model to solve the problem.
  3. Write a computer program that converts the model into an operating simulation program.
  4. Use the computer simulation program as an experimental device to resolve the problem.
A model is said to be verified or validated when it is proven to be a reasonably accurate representation of the system being simulated

Simulation Languages and Modeling Systems
NAME TYPE EXAMPLE
Advanced Continuous Simulation Language Continuous Electrical circuit analysis, missle & aircraft simulation
General Purpose System Simulator Discrete Supermarket checkout system; traffic light system
Simscript Discrete Auto assembly line, sonar
Simula Discrete Job shop operation, national economy


OOPs simulation modeling system: SimCity, SimAnt
Extend: predator/prey problem; bank teller problem

8.6 Virtual Reality

virtual reality / artificial reality - "simulation where user has a "real" view into a world that only exists inside the computer
Neuromancer - William Gibson cyberspace

Fundamentals of Virtual Reality
requires a 3-D viewing system with sensors that detect head motion & data gloves

Uses of Virtual Reality
virtual kitchens
virtual sports (golf & skiing)
virtual representation of Mars
virtual images of fetus

Virtual Reality and the Internet (VRML)

Exercises (due Sept. 26, 1997)

Exercises (due Oct. 3, 1997)