# Swarm behaviour

Swarm behaviour, or swarming, is a collective behaviour exhibited by entities, particularly animals, of similar size which aggregate together, perhaps milling about the same spot or perhaps moving en masse or migrating in some direction. It is a highly interdisciplinary topic.
As a term, swarming is applied particularly to insects, but can also be applied to any other entity or animal that exhibits swarm behaviour. The term flocking or murmuration can refer specifically to swarm behaviour in birds, herding to refer to swarm behaviour in tetrapods, and shoaling or schooling to refer to swarm behaviour in fish. Phytoplankton also gather in huge swarms called blooms, although these organisms are algae and are not self-propelled the way animals are. By extension, the term "swarm" is applied also to inanimate entities which exhibit parallel behaviours, as in a robot swarm, an earthquake swarm, or a swarm of stars.
From a more abstract point of view, swarm behaviour is the collective motion of a large number of self-propelled entities. From the perspective of the mathematical modeller, it is an emergent behaviour arising from simple rules that are followed by individuals and does not involve any central coordination. Swarm behaviour is also studied by active matter physicists as a phenomenon which is not in thermodynamic equilibrium, and as such requires the development of tools beyond those available from the statistical physics of systems in thermodynamic equilibrium. In this regard, swarming has been compared to the mathematics of superfluids, specifically in the context of starling flocks (murmuration).
Swarm behaviour was first simulated on a computer in 1986 with the simulation program boids. This program simulates simple agents (boids) that are allowed to move according to a set of basic rules. The model was originally designed to mimic the flocking behaviour of birds, but it can be applied also to schooling fish and other swarming entities.

## Models

In recent decades, scientists have turned to modeling swarm behaviour to gain a deeper understanding of the behaviour.

### Mathematical models

Early studies of swarm behaviour employed mathematical models to simulate and understand the behaviour. The simplest mathematical models of animal swarms generally represent individual animals as following three rules:
* Move in the same direction as their neighbours
* Remain close to their neighbours
* Avoid collisions with their neighbours
The boids computer program, created by Craig Reynolds in 1986, simulates swarm behaviour following the above rules. Many subsequent and current models use variations on these rules, often implementing them by means of concentric "zones" around each animal. In the "zone of repulsion", very close to the animal, the focal animal will seek to distance itself from its neighbours to avoid collision. Slightly further away, in the "zone of alignment", the focal animal will seek to align its direction of motion with its neighbours. In the outermost "zone of attraction", which extends as far away from the focal animal as it is able to sense, the focal animal will seek to move towards a neighbour.
The shape of these zones will necessarily be affected by the sensory capabilities of a given animal. For example, the visual field of a bird does not extend behind its body. Fish rely on both vision and on hydrodynamic perceptions relayed through their lateral lines, while Antarctic krill rely both on vision and hydrodynamic signals relayed through antennae.
However recent studies of starling flocks have shown that each bird modifies its position, relative to the six or seven animals directly surrounding it, no matter how close or how far away those animals are. Interactions between flocking starlings are thus based on a topological, rather than a metric, rule. It remains to be seen whether this applies to other animals. Another recent study, based on an analysis of high-speed camera footage of flocks above Rome and assuming minimal behavioural rules, has convincingly simulated a number of aspects of flock behaviour.

### Evolutionary models

In order to gain insight into why animals evolve swarming behaviours, scientists have turned to evolutionary models that simulate populations of evolving animals. Typically these studies use a genetic algorithm to simulate evolution over many generations. These studies have investigated a number of hypotheses attempting to explain why animals evolve swarming behaviours, such as the selfish herd theory the predator confusion effect, the dilution effect, and the many eyes theory.

### Agents

* Mach, Robert; Schweitzer, Frank (2003). "Multi-Agent Model of Biological Swarming". Advances In Artificial Life. Lecture Notes in Computer Science. Vol. 2801. pp. 810–820. CiteSeerX 10.1.1.87.8022. doi:10.1007/978-3-540-39432-7_87. ISBN 978-3-540-20057-4.

### Emergence

The concept of emergence—that the properties and functions found at a hierarchical level are not present and are irrelevant at the lower levels–is often a basic principle behind self-organizing systems. An example of self-organization in biology leading to emergence in the natural world occurs in ant colonies. The queen does not give direct orders and does not tell the ants what to do. Instead, each ant reacts to stimuli in the form of chemical scents from larvae, other ants, intruders, food and buildup of waste, and leaves behind a chemical trail, which, in turn, provides a stimulus to other ants. Here each ant is an autonomous unit that reacts depending only on its local environment and the genetically encoded rules for its variety. Despite the lack of centralized decision making, ant colonies exhibit complex behaviours and have even been able to demonstrate the ability to solve geometric problems. For example, colonies routinely find the maximum distance from all colony entrances to dispose of dead bodies.

