NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)


This project focuses on the swarming behavior witnessed in the "INVASIVE ANT SYNDROME".
L. Paralienus (lpar or lp for brevity) is the native specialist species; whereas L. Neglectus (lneg or ln for brevity) is the smaller but more numerous/invasive generalist species. By hitch-hiking alongside the modern human-dispersal patterns, these invasive species have rapidly spread across Europe. In just a few decades, they succeeded in eliminating many of the native species. This has had a dramatic disequilibrating effect across many levels of the ecosystem. And it is now poised as a global threat. To put this in perspective, ants constitute 15-20% of the total terrestial animal biomass" [3]. Ants belong to the genus Formicidae that consists of about 12000 (mostly specialized) species. The invasive generalist ants constitute about 200 (less than 2%) of the ant diversity. By rapidly collapsing the bio-diversity across the family lineage, they dramatically narrow the evolutionary ant pathways. Furthermore, given their generalist-nature, they are far more prone to local diseases (fungal/bacterial) that the specialist/nativists have evolved defenses against. Also, estimates of economic "damage and cost-control of invasive species in the U.S. alone amount to more than $138 billion annually [8]."

The phenomenon of interest for this project is not the normal foraging or nest building activities; it is instead focused on modeling the relative battle strategies between these two swarms of ant armies.

Questions of interest include:
1: What makes the smaller, but more numerous ln's so effective as a fighting machine?
2: How may one visualize the swarm effect when two massive ant armies go to battle?
3: What are some of the structural intervensions one may propose to help regain the diversity balance?

The fundamental theoretical work that informs this project is based on the Lanchester laws of combat [Refs. 1, 3 & 7] , first formulated in 1916 (during World War I) by the British Automotive Engineer, Frederick W. Lanchester. There are two versions of the law: the linear vs. the square-law. In the linear version, each of the combatants is sufficiently distributed across the warring landscape and is therefore evenly paired with one other opponent. Here, the lp species has the advantage over ln as it is physically much more stronger in a 1:1 combat. In contrast, the square-law brings about the swarming effect that the ln's are able to project given their larger numbers. Each lp is here being attacked by 2 or more ln's; and the advantage shifts to the more numerous ln's; with the casualties adding up in proportion to the square of the opposing forces.

In the ABM simulation, the opposing ant armies are "set up" in two separate chambers that are separated by a partition wall. When the war starts, the partition wall is breached at either a single central location; or evenly across the length of the partition. The former choice helps simulate the square-law effect; wheras the later (by evenly distributing the combatants) helps simulate the linear-law effect. A wide-enough, single opening elicits the square law; whereas multiple small openings elicit the linear law. Experimentally, this is supported in [7] where it is suggested that "..the top dish with a 180 degree opening is consistent with the square law, and the bottom dish with a narrow entrance creates the conditions of the linear law."

Extrapolating from the above, one may attempt to visualize what forms of human intervensions may help tilt the balance towards the linear law and away from the square law. As [6] indicates: "Different species may respond differently to habitat fragmentation. Theory predicts that abundant generalist species should be less affected by fragmentation than specialist species. In ant communities, the most abundant species is often behaviourally dominant." On the face of it, this indicates that fragmentation of the habitat (such as clearing the brush or mowing the lawn) clearly favors the invasive species. But a controlled form of fragmentation could favor the nativists while also leveraging the linear law. This is because fragmentation is more akin to opening multiple perforations in the ABM partition wall which gave the advantage to the lp's. But the problem with blanket fragmentation is that it also disrupts the lp-nest. If instead, fragmentation was done by leaving a few spots untouched for the lp-nest to grow and thrive, the balance can then perhaps be restored. The current practice of using baits and toxins does not really scale when faced with the numbers involved in the invasive ant swarms. As Francis Bacon indicated, "Nature to be commanded, must be obeyed." It is far better to work with nature rather than trying to disrupt it without understanding the larger consequences.


