The purpose of this project is to practice creating and analyzing computational models in Python. You may work on this project individually or in group of two. The specific sysem we will be examining is a discrete time, discrete space, model of predator-prey population dynamics. Our model will make the following simplifying assumptions:
There are two deadlines for this project. For the first deadline you will need to get a basic version of the project working and submit your code. For the second deadline you will need to run experiments using your code and submit a report describing the results. Depending on the experiments you choose to perform, you may or may not need to make changes to your original code. The code and the paper will be weighted equally in final grade for this project.
Much of the code for this project is already written. You may get a
copy by downloading the file Population.py.
The (incomplete) main function for the program is the
predator_prey
function. Your goal will be to fill in the
missing pieces of this function and several other functions.
The rules that will govern our simulation are taken from [1]. The evolution of the system is governed by the following three interactions1:
V + O -->r 2V (Reproduction)
V + P -->p 2P (Predation)
P + O -->d 2O (Starvation)
In these interactions, V represents a cell occupied by prey, P represents a cell occupied by a predator, and O represents an empty cell. The variables r, p, and d represent the probabilities that the indicated interactions will occur. As an example of how these rules will be implemented in the code, let's consider reproduction:
Select a random cell from the environment. If the cell contains prey (V), then select one of the four neighbors of the cell at random. If the neighbor is empty (O), then It is filled with prey with probability r. Otherwise Nothing happens. If the originally selected cell does not contain prey, then nothing happens.
A partially completed function, reproduction
, to
implement this logic is provided in the Population.py
file.
It will be your responsibility to create similar functions to handle the
rules for predation and starvation2. The simulation
progresses by repeatedly applying these three rules.
In order to analyze the results of the simulation, it will be
necessary to track the population sizes of the different species over
time. You will need to write a Python function that is able to count
the number of cells that have a particular value. You should
not
have three separate functions: count_prey
,
count_predator
and count_space
. Instead, you
should create a single function, count_species
, that uses a parameter to determine what
species it should be counting. Your function should work equally well
for a simulation that includes 50 species as it does for a simulation
that only include three. Throughout the code that is provided, prey are
represented by cells containing 1's, predators are represented by cells
containing 2's, and empty space is represented by cells containing 0's.
Before you dive in and start programming, you should carefully read this entire document to make sure you understand what is expected. You should also take a careful look at the code that is provided, read the comments, and make sure you understand the changes that need to be made. You should test each function as you code it rather than trying to write all of the code at once.
The functions that will be included in your completed program fall into the following three categories:
When you are satisfied your code is working properly, submit your
Population.py
file via Kit. Your Python code will
be graded on the basis of style as well as correctness. Your code
should include appropriate comments. (Comments before functions,
inside of functions, program description, etc.) Variable names
should be descriptive.
The following scale will be used to grade the program:
Grading Criteria | Points |
---|---|
Functionality | 30 |
Style/Organization | 10 |
Appropriate Comments | 10 |
TOTAL | 50 |
Once you have your code working properly, you'll need to choose a question that you would like to address with your model, and run appropriate experiments to answer it. Be creative. There are many possibilities. Here are a few ideas that you could pursue. Most of these are a bit broad; you will probably need to narrow them down to come up with a manageable project. Don't be too ambitious. You are more likely to do a good job if you pick a topic that is simple and focused.
Keep in mind that some of these questions can be answered without making changes to the code, while others cannot.
The final report should be a 3-5 page paper detailing your experiment(s) and results. It should include appropriate figures to illustrate your results. Grammar and spelling will count, as will the overall structure and flow of the paper. Your paper can be prepared using any word processing program and then converted to PDF. Minimally, it should include:
In writing your paper, you can consider the rest of the class to be the target audience. This means that you do not need an extensive explanation of the basic premise of the paper, but you do need to clearly describe the specific question that you are addressing. Reports will be graded according to the following rubric:
Grading Criteria | Points |
---|---|
Content Do you have a clearly articulated experimental question? Does your paper effectively address that question? | 10 |
Spelling, grammar, sentence structure | 5 |
Word selection and tone Your paper should use precise and unambiguous language. It should not have an informal tone. | 5 |
Organization Appropriately organized sections. Well structured paragraphs. | 5 |
Figures Figures should support the conclusions of your paper. They should include captions and axis labels. | 3 |
BiblographyAny outside information should be cited. | 2 |
TOTAL: | 30 |
Your completed report should be submitted on Kit.