### Stigmergy

A further key concept in the field of swarm intelligence is stigmergy. Stigmergy is a mechanism of indirect coordination between agents or actions. The principle is that the trace left in the environment by an action stimulates the performance of a next action, by the same or a different agent. In that way, subsequent actions tend to reinforce and build on each other, leading to the spontaneous emergence of coherent, apparently systematic activity. Stigmergy is a form of self-organization. It produces complex, seemingly intelligent structures, without need for any planning, control, or even direct communication between the agents. As such it supports efficient collaboration between extremely simple agents, who lack any memory, intelligence or even awareness of each other.

### Swarm intelligence

Swarm intelligence is the collective behaviour of decentralized, self-organized systems, natural or artificial. The concept is employed in work on artificial intelligence. The expression was introduced by Gerardo Beni and Jing Wang in 1989, in the context of cellular robotic systems.
Swarm intelligence systems are typically made up of a population of simple agents such as boids interacting locally with one another and with their environment. The agents follow very simple rules, and although there is no centralized control structure dictating how individual agents should behave, local, and to a certain degree random, interactions between such agents lead to the emergence of intelligent global behaviour, unknown to the individual agents.
Swarm intelligence research is multidisciplinary. It can be divided into natural swarm research studying biological systems and artificial swarm research studying human artefacts. There is also a scientific stream attempting to model the swarm systems themselves and understand their underlying mechanisms, and an engineering stream focused on applying the insights developed by the scientific stream to solve practical problems in other areas.

### Algorithms

Swarm algorithms follow a Lagrangian approach or an Eulerian approach. The Eulerian approach views the swarm as a field, working with the density of the swarm and deriving mean field properties. It is a hydrodynamic approach, and can be useful for modelling the overall dynamics of large swarms. However, most models work with the Lagrangian approach, which is an agent-based model following the individual agents (points or particles) that make up the swarm. Individual particle models can follow information on heading and spacing that is lost in the Eulerian approach.

#### Ant colony optimization

Ant colony optimization is a widely used algorithm which was inspired by the behaviours of ants, and has been effective solving discrete optimization problems related to swarming. The algorithm was initially proposed by Marco Dorigo in 1992, and has since been diversified to solve a wider class of numerical problems. Species that have multiple queens may have a queen leaving the nest along with some workers to found a colony at a new site, a process akin to swarming in honeybees.
* Ants are behaviourally unsophisticated; collectively they perform complex tasks. Ants have highly developed sophisticated sign-based communication.
* Ants communicate using pheromones; trails are laid that can be followed by other ants.
* Routing problem ants drop different pheromones used to compute the "shortest" path from source to destination(s).
* Rauch, EM; Millonas, MM; Chialvo, DR (1995). "Pattern formation and functionality in swarm models". Physics Letters A. 207 (3–4): 185. arXiv:adap-org/9507003. Bibcode:1995PhLA..207..185R. doi:10.1016/0375-9601(95)00624-c. S2CID 120567147.

#### Self-propelled particles

The concept of self-propelled particles (SPP) was introduced in 1995 by Tamás Vicsek et al. as a special case of the boids model introduced in 1986 by Reynolds. An SPP swarm is modelled by a collection of particles that move with a constant speed and respond to random perturbations by adopting at each time increment the average direction of motion of the other particles in their local neighbourhood.
Simulations demonstrate that a suitable "nearest neighbour rule" eventually results in all the particles swarming together, or moving in the same direction. This emerges, even though there is no centralized coordination, and even though the neighbours for each particle constantly change over time. SPP models predict that swarming animals share certain properties at the group level, regardless of the type of animals in the swarm. Swarming systems give rise to emergent behaviours which occur at many different scales, some of which are both universal and robust. It has become a challenge in theoretical physics to find minimal statistical models that capture these behaviours.

#### Particle swarm optimization

Particle swarm optimization is another algorithm widely used to solve problems related to swarms. It was developed in 1995 by Kennedy and Eberhart and was first aimed at simulating the social behaviour and choreography of bird flocks and fish schools. The algorithm was simplified and it was observed to be performing optimization. The system initially seeds a population with random solutions. It then searches in the problem space through successive generations using stochastic optimization to find the best solutions. The solutions it finds are called particles. Each particle stores its position as well as the best solution it has achieved so far. The particle swarm optimizer tracks the best local value obtained so far by any particle in the local neighbourhood. The remaining particles then move through the problem space following the lead of the optimum particles. At each time iteration, the particle swarm optimiser accelerates each particle toward its optimum locations according to simple mathematical rules. Particle swarm optimization has been applied in many areas. It has few parameters to adjust, and a version that works well for a specific applications can also work well with minor modifications across a range of related applications. A book by Kennedy and Eberhart describes some philosophical aspects of particle swarm optimization applications and swarm intelligence. An extensive survey of applications is made by Poli.

