The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of...

33
The Computer Continuum 11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows us to visualize worlds that might not exist outside of the computer.

Transcript of The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of...

Page 1: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-1

Chapter 11: Simulation: Modeling the

Physical World

Simulation is one of the most important uses of computers today. It allows us to visualize worlds

that might not exist outside of the computer.

Page 2: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-2

Simulation: Modeling the Physical World

In this chapter:

• Why do we need simulations?

• What is a model and how do they differ?

• How can the simulation game Monopoly be categorized?

• What can SimCity teach us?

• What do programmers consider when planning, designing, and implementing a simulation?

• Virtual reality, what are its uses?

• How can an electronic spreadsheet be used as a simulation tool?

Page 3: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-3

Reasons for Simulation

Simulation: A technique used to mimic or imitate some phenomenon in a way that represents the real situation in most of its details.• A physical or mathematical model is designed to behave like

the object or event of interest. – By manipulating and working with the model, a person

can: • Predict outcomes. • Better understand the model. • Experiment with the model.• Test the model. • Use the model for training purposes.

Page 4: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-4

Reasons for Simulation

Time compression must be possible in order to predict the future in some way.

– Presidential elections.

– Weather forecasting.

– National economic trends.

– Population growth.

• Predictions are only as good as the model used in the simulation!

Page 5: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-5

Reasons for Simulation

Simulation of the Inaccessible or Impossible• Many simulations are necessary because it is impossible to

gain knowledge any other way.

– Observing the collapse of a star.

– Reactions within a nuclear reactor.

– Genetic evolution.

– The weather on Venus.

– Recreation of the bomb blast that destroyed the Alfred P. Murrah Federal Building in Oklahoma City, Oklahoma.

Page 6: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-6

Reasons for Simulation

Based on the explosives investigation, a simulation of the bomb’s force was recreated.

Oklahoma Bombing

Simulation

Page 7: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-7

Reasons for Simulation

Experimentation and Testing• Testing the simulated model of a complicated system is

sometimes more feasible than testing the real thing.

– Experimentation on a new jet engine.

– Repeatedly crashing automobiles into cement barriers.

– Results from changing tax rates and interest rates on the US economy.

– Changing fertilizer compounds on corn crops.

Page 8: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-8

Reasons for Simulation

Testing guardrail designs using simulated car crashes.

Page 9: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-9

Reasons for Simulation

Education and Training• Offers greater flexibility than traditional education and

training.

• Can offer the benefit of years of experience to people learning some complex skill.

– Diagnostics in medicine.

– Flight training.

– Training a nuclear power plant technician.

– Managing salmon runs.

– Managing traffic patterns.

– Building and bridge construction.

Page 10: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-10

Reasons for Simulation

Simulated landing onto an aircraft carrier.

Page 11: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-11

Building a Model

Models, whether physical or computer-simulated, share general characteristics:• Continuous systems: Have quantities that vary smoothly or

in a continuous manner.

– Example: Simulated landing of a rocket on the moon has quantities in engine thrust, velocity, and deceleration. All these vary smoothly (don’t jump).

• Discrete systems: Have quantities that vary in steps or jumps.

– Example: Modeling the traffic flow at an intersection. The number of cars can be counted precisely. Can’t have half a car pass through the intersection.

Page 12: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-12

Building a Model

Models can also be characterized as predictable or probabilistic• Predictable systems: Have systems that predict exactly what

will happen.

– Example: Using the mathematical model of the solar system to predict exactly when an eclipse will happen.

• Probabilistic systems: Have models that contain unpredictable features.

– Example: Weather simulation programs combine multitudes of information from satellites and previously recorded data. Yet, weather systems have unpredictable features.

Page 13: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-13

Building a Model

Models can also be characterized as having feedback versus non-feedback features.• Feedback: A general term denoting the feeding back or

recycling of actions or results of a model to itself.– An automobile driver system is a feedback type of system:

