Project 3: Finishing the Sequential Implementation of Fish Schooling SimulationsThis is a continuation of project 2. Add a few files to your fish-schooling code from project 2:
- curl -O http://cs.colby.edu/courses/S16/cs336/projects/proj03/proj03/sim_fast.c
- curl -O http://cs.colby.edu/courses/S16/cs336/projects/proj03/proj03/sim_stats_1r.c
- curl -O http://cs.colby.edu/courses/S16/cs336/projects/proj03/proj03/sim_stats_nr.c
- curl -O http://cs.colby.edu/courses/S16/cs336/projects/proj03/proj03/disp_stats.c
- sim_fast.c: Runs a single simulation, which isn't slowed down by file IO. It also asks for the polarity and elongation to be computed.
- sim_stats_1r.c: Runs a set of simulations for a single value of r. It prints out the mean elongation and polarization from the last steps of all the simulations.
- sim_stats_nr.c: Runs a set of simulations for each of several values of r. It writes the mean and std. dev. of the polarization and elongation values to a file that can then be read in by disp_stats.
- disp_stats.c: A program Stephanie wrote to graphically display the results of lots of simulations. It reads in a file output by sim_stats_nr.
The main programs begin with more IO and less computation (good for debugging) and end with more computation and less IO. We also introduce code to time the computations. Our goal as we parallelize this code in the future will be to speed it up dramatically.
One Simulation at a Time, with Statistics
Now that we know how to run single simulations, let's compute the polarity and elongation values. We continue to allow for certain initial configurations, so that we can debug the statistics.
- Write computePolarization (in fish_support.c)
- Write runSimulationWithStatistics (in fish_support.c)
- Test it by running sim_fast (I supply sim_fast.c and my_timing.c)
Lots of Simulations for one orientation/attraction ratio
Ultimately, our goal is to run many simulations for each value of r (orientation/attraction ratio) starting from random initial conditions. First, let's write code that runs multiple simulations for one value of r.
- Write runRandomSimulationWithStatistics (in fish_support.c)
- Write runSimulations (in fish_support.c)
Lots of Simulations for multiple orientation/attraction ratios
- Run sim_stats_nr to get a taste of how much time it can take to run sequential code. We need to run at least 32 simulations for each r value on schools of at least 100 fish. How long does it take to run 32 simulations of 100-fish schools for three values of r?
- Add support to fishStep to account for a blind spot. If you would like to compare it to the output of my code (with just this extension), examine the .fsh files ending in ext1. To generate them, I ran sim_slow like this:
./sim_slow 9 3 2 1 reference_diag_ext1.fsh 1 ./sim_slow 9 3 100 1 reference_diag_long_ext1.fsh 1 ./sim_slow 9 4 2 1 reference_diagPacked_ext1.fsh 1 ./sim_slow 9 4 100 1 reference_diagPacked_long_ext1.fsh 1
To test them you can run sim_from_file like this:
./sim_from_file reference_diag_ext1.fsh 2 1 my_diag.fsh 1 ./sim_from_file reference_diag_long_ext1.fsh 100 1 my_diag_long.fsh 1 ./sim_from_file reference_diagPacked_ext1.fsh 2 1 my_diagPacked.fsh 1 ./sim_from_file reference_diagPacked_long_ext1.fsh 100 1 my_diagPacked_long.fsh 1
- Add support to fishStep to correct for fish that are turning too much. If you would like to compare it to the output of my code (with both extensions), examine the .fsh files ending in ext1ext2. To generate them, I ran sim_slow like this:
./sim_slow 9 3 2 1 reference_diag_ext1ext2.fsh 1 ./sim_slow 9 3 100 1 reference_diag_long_ext1ext2.fsh 1 ./sim_slow 9 4 2 1 reference_diagPacked_ext1ext2.fsh 1 ./sim_slow 9 4 100 1 reference_diagPacked_long_ext1ext2.fsh 1
To test them you can run sim_from_file like this:
./sim_from_file reference_diag_ext1ext2.fsh 2 1 my_diag.fsh 1 ./sim_from_file reference_diag_long_ext1ext2.fsh 100 1 my_diag_long.fsh 1 ./sim_from_file reference_diagPacked_ext1ext2.fsh 2 1 my_diagPacked.fsh 1 ./sim_from_file reference_diagPacked_long_ext1ext2.fsh 100 1 my_diagPacked_long.fsh 1
- Write computeElongation.
- Construct an initial configuration that allows you to demonstrate that fish can school (or at least take one step in a simulation) differently when they do or do not have a blindspot. This can be very small (e.g. 2 fish and only 2 timesteps).
Make liberal use of dump_sim and sim_from_file.
- Create a file named README.txt for your project write-up. This week, I want you to talk about (a) what was the most challenging aspect of the project, (b) which extensions you did, and (c) how long it takes to run sim_stats_1r for different values of r (ranging from 0.25 to 16) for different sizes of fish schools (ranging from 10 to 100), and for different numbers of simulations (you will be limited by the fish school size for this one). For part (c), it is up to you to decide which simulations to run. Make your decision based on how long it takes to run the individual simulations. Don't spend more than an hour on this part (writing and running together).
- You should hand in all code necessary to run your solutions. Place all necessary .h, .c, and Makefile files in proj02 directory along with the README file. Stephanie will probably want to compile and run the code. It should be possible to do so without looking for any more files. Tar/zip up the directory and email it to Stephanie.