#### Altruism

Researchers in Switzerland have developed an algorithm based on Hamilton's rule of kin selection. The algorithm shows how altruism in a swarm of entities can, over time, evolve and result in more effective swarm behaviour.

## Biological swarming

The earliest evidence of swarm behaviour in animals dates back about 480 million years. Fossils of the trilobite Ampyx priscus have been recently described as clustered in lines along the ocean floor. The animals were all mature adults, and were all facing the same direction as though they had formed a conga line or a peloton. It has been suggested they line up in this manner to migrate, much as spiny lobsters migrate in single-file queues; it has also been suggested that the formation is the precursor for mating, as with the fly Leptoconops torrens. The findings suggest animal collective behaviour has very early evolutionary origins.
Examples of biological swarming are found in bird flocks, fish schools, insect swarms, bacteria swarms, molds, molecular motors, quadruped herds and people.

### Social insects

The behaviour of social insects (insects that live in colonies, such as ants, bees, wasps and termites) has always been a source of fascination for children, naturalists and artists. Individual insects seem to do their own thing without any central control, yet the colony as a whole behaves in a highly coordinated manner. Researchers have found that cooperation at the colony level is largely self-organized. The group coordination that emerges is often just a consequence of the way individuals in the colony interact. These interactions can be remarkably simple, such as one ant merely following the trail left by another ant. Yet put together, the cumulative effect of such behaviours can solve highly complex problems, such as locating the shortest route in a network of possible paths to a food source. The organised behaviour that emerges in this way is sometimes called swarm intelligence, a form of biological emergence.

#### Ants

Individual ants do not exhibit complex behaviours, yet a colony of ants collectively achieves complex tasks such as constructing nests, taking care of their young, building bridges and foraging for food. A colony of ants can collectively select (i.e. send most workers towards) the best, or closest, food source from several in the vicinity. Such collective decisions are achieved using positive feedback mechanisms. Selection of the best food source is achieved by ants following two simple rules. First, ants which find food return to the nest depositing a pheromone chemical. More pheromone is laid for higher quality food sources. Thus, if two equidistant food sources of different qualities are found simultaneously, the pheromone trail to the better one will be stronger. Ants in the nest follow another simple rule, to favor stronger trails, on average. More ants then follow the stronger trail, so more ants arrive at the high quality food source, and a positive feedback cycle ensures, resulting in a collective decision for the best food source. If there are two paths from the ant nest to a food source, then the colony usually selects the shorter path. This is because the ants that first return to the nest from the food source are more likely to be those that took the shorter path. More ants then retrace the shorter path, reinforcing the pheromone trail.
Army ants, unlike most ant species, do not construct permanent nests; an army ant colony moves almost incessantly over the time it exists, remaining in an essentially perpetual state of swarming. Several lineages have independently evolved the same basic behavioural and ecological syndrome, often referred to as "legionary behaviour", and may be an example of convergent evolution.
The successful techniques used by ant colonies have been studied in computer science and robotics to produce distributed and fault-tolerant systems for solving problems. This area of biomimetics has led to studies of ant locomotion, search engines that make use of "foraging trails", fault-tolerant storage and networking algorithms.

#### Honey bees

In temperate climates, honey bees usually form swarms in late spring. A swarm typically contains about half the workers together with the old queen, while the new queen stays back with the remaining workers in the original hive. When honey bees emerge from a hive to form a swarm, they may gather on a branch of a tree or on a bush only a few meters from the hive. The bees cluster about the queen and send out 20–50 scouts to find suitable new nest locations. The scouts are the most experienced foragers in the cluster. If a scout finds a suitable location, she returns to the cluster and promotes it by dancing a version of the waggle dance. This dance conveys information about the quality, direction, and distance of the new site. The more excited she is about her findings, the more vigorously she dances. If she can convince others they may take off and check the site she found. If they approve they may promote it as well. In this decision-making process, scouts check several sites, often abandoning their own original site to promote the superior site of another scout. Several different sites may be promoted by different scouts at first. After some hours and sometimes days, a preferred location eventually emerges from this decision-making process. When all scouts agree on the final location, the whole cluster takes off and swarms to it. Sometimes, if no decision is reached, the swarm will separate, some bees going in one direction; others, going in another. This usually results in failure, with both groups dying. A new location is typically a kilometre or more from the original hive, though some species, e.g., Apis dorsata, may establish new colonies within as little as 500 meters from the natal nest. This collective decision-making process is remarkably successful in identifying the most suitable new nest site and keeping the swarm intact. A good hive site has to be large enough to accommodate the swarm (about 15 litres in volume), has to be well-protected from the elements, receive an optimal amount of sunshine, be some height above the ground, have a small entrance and be capable of resisting ant infestation - that is why tree cavities are often selected.

