Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science 101 Modeling and Simulation. Scientific Method Observe behavior of a system and formulate an hypothesis to explain it Design and carry.

Similar presentations


Presentation on theme: "Computer Science 101 Modeling and Simulation. Scientific Method Observe behavior of a system and formulate an hypothesis to explain it Design and carry."— Presentation transcript:

1 Computer Science 101 Modeling and Simulation

2 Scientific Method Observe behavior of a system and formulate an hypothesis to explain it Design and carry out experiments to test the hypothesis Make predictions about behavior based on valid hypotheses

3 Models Scientists often work with a model of a system rather than the “real thing” A model is a simplified version or abstraction of the real thing Example: test a model airplane in a wind tunnel

4 Physical vs Computational Models A computational model represents a physical model as a set of equations or algorithmic procedures A computational model captures the fundamental characteristics and behavior of a system Computational models are also called simulation models or simulations

5 Why Construct a Simulation? The system may not exist, so it’s impossible to experiment directly on it The system does not consist of physical objects (welfare policies, labor practices) It might be unsafe to experiment on an actual system, such as a nuclear power plant

6 Why Construct a Simulation? It might take too much time to build a physical model Some physical systems change too quickly or slowly, such as subatomic particles or ecosystems Some physical models have serious ethical consequences, such as the use of animals for medical research Ease of modification: if design doesn’t work, just modify the parameters

7 Computational Steering Initialize the system, observe its response, and if not satisfied, modify the parameters and run it again Repeat the process again and again, seeking to improve performance Interactive design too expensive to conduct with real physical systems

8 Interactive Design with a Simulator Construct the simulation model Set the initial parameters Run the simulation and collect results Modify the parameters Satisfied? Start Stop No Yes

9 An Example Physical Experiment Galileo’s experiment to demonstrate that heavy objects don’t fall faster than light ones Drop a massive iron cannonball and a light wooden ball from the top of the Tower of Pisa They landed at the same instant!

10 The Mathematical Model An equation represents the relation between distance, velocity, the force of gravity, and time d = v init t + ½ gt 2 g is 9.8 meters/sec 2 everywhere along the earth’s surface Note that the object’s mass is not part of the equation We can substitute a distance and solve for the time or the time and solve for the distance

11 The Mathematical Model The Tower of Pisa is 54 meters high d = v init t + ½ gt 2 54 = 0 * t + ½ * 9.8 * t 2 t 2 = 11.02 t = 3.32 seconds Then drop the balls and time them to verify

12 The Mathematical Model Galileo could have used this model to determine the time from a height of 150 meters, even though no building that high existed at that time d = v init t + ½ gt 2 150 = 0 * t + ½ * 9.8 * t 2 t 2 = 30.6 t = 5.53 seconds And it’s safe: nobody ever fell off an equation!

13 When Equations Don’t Work Accuracy. Sometimes, there are too many factors (such as air resistance for falling bodies or the imperfect shape of the Earth) and the equations get too complex The gravitational model is continuous, can be described in terms of equations, but sometimes we don’t know the equations or the system may resist a continuous description

14 When Equations Don’t Work Some systems contain stochastic components, meaning that some elements exhibit random behavior Customers walk into a store at random times Models must then use statistical approximations instead of exact equations

15 Discrete Event Simulation Time is not continuous, as with falling bodies, but breaks up into discrete moments At each moment, an event takes place that changes the state of the system Examples: a customer enters a store or purchases an item One event can cause a later event to happen During some moments, nothing can happen at all

16 Example: A Car Wash Given that it takes 4 minutes to wash a car and that cars arrive in a line with a random probability of.25, how many cars will get washed in 600 minutes and how long did each car have to wait in line? We can vary the wash time and the probability of arrival try to determine the optimal state of this “system”

17 The User Interface

18 The Simulation Algorithm Get the minutes per wash, probability of arrival, and total running time Initalize the counters For each minute do If a new car has arrived Time-stamp the car and add it to the end of the line If a car is not being washed and the line is not empty then Take a car off the front of the line Use its time stamp to see how long it waited Add its wait time to the total wait time Record that we have just begun to wash that car If a car is being washed Reduce by 1 minute the time left before we are done washing it If we are done washing the car Increment the number of cars washed Return the total number of cars washed and the average wait time Note that the “cars” and “minutes” are abstract, not real

19 Two Senses of “Improving” We can vary the parameters of a given model to determine the optimal behavior of a system We can make the model of a system more realistic by adding multiple wash stations, types of wash, etc.


Download ppt "Computer Science 101 Modeling and Simulation. Scientific Method Observe behavior of a system and formulate an hypothesis to explain it Design and carry."

Similar presentations


Ads by Google