27.2.13

The frustrating attempt at obtaining a stable population size

Todays post is summed up nicely by its title. Two weeks after 'finishing' model construction, I am still finding bugs in the code and still tearing my hair out at trying to get my simulation to generate a stable population size.

With my 'glass is half full' head on, I say to myself that this time has been good and constructive and I'm glad I've found these niggly gremlins now rather than in a month when I've done my analysis and handed in my transfer report. And yes, this is true, but my 'life sucks' head says, why have I been so stupid as to code in these bugs in the first place? Have I not had years of coding experience by now? Am I not a reasonable programmer? Perhaps not? So yes, these bugs are MY fault. I am THAT stupid and model verification is the bane of my existence!



Coding has to be the worlds best way to make you doubt your own abilities and really look hard at yourself. Inevitably I find that a few hours of brilliant genius coding effort leads to some very strong hair-pulling out tactics a few weeks later when the 'simple' changes have done strange and unpredictable things to my agents and the way they behave. So strange in fact that it frazzles my tiny little brain trying to understand why my model is behaving in the way it is.

Agent-based models, it seems, really DO reflect complex systems. Or is it just my bad coding? Only time will tell.

Yesterdays coding blunder, after frustratingly trying to figure out why my population get exploding after about 12 years, was that not all my agents were NOT under-going their 'lose some energy every time step' step. And that only the ones who were actually eating food were doing this, meaning those agents that chose not to eat were perfectly happy and never suffered any negative consequences from choosing to perform actions that denied them the potential to consume resources. This at least explains nicely why my male agents were choosing to move incredibly long distances along trails (that provided no food).

So yes, in essence I am happy I found this bug. But todays problem is finding a set of parameters values that now fixes the opposite problem - generate a population that doesn't fall to zero within about 10 years.

Oh, the joys of programming.




22.2.13

LaTeX

I have just become aware of the TeX tips handle on twitter which I have also just started following. As the name suggests it provides useful tips on using LaTeX.

A useful website it has just informed me of can be found here: /http://www.latextemplates.com/ revealing some very useful LaTeX templates: articles, books, presentations, lab notes, PhD thesis!

great tip. Thanks @TeXtip!

21.2.13

Repast demo and tutorial

I have gotten to the point in the current version of my model where sending a both run of simulations of to IRIDIS the southampton uni supercomputer is becoming more and ore necessary. I'm struggling to get a run of 20 years in my simulation at the moment to check for stability of population and territories etc and its taking ages.
One run, depending on the number of agents and amount of reproduction (hence new agents), can take anywhere from half an hour to about 2 hours. I'm also having problems with memory where the simulation breakdown at that start of a new run due to being out of memory. Am currently trying to fix this problem.

Anyway, on my way to discovering if its possible to export a repast batch and pass it to IRIDIS I have come across a nice Repast demo that I wish had been around two years ago when I was starting to think about potential agent based simulation software and 18 months ago when i was struggling with my first attempts with repast.

Demo is based on a population of 'bugs' that move around and eat food from the landscape. Coincidentally amazingly relevant to my own model. I might try the demo and see if I can steal any ideas for better coding/construction of the model/GUI.

Demo can be found here: http://code.google.com/p/repast-demos/wiki/StupidModel
and an output of the GUI:


13.2.13

Biological principles underpinning Jaguar ABM

After some careful consideration of the need for a good biological foundation to my ABM, my supervisors and I agreed to implement some well-known population dynamics theory into key processes of the way the model and the agents undertake tasks.

Key factors: the jaguars - how they decide when and how often to move, and how they consume food across the landscape, and the food itself - food represents prey species and how will this respond to consumption?

Some sample prey species shown here, armadillo, coati, kinkajou, white-lipped peccary.


 


For my agents (jaguars), the key factor governing the way they move in the model is energy. Starting from an initial maximum energy state, they 'use-up' energy in a similar way to calorific expenditure in real animals. Moving and simply existing causes a steady loss of energy. Agents however need energy to survive and so must replenish this lost energy by consuming food. In this respect, low energy creates a greater need for the agent to change location to find an alternative, and potentially greater, food source. But of course real predators suffer a density-dependent relationship with prey and so based on some estimate of attack rate, a, handling time, b, and prey density, N, agents consume food based on the Holling Type 11 response:



Prey must then respond to being consumed, and are considered to regenerate according to a standard logistic growth function:


where, r is the intrinsic growth rate, K is carrying capacity and N is current prey density. For simplification, all prey species have been combined into a single food source and evenly distributed across the landscape, with K varying only with habitat type.