### Non-social insects

Unlike social insects, swarms of non-social insects that have been studied primarily seem to function in contexts such as mating, feeding, predator avoidance, and migration.

#### Moths

Moths may exhibit synchronized mating, during which pheromones released by females initiate searching and swarming behavior in males. Males sense pheromones with sensitive antennae and may track females as far as several kilometers away. Swarm mating involves female choice and male competition. Only one male in the swarm—typically the first—will successfully copulate. Females maximize fitness benefits and minimize cost by governing the onset and magnitude of pheromone deployed. Too little pheromone will not attract a mate, too much allows less fit males to sense the signal. After copulation, females lay the eggs on a host plant. Quality of host plant may be a factor influencing the location of swarming and egg-laying. In one case, researchers observed pink-striped oakworm moths (Anisota virginiensis) swarming at a carrion site, where decomposition likely increased soil nutrient levels and host plant quality.

#### Flies

Midges, such as Tokunagayusurika akamusi, form swarms, dancing in the air. Swarming serves multiple purposes, including the facilitation of mating by attracting females to approach the swarm, a phenomenon known as lek mating. Such cloud-like swarms often form in early evening when the sun is getting low, at the tip of a bush, on a hilltop, over a pool of water, or even sometimes above a person. The forming of such swarms is not out of instinct, but an adaptive behavior – a "consensus" – between the individuals within the swarms. It is also suggested that swarming is a ritual, because there is rarely any male midge by itself and not in a swarm. This could have formed due to the benefit of lowering inbreeding by having males of various genes gathering in one spot. The genus Culicoides, also known as biting midges, have displayed swarming behavior which are believed to cause confusion in predators.

#### Cockroaches

Cockroaches leave chemical trails in their feces as well as emitting airborne pheromones for mating. Other cockroaches will follow these trails to discover sources of food and water, and also discover where other cockroaches are hiding. Thus, groups of cockroaches can exhibit emergent behaviour, in which group or swarm behaviour emerges from a simple set of individual interactions.
Cockroaches are mainly nocturnal and will run away when exposed to light. A study tested the hypothesis that cockroaches use just two pieces of information to decide where to go under those conditions: how dark it is and how many other cockroaches there are. The study conducted by José Halloy and colleagues at the Free University of Brussels and other European institutions created a set of tiny robots that appear to the roaches as other roaches and can thus alter the roaches' perception of critical mass. The robots were also specially scented so that they would be accepted by the real roaches.

#### Locusts

Locusts are the swarming phase of the short-horned grasshoppers of the family Acrididae. Some species can breed rapidly under suitable conditions and subsequently become gregarious and migratory. They form bands as nymphs and swarms as adults—both of which can travel great distances, rapidly stripping fields and greatly damaging crops. The largest swarms can cover hundreds of square miles and contain billions of locusts. A locust can eat its own weight (about 2 grams) in plants every day. That means one million locusts can eat more than one tonne of food each day, and the largest swarms can consume over 100,000 tonnes each day.
Swarming in locusts has been found to be associated with increased levels of serotonin which causes the locust to change colour, eat much more, become mutually attracted, and breed much more easily. Researchers propose that swarming behaviour is a response to overcrowding and studies have shown that increased tactile stimulation of the hind legs or, in some species, simply encountering other individuals causes an increase in levels of serotonin. The transformation of the locust to the swarming variety can be induced by several contacts per minute over a four-hour period. Notably, an innate predisposition to aggregate has been found in hatchlings of the desert locust, Schistocerca gregaria, independent of their parental phase.
An individual locust's response to a loss of alignment in the group appears to increase the randomness of its motion, until an aligned state is again achieved. This noise-induced alignment appears to be an intrinsic characteristic of collective coherent motion.

#### Migratory behavior

Insect migration is the seasonal movement of insects, particularly those by species of dragonflies, beetles, butterflies, and moths. The distance can vary from species to species, but in most cases these movements involve large numbers of individuals. In some cases the individuals that migrate in one direction may not return and the next generation may instead migrate in the opposite direction. This is a significant difference from bird migration.
Monarch butterflies are especially noted for their lengthy annual migration. In North America they make massive southward migrations starting in August until the first frost. A northward migration takes place in the spring. The monarch is the only butterfly that migrates both north and south as the birds do on a regular basis. But no single individual makes the entire round trip. Female monarchs deposit eggs for the next generation during these migrations. The length of these journeys exceeds the normal lifespan of most monarchs, which is less than two months for butterflies born in early summer. The last generation of the summer enters into a non-reproductive phase known as diapause and may live seven months or more. During diapause, butterflies fly to one of many overwintering sites. The generation that overwinters generally does not reproduce until it leaves the overwintering site sometime in February and March. It is the second, third and fourth generations that return to their northern locations in the United States and Canada in the spring. How the species manages to return to the same overwintering spots over a gap of several generations is still a subject of research; the flight patterns appear to be inherited, based on a combination of the position of the sun in the sky and a time-compensated Sun compass that depends upon a circadian clock that is based in their antennae.

