Simulates layout of traps in an area with insect outbreak and dispersal; calculates capture probability

Download .jar file Download as .zip Download as .tar.gz
View on GitHub


TrapGrid simulates insect dispersal in a rectangular area containing traps. Each trap has a parameter indicating its attractiveness. Using this value, the escape probability for a given insect at a given distance from the trap can be calculated.

An outbreak is determined by a quantity of insects released at a given point and having a certain diffusion coefficient. The simulation can be run for any number of days, and will calculate the daily average escape probability for the colony, as well as a cumulative escape probability.


java -jar TrapGrid.jar <TrapGrid file> [-ob <outbreak file>] [-nd <number of days>] [-ns <number of simulations>] [-nf <number of flies per outbreak>] [-dc <diffusion coefficient>] [-s <seed for random number generator>] [-t <tolerance for TrapGrid average escape probability calculator>] [--calculateAvgEscProb]

TrapGrid file

A TrapGrid file is a tab-delimited file. The first row should contain x and y values representing the upper-right corner of a rectangle (whose lower-left corner is (0,0)). Each subsequent line should have three entries -- x, y and lambda representing the position and attractiveness of each trap.

Other inputs

You may supply an optional Outbreak file, which is a two-column tab-delimited file containing the x and y locations of outbreaks to be simulated. If you provide this file, the program will run one simulation per location.

The last flag, '--calculateAvgEscProb', enables calculation of the grid's overall average escape probability. Depending on the size of the area in question, this calculation can be time-consuming, and of course does not need to be repeated for multiple runs using the same grid.


TrapGrid writes to stdout. It will print a summary of the grid and other parameters used, along with a table. The table gives Outbreak Location, Day and Cumulative Escape Probability for each day of each outbreak simulated.

Sample data

The repository ships with a sample TrapGrid file called 'foogrid'. Running the program as follows:

java -jar TrapGrid.jar -tg foogrid

will run a simulation of a single outbreak consisting of 500 files in a 100m by 100m grid.


Javadocs here. If you have any problems running TrapGrid, please contact bhall7 at hawaii dot edu.