Project: Insect Ecology

Bees, the Environment, and Sustainability

Bees are a critical part of our ecosystem. Bees serve to pollinate more than 80% of the crops we eat, such as, as well as crops our feed animals (i.e. livestock) eat. Many people support bee populations by planting a variety of plants and flowers in their home gardens, supporting local organic farming, buying local honey, stopping the use of garden pesticides, and providing habitat for bee hives to be constructed and flourish.

Alarms have been sounded over the past 10 years about the decimation of many bee colonies, due to a combination of natural and man-made factors. As a result, scientists have been actively trying to learn more about how bee colonies work and the factors which impact their survival or extinction. Check out the following video for an example of the impacts of a declining bee population:

A mathematical model by Khoury, Myerscough, and Barron (2011) attempts to explain and dynamics of bee colony populations based on the death rate of “forager” bees. Forager bees are females who collect nectar and pollen from nearby sources; since they must leave the hive and expose themselves to greater environmental dangers, the life span of forager bees is often shorter than other hive bees and is often dependent on exactly when the foraging phase of their lifespan begins. Simply put, the longer bees delaying becoming foragers, the healthier the overall colony population. Hive bees are “recruited” to become forager bees when the colony detects a need for more foragers.

The mathematical model can be described first by two differential equations. Let us define a few variables:

  • H is the number of bees working in the hive
  • F is the number of forager bees (working outside the hive)
  • N is the total number of adult worker bees
  • Let m be the death rate of forager bees
  • Let t be the time, measured in days

Given these variables, let’s examine the differential equations for the rate of change in bee colony population (based on recruitment of bees to be foragers) and for the rate of change in the number of forager bees:

bees_eq1

bees_eq2

Next, let’s define the eclosion function E(H, F), which describes the colony population dynamics based on the number of hive bees and foragers:

bees_eq3

where w is a constant and L is the laying rate of the queen bee. Finally, let’s define the recruitment function R(H, F):

bees_eq4

Where α is the maximum rate that bees become foragers, in the absence of foragers in the colony, and σ is a constant: the second term of the function describes how the presence of foragers in the colony inhibits recruitment of other hive bees to become foragers.

C++ Project: Predicting Bee Populations

This project will provide you with an introduction to the fundamentals of one-dimensional arrays and user-defined functions in C++. In this project, you will…

  • Develop code to read data from the standard input and produce data to the standard output.
  • Write code that conforms to a programming style specified by the instructor.
  • Select and implement the appropriate control structure(s) for this problem.
  • Decompose the given problem into a sequence of single-purpose functions that are highly cohesive and loosely coupled.
  • Declare, define, and initialize one-dimensional, simple data type arrays of a fixed size.
  • Demonstrate the ability to read from and write to an arbitrary array element using array indices.
  • Demonstrate an ability to process the entire array, one element at a time, performing both read and write operations.
  • Develop code to read data from a text file and write data in a prescribed format to a text file.

As always, be sure to properly document your code. Consult the C++ Coding Guidelines document for proper coding standards. Use good design principles and design the solution before attempting to write code.

Exercise #1: Create a program called ColonyDynamics1.cpp. This program will take the following user input:

  • First value of w (int)
  • Second value of w (int)
  • Third value of w (int)

All user input values must be greater than or equal to 0. Once the input is complete, use one or more loops to compute the values of E(H, F) for the given values of w as the population (N = H + F) increases. The following variables will come into play:

  • N (int), the number of bees in the colony (start at 0, increase in 100-unit increments to 40,000 for your loop)
  • L (int), the laying rate of the queen (constant 2,000)

Store the computed values of E(H, F) into three separate and parallel arrays (one for each w value), all of size 512 and type double. Once the computation process is complete, your program should dump the contents of the three arrays to a comma-separated value (CSV) file called eclosion.csv and display a simple message to the user indicating the program is complete. For example:

Enter the first value of w: 4000
Enter the second value of w: 10000
Enter the third value of w: 27000
File eclosion.csv created, program complete.

When you create the CSV file, be sure that your first column is the corresponding value of N, beginning at 0 and increasing in 100-unit increments. This means your file will have four columns, in this order: The value of N, The value of E with the first value of w, The value of E with the second value of w, The value of E with the third value of w.

All computed numerical values should be precise to three decimal places. Your program should make use of multiple functions besides main() (use the input/process/output cycle as your guide). Think about how each problem actually involves more than one subproblem. At a minimum, you must construct functions aligned with the input-process-output steps. Don’t forget to validate all input, in the manner we discussed in class!

Exercise #2: Open the eclosion.csv file you created in Exercise #1 with Microsoft Excel. Create a chart with three separate lines: one for each value of w. The x-axis should be the increasing value of N, the y-axis should be the increasing values of E(H, F). Add the chart as a separate page to your Excel workbook.

Exercise #3: Create a program called ColonyDynamics2.cpp. This program will take the following user input:

  • The value of m (double)
  • The initial value of H (int), the number of bees working in the hive
  • The initial value of F (int), the number of forager bees

You will use this user input to produce a CSV file called growth.csv. This file will contain a series of time steps (time 0-15000) along with computed values of H and F for each time step. Remember that the values of H and F at each time step (other than step 0) are the present values of H and F with the change in H (dH/dt) and change in F (dF/dt) added to them. You will also need to use the following constants: L = 2000, w = 27000, α = 0.25, σ = 0.75.

All computed numerical values should be precise to three decimal places. Your program should make use of multiple functions besides main() (use the input/process/output cycle as your guide). Think about how each problem actually involves more than one subproblem. At a minimum, you must construct functions aligned with the input-process-output steps. Don’t forget to validate all input, in the manner we discussed in class!

Exercise #4: Open the growth.csv file you created in Exercise #3 with Microsoft Excel. Create a chart with two separate lines, plotted over time: one for H and one for F. The x-axis should be the increasing value of time. Add the chart as a separate page to your Excel workbook.

Deliverables

See the instructor for submission instructions and due date(s).

Powered by WordPress. Designed by WooThemes

Skip to toolbar