### Birds
#### Bird migration

Approximately 1800 of the world's 10,000 bird species are long-distance migrants. The primary motivation for migration appears to be food; for example, some hummingbirds choose not to migrate if fed through the winter. Also, the longer days of the northern summer provide extended time for breeding birds to feed their young. This helps diurnal birds to produce larger clutches than related non-migratory species that remain in the tropics. As the days shorten in autumn, the birds return to warmer regions where the available food supply varies little with the season. These advantages offset the high stress, physical exertion costs, and other risks of the migration such as predation.
Many birds migrate in flocks. For larger birds, it is assumed that flying in flocks reduces energy costs. The V formation is often supposed to boost the efficiency and range of flying birds, particularly over long migratory routes. All the birds except the first fly in the upwash from one of the wingtip vortices of the bird ahead. The upwash assists each bird in supporting its own weight in flight, in the same way a glider can climb or maintain height indefinitely in rising air. Geese flying in a V formation save energy by flying in the updraft of the wingtip vortex generated by the previous animal in the formation. Thus, the birds flying behind do not need to work as hard to achieve lift. Studies show that birds in a V formation place themselves roughly at the optimum distance predicted by simple aerodynamic theory. Geese in a V-formation may conserve 12–20% of the energy they would need to fly alone. Red knots and dunlins were found in radar studies to fly 5 km per hour faster in flocks than when they were flying alone. The birds flying at the tips and at the front are rotated in a timely cyclical fashion to spread flight fatigue equally among the flock members. The formation also makes communication easier and allows the birds to maintain visual contact with each other.
Other animals may use similar drafting techniques when migrating. Lobsters, for example, migrate in close single-file formation "lobster trains", sometimes for hundreds of miles.
The Mediterranean and other seas present a major obstacle to soaring birds, which must cross at the narrowest points. Massive numbers of large raptors and storks pass through areas such as Gibraltar, Falsterbo, and the Bosphorus at migration times. More common species, such as the European honey buzzard, can be counted in hundreds of thousands in autumn. Other barriers, such as mountain ranges, can also cause funnelling, particularly of large diurnal migrants. This is a notable factor in the Central American migratory bottleneck. This concentration of birds during migration can put species at risk. Some spectacular migrants have already gone extinct, the most notable being the passenger pigeon. During migration the flocks were a mile (1.6 km) wide and 300 miles (500 km) long, taking several days to pass and containing up to a billion birds.

### Marine life
#### Fish

The term "shoal" can be used to describe any group of fish, including mixed-species groups, while "school" is used for more closely knit groups of the same species swimming in a highly synchronised and polarised manner.
Fish derive many benefits from shoaling behaviour including defence against predators (through better predator detection and by diluting the chance of capture), enhanced foraging success, and higher success in finding a mate. It is also likely that fish benefit from shoal membership through increased hydrodynamic efficiency.
Fish use many traits to choose shoalmates. Generally they prefer larger shoals, shoalmates of their own species, shoalmates similar in size and appearance to themselves, healthy fish, and kin (when recognised). The "oddity effect" posits that any shoal member that stands out in appearance will be preferentially targeted by predators. This may explain why fish prefer to shoal with individuals that resemble them. The oddity effect would thus tend to homogenise shoals.
One puzzling aspect of shoal selection is how a fish can choose to join a shoal of animals similar to themselves, given that it cannot know its own appearance. Experiments with zebrafish have shown that shoal preference is a learned ability, not innate. A zebrafish tends to associate with shoals that resemble shoals in which it was reared, a form of imprinting.
Other open questions of shoaling behaviour include identifying which individuals are responsible for the direction of shoal movement. In the case of migratory movement, most members of a shoal seem to know where they are going. In the case of foraging behaviour, captive shoals of golden shiner (a kind of minnow) are led by a small number of experienced individuals who knew when and where food was available.
Radakov estimated herring schools in the North Atlantic can occupy up to 4.8 cubic kilometres (1.2 cu mi) with fish densities between 0.5 and 1.0 fish/cubic metre, totalling several billion fish in one school.
* Partridge BL (1982) "The structure and function of fish schools" Scientific American, June:114–123.
* Parrish JK, Viscido SV, Grunbaum D (2002). "Self-Organized Fish Schools: An Examination of Emergent Properties" (PDF). Biol. Bull. 202 (3): 296–305. CiteSeerX 10.1.1.116.1548. doi:10.2307/1543482. JSTOR 1543482. PMID 12087003. S2CID 377484. Archived from the original (PDF) on 11 September 2006.

