Swarming
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.

Self-organization: 

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.