If I have class at 9, and my alarm goes off at 8:30...
From SC08 Student Competition
[edit] Teaser
- Monte Carlo simulations take many, many iterations with semi-random events to find an average of the outcomes over time. You'll want to familiarize yourself with that concept, as well as how to create a random number in your favorite programming language. If you know a little MPI, even better.
[edit] Description
This is a real life problem! One of the SC Education committee members lives in Cedar Rapids, IA. In order to leave for class early in the morning, there are two different roads she can take from her apartment to the highway: Blairs Ferry and Collins. The two run parallel to each other and have different pros and cons.
On Blairs Ferry, the average speed for the 3.6 miles to the highway exit is about 35 mph. However, there are eight stop lights. The odds of hitting any particular stoplight are about one in two, and the delay for hitting a light is about two minutes.
Collins has a little back road that runs for .7 mile with an average speed of 25 mph. This back road has no lights. However, once turning onto the main road (which is 2.2 miles), there are seven lights. There's only a 35% chance of hitting any particular light, but a delay will cost three minutes.
In order to maximize the amount of time this person has to lay in bed in the morning, which road should she take?
Assumptions/Hints:
- Calculate only the distance to the highway - assume the distance between the two exits on the highway is negligible.
- Rather than converting between minutes and hours, convert the relevant values to minutes and stick with minutes.
- Assume that your odds of hitting a particular light don't affect the odds of hitting the next one.
[edit] Grading
- On your team's USB drive under a directory named "AlarmGoesOff"" a plain text file with answers to the following (hint, do them in order):
- Using straight probability, what are the average times that you should expect for each road?
- Write a Monte Carlo simulation to test these times. Your code should take the number of iterations as a command line argument and print out the averages for each road. Turn in your code and any instructions for running it.
- Assume the average time this person has is about fourteen minutes to drive to the highway and make it to class on time. Modify your code to determine, for each road, what percentage of the time she will make it to class on time taking that route. Turn in your code and any instructions for running it.
- Taking your code from question 2, parallelize it to run on multiple processes with MPI, and then have the head node print out the final results. Turn in your code and any instructions necessary for running it.