#### Fish migration

Between May and July huge numbers of sardines spawn in the cool waters of the Agulhas Bank and then follow a current of cold water northward along the east coast of South Africa. This great migration, called the sardine run, creates spectacular feeding frenzies along the coastline as marine predators, such as dolphins, sharks and gannets attack the schools.

#### Krill

Most krill, small shrimp-like crustaceans, form large swarms, sometimes reaching densities of 10,000–60,000 individual animals per cubic metre. Swarming is a defensive mechanism, confusing smaller predators that would like to pick out single individuals. The largest swarms are visible from space and can be tracked by satellite. One swarm was observed to cover an area of 450 square kilometres (175 square miles) of ocean, to a depth of 200 meters (650 feet) and was estimated to contain over 2 million tons of krill. Recent research suggests that krill do not simply drift passively in these currents but actually modify them. Krill typically follow a diurnal vertical migration. By moving vertically through the ocean on a 12-hour cycle, the swarms play a major part in mixing deeper, nutrient-rich water with nutrient-poor water at the surface. Until recently it has been assumed that they spend the day at greater depths and rise during the night toward the surface. It has been found that the deeper they go, the more they reduce their activity, apparently to reduce encounters with predators and to conserve energy.
Later work suggested that swimming activity in krill varied with stomach fullness. Satiated animals that had been feeding at the surface swim less actively and therefore sink below the mixed layer. As they sink they produce faeces which may mean that they have an important role to play in the Antarctic carbon cycle. Krill with empty stomachs were found to swim more actively and thus head towards the surface. This implies that vertical migration may be a bi- or tri-daily occurrence. Some species form surface swarms during the day for feeding and reproductive purposes even though such behaviour is dangerous because it makes them extremely vulnerable to predators. Dense swarms may elicit a feeding frenzy among fish, birds and mammal predators, especially near the surface. When disturbed, a swarm scatters, and some individuals have even been observed to moult instantaneously, leaving the exuvia behind as a decoy. In 2012, Gandomi and Alavi presented what appears to be a successful stochastic algorithm for modelling the behaviour of krill swarms. The algorithm is based on three main factors: " (i) movement induced by the presence of other individuals (ii) foraging activity, and (iii) random diffusion."

#### Copepods

Copepods are a group of tiny crustaceans found in the sea and lakes. Many species are planktonic (drifting in sea waters), and others are benthic (living on the ocean floor). Copepods are typically 1 to 2 millimetres (0.04 to 0.08 in) long, with a teardrop shaped body and large antennae. Although like other crustaceans they have an armoured exoskeleton, they are so small that in most species this thin armour, and the entire body, is almost totally transparent. Copepods have a compound, median single eye, usually bright red, in the centre of the transparent head.
Copepods also swarm. For example, monospecific swarms have been observed regularly around coral reefs and sea grass, and in lakes. Swarms densities were about one million copepods per cubic metre. Typical swarms were one or two metres in diameter, but some exceeded 30 cubic metres. Copepods need visual contact to keep together, and they disperse at night.
Spring produces blooms of swarming phytoplankton which provide food for copepods. Planktonic copepods are usually the dominant members of the zooplankton, and are in turn major food organisms for many other marine animals. In particular, copepods are prey to forage fish and jellyfish, both of which can assemble in vast, million-strong swarms. Some copepods have extremely fast escape responses when a predator is sensed and can jump with high speed over a few millimetres (see animated image below).
* Photo: School of herrings ram feeding on a swarm of copepods.
* Animation showing how herrings hunting in a synchronised way can capture the very alert and evasive copepod (click to view).
* Swarms of jellyfish also prey on copepods
Planktonic copepods are important to the carbon cycle. Some scientists say they form the largest animal biomass on earth. They compete for this title with Antarctic krill. Because of their smaller size and relatively faster growth rates, however, and because they are more evenly distributed throughout more of the world's oceans, copepods almost certainly contribute far more to the secondary productivity of the world's oceans, and to the global ocean carbon sink than krill, and perhaps more than all other groups of organisms together. The surface layers of the oceans are currently believed to be the world's largest carbon sink, absorbing about 2 billion tonnes of carbon a year, the equivalent to perhaps a third of human carbon emissions, thus reducing their impact. Many planktonic copepods feed near the surface at night, then sink into deeper water during the day to avoid visual predators. Their moulted exoskeletons, faecal pellets and respiration at depth all bring carbon to the deep sea.