Before the war starts, the respective ant armies are "set up" in two adjacent chambers separated by a dividing wall. The smaller (but usually far more numerous & nimble) L. Neglectus (lneg or ln for brevity) red-ants are to the left; while the larger (and not so numerous nor agile) dark-brown L. Paralienus (lpar or lp for brevity) ants are to the right. Do note that in real-life lneg is not really red; instead they are slightly yellow on brown. But they are depicted as red in order to make the colors stand out for contrast. At each step, the combatants leave chemical signatures (i.e., pheromones) in the patch they inhabit. These chemicals diffuse and evaporate over time. The pheromone trace of the ln-agent is yellowish; while the pheromone trace of the lp-agent is blueish. Ants can sniff and identify both their own chemical droppings as well as that of the enemy. Usually, the diffusion rate is low; while the evaporation rate is high.

The user can adjust the various controls (as explained in detail below) to influence the set-up.

The event that starts the war is the button-push on "Start-War" which executes the opening of the divider that separates the two ant swarms. The dividing wall can be perforated either at a single central location, or at multiple locations. This option (single vs. multiple perforations) is controlled by the switch: many_holes? This helps establish the distributional toplology of the perforation. As explained above, a single perforation helps elicit the square-law; whereas, multiple perforations help elicit the linear-law. The user can also control the perforation dimensions via the divider-width as well as the hole-size. Larger the size of each perforation, greater the chance that the square law is operative.

Once the war starts, each agents starts homing into the enemy pheromone trace wafting around. From then on, it is the decimating numbers as well as the spatial-distribution of the combatants that governs the outcome. The battle-front quickly transforms into clusterrs of fighting, swarmings ants rushing at each other. A few basic rules that govern each of these combat outcomes are as follows (all fights require at least one of each lp & ln in the observant patch):

Rule 1: Linear-Law Combat where (lpcount - lncount) >=0); advantage lp
Rule 2: Toss-Up Combat where (lncount - lpcount) = 1; it's a toss-up
Rule 3: Sqaure-Law Combat where (lncount - lpcount) >= 2; advantage ln

Depending on the settings, one may view the formation of the linear vs. the square law patterns on the plot titled: For whom the bell tolls.... While the linear formation is more or less linear; the square law formation shows the classic parabola formation. Where it is a toss-up, it could go either way--with regions of the plot sometimes showing linear sections and sometimes parabolic.


Note: Length Dimensioning is set as a percentage of the maximum x-dimension of the world view. This approach is denoted as pct-x-max in the description below

In summary, the controls include (organized top to bottom on the left of the Interface):
1: Slider/box-size: the size of the bounding-box; set as a pct-x-max.
2: Slider/divider-width: the width of the partition wall; set as a pct-x-max.
3: Slider/hole-size: the diameter (size) of the holes in the partition that will allow the combatants to engage; set as a pct-x-max.
4: Switch/many-holes?: Boolean that indicates if there is to be a single central hole...or many that are evenly placed across the length iof the partition.
5: Slider/num-lns: The number of the more numerous ln's
6: Slider/num-lps: The number of the less numerous lp's
7: Slider/ln-speed: The speed at which the more agile ln moves
8: Sliderlp-speed: The speed at which the less agile lp moves
9: Slider/ln-diffusion-rate: The rate at which the ln pheromone diffuses across the adjacent patches
10: Slider/lp-diffusion-rate: The rate at which the lp pheromone diffuses across the adjacent patches
11: Slider/ln-evaporation-rate: The rate at which the ln pheromone evaporates and is lost
12: Slider/lp-evaporation-rate: The rate at which the lp pheromone evaporates and is lost
13: Button/setup: The setup routine that sets up the bounding boxes as well as the two adjacent armies separated by the partition
14: Button/go: The iterative looping of events that include:

Agent-Level Events:
a: Bouncing of the agent if near an impenetrable wall
b: Random agent wiggle
c: Chasing after the strongest enemy pheromone concentration
d: Motion into the new patch
e: Marking the new patch with self pheromone markings