• Driver tries to avoid an object in the road» A turn away from the object is started.» Driver’s eyes feed back information...

• If the turn is not sharp enough» Driver increases the turn» Driver’s eyes feed back information...

Page 14: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-14

Monopoly Game Simulation

Monopoly Simulation:• Probabilistic: Controlled by random toss of dice or

instructions given by randomly shuffled cards.

• Discrete: Dice or instructions both show exact number of steps to be taken.

• Feedback?

– If players are involved, then yes there is feedback in the system.

– If the system is defined not to include the players but only the dice tosses on the board, it does not have a feedback loop.

Page 15: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-15

Monopoly Game Simulation

Monopoly Simulation: How can computers be used to simulate systems?• A partial list of activities necessary to simulate the game of

Monopoly:– Toss dice.– Move game pieces.– Allow real estate, hotel and house purchases.– Draw Chance or Community Chest card if necessary.– Toss second or third time if necessary.– Go to jail if doubles on third toss.– Collect $200.00 upon passing GO.– Check for rent payment.– Keep records of each player’s assets (cash and real estate)...

Page 16: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-16

Monopoly Game Simulation

To understand the process of writing a program to play Monopoly, look at part of the problem of getting out of jail...

Start inJail

Count = 1

WaitTurn

WaitTurn

Out ofJail

Move #Shown

RollPay $50.00

Roll

Use Get out of Jailfree card

Is Count

>2?

Use Get out of Jailfree card

Pay $50.00

Doubles?

Yes

No No No

Yes Yes Yes

No

Page 17: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-17

Monopoly Game Simulation

The probabilities for landing on the various squares in Monopoly:

1 Mediterranean .0238252 16 St. James Place .0318117 31 Pacific .02995342 Community Chest .0210683 17 Community Chest .0272474 32 North Carolina .02934203 Baltic .0241763 18 Tennessee .0334833 33 Community Chest .02643924 Income Tax .0260343 19 New York .0333734 34 Pennsylvania .02792915 Reading Railroad .0332449 20 Free Parking .0335340 35 Short Line Rail. .02718716 Oriental .0253014 21 Kentucky .0310290 36 Chance .00968257 Chance .0096756 22 Chance .0124010 37 Park Place .02444478 Vermont .0259620 23 Indiana .0304690 38 Luxury Tax .02435729 Connecticut .0257326 24 Illinois .0355236 39 Boardwalk .029473410 Just Visiting .0253909 25 B&O Railroad .0343378 40 Go Jail Possibilities .034590411 St. Charles Place .0303370 26 Atlantic .0301120 J(1) Sent to Jail .044404912 Electric Co. .0310260 27 Ventnor .0298999 J(2) in Jail 2 Turns .037004113 States .0258042 28 Water Works .0314613 J(3) in Jail 3 Turns .030836814 Virginia .0287890 29 Marvin Gardens .028938515 Pennsylvania Rail .0312800 30 Go to Jail .0000000

Page 18: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-18

Monopoly Game Simulation

Calculating the return on investment, taking into account the probability of landing on that particular property:

120

100

80

60

40

20

0$1000 $2000

Page 19: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-19

SimCity: Simulation for City Planning

SimCity:• A game or simulation rich in details needed to do real city

planning.• Basic thesis: To build and run a city.• Building Cities: (Problem Solving)

– Zoning areas as Residential, Commercial or Industrial.– Building roads, rail systems, power and water facilities.– Taxing and appropriating funds.– Building police stations, fire stations, and hospitals.– Including educational institutions and libraries.– Adding zoos, parks and recreational areas.– Building marinas, airports, and seaports.

Page 20: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-20

SimCity: Simulation for City Planning

Choices of power plants in the year 2026.

Page 21: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-21

SimCity: Simulation for City Planning

Sims: The people who live in the simulation.• People will stay in a city if they feel safe, taxes are

reasonable, jobs are available, and services are provided.

City Planning must include replacement and repairs as needed.• Power plants wear out.

