NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

Download
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled because this model uses extensions.)

## WHAT IS IT?

This is a modification of the "Virus" model from Biology section of the NetLogo Model's Library to illustrate use of the time extension for "discrete event simulation", which makes the code simpler and faster (see THINGS TO NOTICE below).

With the few (but important) exceptions noted below, this model does exactly what the original Virus model did and uses the same code. The model documentation is not duplicated here; instead, this tab only discusses the differences between the original Virus model and this discrete event implementation.

## HOW IT WORKS

The differences from the original Virus model are:

* Instead of using counter variables (`remaining-immunity`, `sick-time`) to count down how many ticks remain until a turtle becomes susceptible or recovers, this version has turtles simply schedule the future time at which those events happen. In the procedure `infect`, the newly infected turtle schedules the time at which it executes `recover-or-die`. In `recover-or-die`, the turtle schedules the time at which its immunity ends and becomes susceptible again. This scheduling eliminates the need for code to check and update the counter variables each tick.

* Instead of separate boolean variables for whether a turtle is sick or immune, turtles have one variable `status` that has values of "susceptible" (equivalent to "healthy" in the original model), "infected" (equivalent to "sick"), or "immune".

* The only important difference in model formulation is that the times it takes turtles to recover (switch from "infected" to "immune") and to lose immunity (switch from "immune" to "susceptible") vary randomly among individuals. Discrete event simulation makes this easy: in each of the `time:schedule-event` statements in `infect` and `recover-or-die`, the future time at which the switch occurs is drawn from a random-exponential distribution, using the parameters "duration" and "immunity-duration" as the mean length of infection and immunity. This individual variation in infection and immunity times can be turned off by simply deleting the primitive `random-exponential` from the `time:schedule-event` statements in `infect` and `recover-or-die`.

* Age is tracked in years instead of weeks, and birthdays are scheduled as discrete events. When each turtle is created in `setup-turtles` it schedules its next birthday (the `get-older` procedure) a random number of weeks in the future. New turtles created in `reproduce` schedule their first birthday 52 weeks after their birth. On each birthday, the turtle simply schedules another execution of `get-older` 52 weeks in the future.

## HOW TO USE IT

## THINGS TO NOTICE

The use of discrete event simulation allows the code to be shorter and simpler. This version has 4 fewer procedures than the original: `get-sick`, `get-health`, `become-immune` are replaced by the `time:schedule-event` statements. The `immune?` reporter is made unnecessary by discrete event simulation and the `status` variable.

This model also executes more rapidly than the original Virus model because it eliminates the need to check counter variables every tick. In BehaviorSpace experiments with display updates off, this version executes in 2/3 the time of the original model, even though execution time (according to the profiler extension) is dominated by interface updates and the `move` procedure. The original model spends much of its execution time in the procedures `immune?` and `get-older`, which have been removed or simplified here.

The addition of individual variation in the duration of infection and immunity qualitatively changes the model's behavior. This model produces small and shorter cycles in infection than the original Virus model.

The model illustrates only one function of the time extension, discrete event simulation. It does not use the time extension's ability to represent specific years, dates, days, etc.

## THINGS TO TRY

## EXTENDING THE MODEL

## RELATED MODELS

## CREDITS AND REFERENCES

The original Virus model was written by Uri Wilensky:

* Wilensky, U. (1998). NetLogo Virus model. http://ccl.northwestern.edu/netlogo/models/Virus. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

## HOW TO CITE

## COPYRIGHT AND LICENSE

(back to the NetLogo User Community Models)