#### Algal blooms

Many single-celled organisms called phytoplankton live in oceans and lakes. When certain conditions are present, such as high nutrient or light levels, these organisms reproduce explosively. The resulting dense swarm of phytoplankton is called an algal bloom. Blooms can cover hundreds of square kilometres and are easily seen in satellite images. Individual phytoplankton rarely live more than a few days, but blooms can last weeks.

### Plants

Scientists have attributed swarm behavior to plants for hundreds of years. In his 1800 book, Phytologia: or, The philosophy of agriculture and gardening, Erasmus Darwin wrote that plant growth resembled swarms observed elsewhere in nature. While he was referring to more broad observations of plant morphology, and was focused on both root and shoot behavior, recent research has supported this claim.
Plant roots, in particular, display observable swarm behavior, growing in patterns that exceed the statistical threshold for random probability, and indicate the presence of communication between individual root apexes. The primary function of plant roots is the uptake of soil nutrients, and it is this purpose which drives swarm behavior. Plants growing in close proximity have adapted their growth to assure optimal nutrient availability. This is accomplished by growing in a direction that optimizes the distance between nearby roots, thereby increasing their chance of exploiting untapped nutrient reserves. The action of this behavior takes two forms: maximization of distance from, and repulsion by, neighboring root apexes. The transition zone of a root tip is largely responsible for monitoring for the presence of soil-borne hormones, signaling responsive growth patterns as appropriate. Plant responses are often complex, integrating multiple inputs to inform an autonomous response. Additional inputs that inform swarm growth includes light and gravity, both of which are also monitored in the transition zone of a root's apex. These forces act to inform any number of growing "main" roots, which exhibit their own independent releases of inhibitory chemicals to establish appropriate spacing, thereby contributing to a swarm behavior pattern. Horizontal growth of roots, whether in response to high mineral content in soil or due to stolon growth, produces branched growth that establish to also form their own, independent root swarms.

### Bacteria

Swarming also describes groupings of some kinds of predatory bacteria such as myxobacteria. Myxobacteria swarm together in "wolf packs", actively moving using a process known as bacterial gliding and keeping together with the help of intercellular molecular signals.

### Mammals

* Parrish JK, Edelstein-Keshet L (1999). "Complexity, pattern and evolutionary trade-offs in animal aggregation" (PDF). Science. 284 (5411): 99–101. Bibcode:1999Sci...284...99P. CiteSeerX 10.1.1.560.5229. doi:10.1126/science.284.5411.99. PMID 10102827. Archived from the original (PDF) on 20 July 2011.

## People

A collection of people can also exhibit swarm behaviour, such as pedestrians or soldiers swarming the parapets. In Cologne, Germany, two biologists from the University of Leeds demonstrated flock like behaviour in humans. The group of people exhibited similar behavioural pattern to a flock, where if five percent of the flock changed direction the others would follow. If one person was designated as a predator and everyone else was to avoid him, the flock behaved very much like a school of fish. Understanding how humans interact in crowds is important if crowd management is to effectively avoid casualties at football grounds, music concerts and subway stations.
The mathematical modelling of flocking behaviour is a common technology, and has found uses in animation. Flocking simulations have been used in many films to generate crowds which move realistically. Tim Burton's Batman Returns was the first movie to make use of swarm technology for rendering, realistically depicting the movements of a group of bats using the boids system. The Lord of the Rings film trilogy made use of similar technology, known as Massive, during battle scenes. Swarm technology is particularly attractive because it is cheap, robust, and simple.
An ant-based computer simulation using only six interaction rules has also been used to evaluate aircraft boarding behaviour. Airlines have also used ant-based routing in assigning aircraft arrivals to airport gates. An airline system developed by Douglas A. Lawson uses swarm theory, or swarm intelligence—the idea that a colony of ants works better than one alone. Each pilot acts like an ant searching for the best airport gate. "The pilot learns from his experience what's the best for him, and it turns out that that's the best solution for the airline," Lawson explains. As a result, the "colony" of pilots always go to gates they can arrive and depart quickly. The program can even alert a pilot of plane back-ups before they happen. "We can anticipate that it's going to happen, so we'll have a gate available," says Lawson.
Swarm behaviour occurs also in traffic flow dynamics, such as the traffic wave. Bidirectional traffic can be observed in ant trails. In recent years this behaviour has been researched for insight into pedestrian and traffic models. Simulations based on pedestrian models have also been applied to crowds which stampede because of panic.
Herd behaviour in marketing has been used to explain the dependencies of customers' mutual behaviour. The Economist reported a recent conference in Rome on the subject of the simulation of adaptive human behaviour. It shared mechanisms to increase impulse buying and get people "to buy more by playing on the herd instinct." The basic idea is that people will buy more of products that are seen to be popular, and several feedback mechanisms to get product popularity information to consumers are mentioned, including smart card technology and the use of Radio Frequency Identification Tag technology. A "swarm-moves" model was introduced by a Florida Institute of Technology researcher, which is appealing to supermarkets because it can "increase sales without the need to give people discounts."
* Helbing D, Keltsch J, Molnar P (1997). "Modelling the evolution of human trail systems". Nature. 388 (6637): 47–50. arXiv:cond-mat/9805158. Bibcode:1997Natur.388...47H. doi:10.1038/40353. PMID 9214501. S2CID 4364517.
* Helbing D, Farkas I, Vicsek T (2000). "Simulating dynamical features of escape panic". Nature. 407 (6803): 487–490. arXiv:cond-mat/0009448. Bibcode:2000Natur.407..487H. doi:10.1038/35035023. PMID 11028994. S2CID 310346.
* Helbing D, Farkas IJ, Vicsek T (2000). "Freezing by heating in a driven mesoscopic system". Physical Review Letters. 84 (6): 1240–1243. arXiv:cond-mat/9904326. Bibcode:2000PhRvL..84.1240H. doi:10.1103/PhysRevLett.84.1240. PMID 11017488. S2CID 18649078.