Observer-Level Events:
a: Diffusion of the pheromone traces
b: Plotting & display updating
c: Stopping the simulation/war if one (or both) of the agent sets is anhilated

Patch-Level Events:
a: Making sure there are no pheromones leaking across impermeable wall's
b: Evaporation of the pheromone trace from each of the patches
c: Recoloring the patches to reflect the dominant pheromone present in the patch
d: Function as the terminator that evaluates the population of combatants at each patch to execute the three basic rules

15: Button/start-war: This opens the perforations as dictated by the user settings (items 1-4 above)
16: Button/truce: This closes the perforation. Any of the enemy combatants (including ones in the perforation) are allowed to continue the battle.
17: Monitor/count(lnegs): Count of ln's currently alive
18: Monitor/ln-dead: ln body count
19: Monitor/count(lpars): Count of lp's currently alive
20: Monitor/lp-dead: lp body count
21: Plot/In Memoriam To Those Who Died: Plots the Ant Body Count against time for each of the combatant spoecies (lp in black, ln in red).
22: Plot/For whom the bell tolls...: Normalized plot of the lp against the ln body-count. Ultimately, one or the other will hit the anhilation wall of 100% destruction. If the trace hits the ceiling, most likely the sqaure law is in effect with the anhilation of the lp's; if the trace hits the right vertical, the linear-law is in effect, with the anhilation of the ln's.


1: Notice the formation of the ant swarms as the battle lines are joined.
2: Every battle has a begin, middle and end game. See if you can predict which side wins when either one of the sides has hit the 80% anhilation mark.
3: See if the dominance of sqaure law or the linear law can be predicted based on the user settings.
4: Compare and contrast the model with the ant swarm activities one may have noticed in the wild.
5: Notice the marked difference in the body counts when the switch is flipped between single vs. multiple holes.


Let the default settings be
1: box-size: 97%
2: divider-width: 1%
3: hole-size: 5%
4: many-holes: TRUE
5: num-lns: 1000
6: num-lps: 250
7: ln-speed: 50
8: lp-speed: 25
9: ln-diffusion-rate: 13
10: lp-diffusion-rate: 11
11: ln-evaporation-rate: 74
12: lp-evaporation-rate: 82

Now vary one paired item at a time.

A: num-lns vs num-lps
1: Test the model at the low ln extreme. Set num-lns very low (say 100) and num-lps as much higher (say 500). See the working of the linear law.
2: Test the model at the high ln extreme. Set num-lns very high (say 1000) and num-lps as rather low (say 100). See if you notice the parabolic shape of the square law emerge.
3: Test the model as possibly a toss-up with (lp: 135, ln: 800).

B: Flip the many-holes switch
In each of the above cases in A, flip the many-holes switch to see the difference in the body-count.

C: Divider-Width Settings
With the default settings, change the divider-width to see if the default case can be flipped over to the losing side.

D: Hole-Size Settings
With the default settings, change the hole-size to see if the default case can be flipped over to the losing side.

E: Speed Settings
With the default case, see if changing the speed of the combatants has a marked effect.

F: Diffusion-Rate Settings
With the default case, see if changing the diffusion-rate of the combatants has a marked effect.

G: Evaporation-Rate Settings
With the default case, see if changing the evaporation-rate of the combatants has a marked effect.


1: The model currently lacks the ability to use the pheromone information of the allied forces; it is only focused on the enemy pheromone trace. It would make sense that the invasive species uses both the pheromone traces (enemy as well as friendly) to launch its swarm attacks. Likewise, the natives are advantaged if they spread out as much as possible (from time to time) and then attack the enemy. For doing that, the natives would need to take advantage of their own pheromone trace levels. Currently, the pheromone trace levels are being used only by the enemy forces; it is not being used to coordinate with the friendly forces for maximum effect.

