There’s a powerful approach to modelling called dynamic state variable programming, covered in Dynamic State Variable Models In Ecology by Clark & Mangel. I’ll post more about the approach sometime, but for now I wanted to make an example from the book available. The first chapter of the book includes a guide through the creation of a patch foraging model. A fully implemented version is available in True BASIC, but I’ve decided to use R for all of my modelling and analyses. Consequently, I’ve implemented the patch selection model from Clark & Mangel in R. It is available from http://public.me.com/mroutley/patchSelection.txt for anyone interested.