Friday, May 8, 2009

Running an Agent-Based Model for Influenza


In the last two articles I first explained the design of a simple agent-based model of influenza, and then detailed some experiments I ran on it. Now it's your turn.

The Flu Model Live

Update: Due to one of the many applet deployment gotchas, some users weren't able to see the applet. It should be working for everyone now. Please let me know if it doesn't.--Miles (May 19)

I developed this model using MetaABM (soon to be Eclipse AMF), an agent-based modeling tool that allows users to design models using a graphical editor. MetaABM then automatically generates Java code for Ascape. I've just updated the applet viewer for Ascape so you can run any Ascape model on a webpage without any code modification. (For any Ascape users out there, I'll post an update with this included soon. Or grab the latest from SVN.) I hope the interface is pretty straightforward, but see the help section below for more info.



This is what the buttons do:
  • Starts the model, or if the model is already running, restarts it to time 0.

  • Pauses or resumes the model.

  • Steps the model forward one period.

  • Stops the model.

  • Displays or hides model settings. These appear on the right side of the applet.

You can change the relative size of the agent and chart view by dragging the splitter between the two panels.


You can change any of the model parameters in the settings dialog. Some of them are only used when the model starts up so to see any effect -- those you'll need to restart the model. For example, changes to Min and Max Contact Probability do not have any effect during a model run, but changes to movement probability do. The settings are explained below. (This documentation is also produced automatically by MetaABM.

NameTypeDefault Value
Individual CountInteger250
The number of individuals to create.
Initial Infection ProbabilityReal.05
The probability that any given individual will be infected at the beginning of the model run. For example, if this value is .15, and their are 100 individuals in the model, roughly 15 of those individuals will be infected at time 0.
Min Contact Transmission ProbabilityReal.08
The minimum probability that proximity to a single neighbor for a single period will result in transmission of infection. At the start of each model run, each individual is assigned a contact transmission probability between the minimum and maximum value. For example, if this value was .08 and the maximum value was 0.12 a given individual could have any value between those two, but the average transmission probability would be around .1. If minium and maximum values are the same, then all individuals will have the same chance of passing along infection to a given neighbor. This value must be between 0.0 and 1.0 and less than or equal to Max Contact transmission Probability.
Max Contact Transmission ProbabilityReal.16
The maximum probability that proximity to a single neighbor for a single period will result in transmission of infection. See Min Contact Probability for more information. Must be a value between 0.0 and 1.0 and greater or equal to Min Contact Transmission Probability.
Case Mortality RateReal.05
The current probability that death will occur for a given individual as a result of infection. Some number between 0.0 and 1.0.
Periods per DayInteger24
Min Period ExposureInteger15
The minimum amount of time from initial exposure to infectious asymptomatic or symptomatic state. 0 or greater.
Max Period ExposureInteger24
Maximum time from initial exposure to infectious asymptomatic or symptomatic state. 0 or greater.
Min Period Asymptom InfectionInteger24
Maximum time spent infected without showing symptoms. 0 or greater.
Max Period Asymptom InfectionInteger48
Maximum time spent infected without showing symptoms. May be zero!
Min Period Symptom InfectionInteger24
Minimum time spent infected with obvious symptoms. 0 or greater.
Max Period Symptom InfectionInteger168
Maximum time spent infected with obvious symptoms. 1 or greater.
Movement ProbabilityReal.5
The chance that an agent will move within a given period. May be any value between 0.0 and 1.0.


By clicking on the Rules tab of the settings dialog, you can play around with how the model executes. For example, you could turn off transmission for some time and see what effect that has on on the overall outcome.

Have Fun

I won't make any suggestions about how to proceed except that you might try some of the things that I discussed in the earlier posts and see what you discover. A couple of requests. It would be great if people could share their experiences with the model. And share the link with you friends!


  1. Dear Miles,
    So great to find your webpage and an AH1N1 model. I write ABMs and teach a posgraduate course in MEXICO, Chiapas, on Dynamics of Socio-Environmental Systems. This year my course starts in 5 days and I would love to teach my first class with your H1N1 Model, as everybody in MEXICO is really into the problem. Unfortunately in my windows XP the running model wont show up on the simulation screen. Do you know why and what do I have to do to get it running? Best Wishes Luis Garcia Barrios. My email is

  2. Hi Luis,

    Sorry I just got your message today.. don't know why I'm not getting notifications.Neat to hear about your course!

    First, I can send you the src code. Do you do Java development or would you need a bundled jar?

    Second I don't run windows so didn't notice this before now, but I just installed the Windows 7 beta n Bootcamp and noticed this issue as well. I'm going to try to get this up and running and thanks for letting me know.


  3. Luis, hoping you heard back through Andrew. Let me know if not.


Popular Posts

Recent Tweets

    follow me on Twitter