2: The invasive species is known to exist in multiple interconnected nests (Polydomy--see theory notes below), with communication lines going out to the sister nests. The current model only shows a sinkle war front. In reality, there could be multiple such invasive fronts against a single native nest. To model such a scenario, one would have to put forth a far more complicated multi-faceted war front.

This model was derived by combining elements from two of the models available in the models libaray ("The Ant Model" as well as the "GasLab Two Gas Model"..see Related Model reference below).

A few of the interesting usage patterns include:
1: Figuring out how to combine and mash-up existing code bases to put forth a working solution that salavages modeling insights from the samples.
2: Taking advantage of plotxy for plotting items that are not time based
3: Using lput for creating multi-dimensional lists

1: Ant Model:

2: GasLab Two Gas:

3: War Guard Queen 2


1.Modeling warfare in social animals: a "chemical" approach.
2.The Evolution of Invasiveness in Garden Ants
3.Modeling ant battles by means of a diffusion-limited Gillespie algorithm
4.Discrimination behavior in the supercolonial pharaoh ant
5.Invasive Ant Risk Assessment: Lasius neglectus
6: Experimental small-scale grassland fragmentation alters competitive interactions among ant species
7: Do Lancasters Laws of Combat Describe Competition in Ants
8: Discrimination behavior in the supercolonial pharaoh ant


Lasius Neglectus (lneg or ln)

• Exhibit "Invasive Ant Syndrome" [4]:
• They are pre-adapted to live in disturbed environments.
• With loose nesting requirements they are able to quickly relocate their colonies in response to home-turf disturbance.
• As opportunistic foragers, they are able to thrive in environments that are resource-depleted or different from their natal turf.
• They are fully capable of taking advantage of the recent human-mediated, global dispersal machinery.
• Polygyny: Many queens in a single nest
• Polydomy: A vast colony spread across many nests
• Intranidal mating: Mating is within the nest, thus sparing the costly adventure of the queen winging it across hostile terrain to find a partner. Thus queens do not require functional wings weighed down with large fat reserves to survive during the treacherous mating season
• Budding: Nest reproduction is via budding, where the queen, its brood and associated workers leave the nest on foot to found a new nest. Budding avoids the costly mating flight as well as the initial set-up cost of reaching a self-sustaining critical mass.
• Lacking in stinger but acidopore (for formic acid) present
• Large Eyes
• Color: Slightly yellow on brown
• Primary food: aphid honeydew
• Mandibles with 7 teeth
• Small body size (length 2.5–3.5 mm).
• Large colony size: Small body size goes hand in hand with large colony size as it is less costly to reproduce and grow. They are therefore able to form super-colonies that often outnumber the natives by 10 to 100 times
• Unicolonial: Most ant species are multicolonial in nature with distinct boundaries that are aggressively defended. In contrast, the unicolonial species have a looser sense of the "self vs other", thus allowing them to dramatically scale into large numbers with the sharing of agents and resources across the polydome towards a peaceful co-existence. This is by far the key characteristic of the invasive ant species as it dramatically reduces friction (that goes with territoriality) while encouraging colonial cohesion and massing. Genetically this is achieved via reduced genetic variability at the loci coding for cuticular hydrocarbons that function as their chemical id.
• Super colonies may grow as large as 14 ha; with just the number of queens estimated to be about 35500 ± 10000; and workers estimated to be around 10^8 workers for the entire super colony.

Lasius Paralienus (lpar or lp)

• Large body size (length 6-7 mm)
• Monogynous species
• Biggest queens of all Palaearctic species.
• Small colonies
• Non-dominant behavior
• Color: Black

lp-ln Agent-Agent Interaction
• ln is often the first aggressor and cooperates and coordinates during attack
• ln has the greater mortality.
• lp is the escape artist and given the chance it will avoid fighting.
• lp is much bigger & stronger than any individual ln.
• But lp does not cooperate with its kind. It is therefore often a swarm of ln's around each lp


John Thomas
Submitted as part of the course: Introduction to Agent Based Modeling

(back to the NetLogo User Community Models)