• Roads need repair.

• As cities grow, increasing water system demand grows.

• Money needs to be coming in for services to be provided!

Page 22: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-22

SimCity: Simulation for City Planning

The water system is “under the city”.

Page 23: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-23

Design and Implementationof Computer Simulations

Five basic tasks to be performed in setting up a computer simulation:1. Determine if the simulation is feasible.

– Cost and other alternatives must be examined first.

2. Create a model to mimic the real situation.

3. Write a computer program that is based on the model.

4. Validate and verify that the program correctly represents the real-world system.

– A model is verified or validated when it proves to be a reasonable representation of the system being simulated.

5. Experiment with the computer simulation to resolve the problem.

Page 24: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-24

Design and Implementationof Computer Simulations

Programming languages used to create simulations:• Can be written in any language including Visual BASIC,

Smalltalk, C++, Pascal, etc.

For complex simulations, several simulation programs have been developed.• Usually have a graphics orientation.

• One example is Extend:

– Library-based simulation program.

– Programmer can build libraries of icons that represent the behaviors of elements in the system being modeled.

Page 25: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-25

Design and Implementationof Computer Simulations

The classic predator/prey problem as modeled in Extend:

Page 26: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-26

Virtual Reality

Virtual Reality (Artificial reality): A situation in which an individual has a three-dimensional view into a world that doesn’t exist except in the computer.• Uses:

– Industry and military train people in the use of complex systems.

– Entertainment.

• Special equipment is necessary to experience the environment fabricated by the computer.

– Can include visual images, smells, and touch.

Page 27: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-27

Virtual Reality

Special equipment is necessary to experience the environment fabricated by the computer.• Can include smells, and touch.

• Can include visual images using a headset, goggles, or a special environment.

– Three approaches to this type of simulation:

• A computer creates a tiny video display in a headset.

• Special goggles are worn that will make 3D images appear.

• Create a room whose walls are video projections of scenes that are created alternately for the left eye, then the right eye.

Page 28: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-28

Virtual Reality

CAVE Automatic Virtual Environment• Physical environment:

10’x10’x9’ room where 3 of the 4 walls and the floor are projection surfaces.

• Electronically controlled shutter glasses alternately allow projected images to appear to each eye.

Page 29: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-29

Virtual Reality

Virtual Surgery: (Surgery project)• Surgery training

workstations with video monitor and hand manipulators.

• Surgeons practice various types of surgery.

• Can be used as a remote surgery facility. Surgeon connects via satellite to an operating room where robot-like devices at an operating room do the job.

Page 30: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-30

Electronic Spreadsheets as Simulation Tools

Electronic spreadsheet application consists of rows/columns of cells that can contain numbers, text, and formulas.• The next slides will display how spreadsheets are used in a:

– Continuous simulation model.

– Probabilistic simulation model.

– Model with feedback.

Page 31: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-31

Electronic Spreadsheets as Simulation Tools

Continuous Simulation Model• Expres is a standard three-

phase, dispersed-flow, black-oil, finite-difference reservoir simulator.

• Uses a spreadsheet’s macro capabilities to simulate oil well production.

Expres Simulator web site…

Page 32: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-32

Electronic Spreadsheets as Simulation Tools

Probabilistic Simulation Model• Each time a probabilistic

simulation is run, a different result will occur.

• This simulation uses a random number function to simulate a die toss.

Page 33: The Computer Continuum11-1 Chapter 11: Simulation: Modeling the Physical World Simulation is one of the most important uses of computers today. It allows.

The Computer Continuum 11-33

Electronic Spreadsheets as Simulation Tools

Model with Feedback• Deals with the issue of time.

– Something happens that affects a reaction later.

• A widely used type of feedback is the “what-if” simulation.

• Example: Backpacking trip. If you only have 4 days and need 4 each of breakfasts, lunches, and dinners. What combinations can you make if you only have $45.00 to spend?