## Robotics

The application of swarm principles to robots is called swarm robotics, while swarm intelligence refers to the more general set of algorithms.
Partially inspired by colonies of insects such as ants and bees, researchers are modelling the behaviour of swarms of thousands of tiny robots which together perform a useful task, such as finding something hidden, cleaning, or spying. Each robot is quite simple, but the emergent behaviour of the swarm is more complex. The whole set of robots can be considered as one single distributed system, in the same way an ant colony can be considered a superorganism, exhibiting swarm intelligence. The largest swarms so far created is the 1024 robot Kilobot swarm. Other large swarms include the iRobot swarm, the SRI International/ActivMedia Robotics Centibots project, and the Open-source Micro-robotic Project swarm, which are being used to research collective behaviours. Swarms are also more resistant to failure. Whereas one large robot may fail and ruin a mission, a swarm can continue even if several robots fail. This could make them attractive for space exploration missions, where failure is normally extremely costly. In addition to ground vehicles, swarm robotics includes also research of swarms of aerial robots and heterogeneous teams of ground and aerial vehicles.
In contrast macroscopic robots, colloidal particles at microscale can also be adopted as agents to perform collective behaviors to conduct tasks using mechanical and physical approaches, such as reconfigurable tornado-like microswarm mimicking schooling fish, hierarchical particle species mimicking predating behavior of mammals, micro-object manipulation using a transformable microswarm. The fabrication of such colloidal particles is usually based on chemical synthesis.

## Military

Military swarming is a behaviour where autonomous or partially autonomous units of action attack an enemy from several different directions and then regroup. Pulsing, where the units shift the point of attack, is also a part of military swarming. Military swarming involves the use of a decentralized force against an opponent, in a manner that emphasizes mobility, communication, unit autonomy and coordination or synchronization. Historically military forces used principles of swarming without really examining them explicitly, but now active research consciously examines military doctrines that draw ideas from swarming.
Merely because multiple units converge on a target, they are not necessarily swarming. Siege operations do not involve swarming, because there is no manoeuvre; there is convergence but on the besieged fortification. Nor do guerrilla ambushes constitute swarms, because they are "hit-and-run". Even though the ambush may have several points of attack on the enemy, the guerillas withdraw when they either have inflicted adequate damage, or when they are endangered.
In 2014 the U. S. Office of Naval Research released a video showing tests of a swarm of small autonomous drone attack boats that can steer and take coordinated offensive action as a group.

## Gallery

* A swarm of migrating herrings
* A swarm of bees
* Salps arranged in chains form huge swarms.
* People swarming through an exit do not always behave like a fluid.
* A swarm of ladybirds
* A swarm of robots
* A swarm of earthquakes
* A swarm of ancient stars

## Myths

* There is a popular myth that lemmings commit mass suicide by swarming off cliffs when they migrate. Driven by strong biological urges, some species of lemmings may migrate in large groups when population density becomes too great. Lemmings can swim and may choose to cross a body of water in search of a new habitat. In such cases, many may drown if the body of water is so wide as to stretch their physical capability to the limit. This fact combined with some unexplained fluctuations in the population of Norwegian lemmings gave rise to the myth.
* Piranha have a reputation as fearless fish that swarm in ferocious and predatory packs. However, recent research, which started "with the premise that they school as a means of cooperative hunting", discovered that they were in fact rather fearful fish, like other fish, who schooled for protection from their predators, such as cormorants, caimans and dolphins. A researcher described them as "basically like regular fish with large teeth".