December 01, 2006

Homework

A metapopulation dynamics model represents the distribution of a fixed population of organisms over a terrain in which only some areas are habitable. The probability of movement from one habitable patch to another depends on the relative patch areas and the distances separating them. Such a model is the basis of a coding exercise this term -- a fairly simplistic model, but nevertheless having some unintuitive subtleties.

The model produces a convergent probability distribution; this is then simulated as a random process, but that is only approximate. At any individual step the resulting populations are not necessarily consistent with the model assumptions (eg, it is possible to wind up with no patches occupied, even though we have a fixed population) but the average over many simulations should be.

The model's behaviour is very dependent on scale -- big patches far apart are not the same as small patches proportionately closer together -- so that is adjustable in the code below, as is the number of patches. There are some other model parameters that are not adjustable in the current implementation, though I may add them at some point.

Red/pink patches are occupied; black/grey are not. The intensity represents something about the transition probabilities that we needn't worry about here. Replay shows the current simulation again. Resimulate creates a new simulation based on the current map. New Map... oh, take a wild guess.

I think I've accurately implemented the model, but some of the behaviour is decidely unintuitive, so perhaps not. Any mistakes will be corrected when I find them.

(Update: one of the formulae in the model was rather ambiguously specified and I took it too much at face value. I've modified the applet to do what I now think it should, and the results are fractionally more plausible, so we'll see.)

(Further Update: I factored out the buttons and added new slider controls. You can now play with the convergence model parameters alpha, x and y; press Defaults to restore these to their initial values. Parameter changes only take effect when you create a new map.)

(If you don't have Java enabled, you won't see anything very interesting here...)

On another note, notwithstanding a few bugs and idiosyncracies, Processing is really rather spiffy.
Posted by matt at December 1, 2006 06:40 PM

Comments
Something to say? Click here.