Programming Exercise: Metapopulation Dynamics


[The applet requires Java to be installed and enabled. If you're seeing this message that's not the case, so you won't get to run the code. You can still read about it below]

The model implemented by the applet above represents the dynamics of a fixed metapopulation over a terrain in which only certain patches are habitable. Probabilities are derived for the occupancy states of each patch according to the geography; we can then simulate occupancy sequences according to those probabilities.

The Replay button shows the current simulation sequence again, while Resimulate generates a new simulation based on the probabilities for the current map. (Patches have an arbitrary 60% chance of being occupied when the simulation begins.)

Maps are generated randomly, and probabilities derived, according to parameters that can be adjusted using the sliders. Note that parameter changes only take effect when the New Map button is clicked.

Alpha, x and y are model parameters; these might be estimated from observed data in a real-world situation. Patches and Scale are implementation parameters: the applet needs to know how many habitable areas to put in its terrain and what the overall distance range should be. (The model uses areas and distances in terms of different order, so it is not invariant under scaling.)

The Defaults button restores the initial values for all parameters.

In the displayed map, red/pink is used to denote occupied patches and black/grey to denote unoccupied. The colour density indicates the probability of remaining in that state: totally black patches are almost guaranteed to remain unoccupied, totally red are likewise sure to remain occupied, paler patches are up for grabs. (This is not something we perceive in great detail, so it won't provide quantitative information; consider it a vague hint.)

NB: You may not be able interact with the applet until you have clicked on it.

The applet was built with Processing, a sort of dialect of Java. The source code isn't really a model of clarity, but you can view it here: MetaPop