22
New Mexico Computer Science For All Designing and Running Simulations Maureen Psaila-Dombrowski

New Mexico Computer Science For All

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

New Mexico Computer Science For All

Designing and RunningSimulations

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:

▫Deterministic simulation 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.

•Show model

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

•Show program running – not stopping

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

•Show Stop in program

Table of Results

Average Number of Ticks Until Food is Gathered

Evaporation Rate

0 33 66 99

Diffusion Rate

0 1565 1558 1442 1516

33 1329 2507 1988 1320

66 1561 2892 2066 1428

99 1521 3467 2157 1440

Graph of Results

0 33 66 990

500

1000

1500

2000

2500

3000

3500

4000

EFFECT OF DIFFUSION RATE

0336699

DIFFUSION RATE

AV

ER

AG

E T

ICK

S

Graph of Results

0 33 66 990

500

1000

1500

2000

2500

3000

3500

4000

EFFECT OF EVAPORATION RATE

0336699

EVAPORATION RATE

AV

ER

AG

E T

ICK

S

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

• Stochastic simulation 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