230 likes | 358 Views
New Mexico Computer Science For All. Designing and Running Simulations Maureen Psaila-Dombrowski. Models vs. Simulations. Model The actual program The abstraction of the real world Captures the elements of the system and the behavior of the elements being modeled Simulation
E N D
New Mexico Computer Science For All Designing and Running Simulations Maureen Psaila-Dombrowski
Models vs. Simulations • Model • The actual program • The abstraction of the real world • Captures the elements of the system and the behavior of the elements being modeled • Simulation • Running the model to simulate the passage of time • Exploring the behavior of the modeled system over time. • In studying complex systems, sometime unexpected patterns emerge that weren’t explicitly programmed into the model.
Simulations on Your Computer • Why? • Once the model is developed • Can run many trials • Can run many parameters • Can develop models for situations where experimentation is difficult • Too dangerous • Too expensive • Too time intensive
Deterministic vs. Stochastic • Two types of simulation models: • Deterministicsimulation models: • Provide single outputs for each set of inputs • No Randomness involved • Stochastic simulation models • Can produce somewhat different outputs for each set of inputs • Randomness IS involved • Agent-based models of Complex Adaptive Systems have Randomness -> they are stochastic • Look at the probability distribution of possible outcomes.
How to run a Simulation • Simple parameter sweeping (one dimension) • Hold all other variables constant • Set min, max, and increment for one variable. • Sweep one variable (from min to max value) • Repetition – Because the models are stochastic • Repetitions at each setting • Take the average? • What output do you want?
Ant Foraging Model • Food piles • Ants wander around looking for food • Ant finds a piece of food • Carries the food back to the nest • Drops a chemical as it moves – trail • Chemical evaporation • Chemical diffusion • Other ants find the chemical trail, • Follow the chemical to food • Carries the food back to the nest • Reinforce chemical trail • Repeated until there is no more food in that pile.
Ant Foraging Experiment/Simulation • Three Parameters • Number of ants (0-200) • Diffusion rate (0-99) • How quickly the chemical diffuses • How wide the trail is • Evaporation rate (0-99) • How fast the chemical evaporates • How long the trail lasts
Ant Foraging Experiment/Simulation • NEED TO KNOW WHAT OUTPUT DATA you are collecting…. Is it food left after # ticks? Is it ticks before all food is found?
Parameter Sweeping • Picking Sample Points (where and how many) • Make sense • no ants does not make sense • Must represent the variable or parameter being explored • Extremes are not enough • 2 points = line…. assumption • Must use points in the middle • More points if behavior is complicated
Ant Simulation – Parameter Sweeping • Parameter Sweeping • Ants (3 sample points) • 50, 100, 200 • Diffusion rate (4 sample points) • 0, 33, 66, 99 • Evaporation rate (4 sample points) • 0, 33, 66, 99 • Total Number of sampling points • 3 x 4 x 4 • 48 sample points
Repetitions • Stochastic model • Must run repetitions at each sample point • How many repetitions? • How random is the process? • Up to the experimenter – YOU!
Ant Simulation - Repetitions • I get to decide • Run the model to see how random • 5 repetitions • How many experiments? (number of sample points) x (number of repetitions) ( 48 ) x ( 5) = 240 • Can Limit Experiments • Fix the number of ants to 100 (number of sample points) x (number of repetitions) ( 4 x 4 ) x ( 5) = 80
What Output? • Simulation Output depends on the model • Number of ticks • Number of agents • Number of patches of color • Epidemic model • Ticks until everyone infected • Number of agents infected after number of ticks • Ants Model • Amount of food left after # ticks • Ticks before all food is found • Ticks before all found gathered
Stopping Forever Button • Forever GO button can go forever • Want an accurate measurement • Automatically Stop the Forever GO button • Conditional Stop at the TOP of GO procedure to go if condition? [ stop ] ... end
Computer Simulation Write-up: • Must include enough replication • Description of problem of interest and abstraction • Description of Model • Assumptions/Simplifications • Variables/Parameters • Description of Simulation • Parameter Sweeping • Repetitions • Description of Results • Verbal Description • Tables/Graphs • Discussion of Results/Conclusions
Summary • Model – The program that captures the elements of the system being modeled and the behavior of those elements • Simulation - Running the model to explore the behavior of the modeled system over time. • Deterministic simulation models: Provide single outputs for each set of inputs because No Randomness involved • Stochasticsimulation models: produce different outputs for each set of inputs because Randomness IS involved • Agent-based models of Complex Adaptive Systems have Randomness -> they are stochastic • Look at the probability distribution of possible outcomes. • How to perform a Stochastic Simulation • Parameter Sweeping • Repetition • When you write up simulation results must include enough detail for simulation to be repeated and explained