Biologically Inspired Computation Introducing Swarm Intelligence contents: the behavior of natural swarms and flocks -Reynold’s rules and swarm simulation. Some of the images in this lecture come from slides for a Course in Swarm Intelligence given at : Swarms, and how they might inspire us There are some interesting things that come to mind when we think of swarms (flocks, schools, etc …): • A swarm sometimes seems to behave as if it is an individual organism. Ants or wasps on a hunt for food, or on the attack, behave as if with a single mind, co-ordinating different actions with different parts of the swarm. • A swarm, of ants/bees/locusts/etc often exhibits behaviours that seem clearly more intelligent than any of the individual members of it. • The way in which swarms in some species change direction is astoundingly well co-ordinated. • The way in which swarms in some species avoid obstacles seems to be extremely well choreographed Other puzzling things that swarms do • Termites build huge nests – how?? Is an individual termite clever enough to do this? • Bees build hives, with complex internal structure -- same question. How on earth can these things happen? HERE IS A LIVE EXAMPLE Two simple rules: While continually wandering randomly: If you are empty-handed and encounter a disc, pick it up If you are carrying a disc and encounter another of the same colour, put yours down. Emergent order arises from simple local rules. We sometimes exhibit swarm behaviour too But we’re mainly interested in animals and insects locusts ants Because we might learn something Why does flocking/swarming occur so much in nature? Energy savings: Geese in V formation have around a 70% greater range than in flying individually. Individuals can fly around 25% faster (why?). Frightening and confusing predators; avoiding being “picked off” Helping to catch prey: e.g. tuna school in a crescent shaped flock with the concave part forward: This is thought to help channel their prey to the “focus”, and stop them from escaping It also maybe helps with migration If we can assume that: – An individual has an idea, but not a perfect one, of where to go … e.g. by itself it may go a few degrees off course. – The “errors” of individuals are not correlated (i.e. they’re all wrong in a randomly different way) – An emergent result of the flocking is that the flock’s direction is the average of its members’ directions. Then: basic statistics can show that the error in the flock’s direction is probably very small. About 1/sqrt(n) of the typical error of one of the n individuals. So … Flocking occurs so much because it is clearly useful. But how do they do it so well? Individual ants are not clever enough to understand the benefits. It comes down to: simple behaviours of individuals in a group can have useful emergent properties. A theme we will continue to see a lot … Another kinds of swarm behaviour is the dynamics and evolution of ideas as they get passed on and changed in social networks. A recommends to B, B recommends to C, … The Adaptive Culture Model Robert Axelrod has a well-known theory, “Axelrod’s Culture Model”, which explains how ideas spread in societies. Kennedy and Eberhart (a computer scientist and a social scientist respectively) altered this into the “Adaptive Culture Model”, which works like this: If you think your neighbour is good, then be more like them. More in the PSO lecture, but that’s basically it. Notice the important words, neighbour: you change yourself under the influence of people nearby good: in some way your neighbour is more optimal than you, otherwise why be like them? more like: this is vague, so you have freedom in how you change This is actually a very good model for how culture and ideas spread quickly in societies. Everything from rumours to eating habits. I only hope this works with `green’ behaviour … Australian atheism UK politics USA mobile tech Back to computer science … From the CS viewpoint, one of the interesting aspects of this is that organised, functional group behaviour emerges, without the need for a central controller (or without a single ‘brain’). The emergent behaviour that we see arises purely as a result of individuals in the swarm processing information in their (fairly) immediate neighbourhood. So, studying this in nature suggests how we can get co-ordinated behaviour from a group of individuals, without having to specify any overall controller. This is very useful, for example, for designing computer networks. If one main machine was in control of the network, and that machine crashed, … But so far that has not been a main success area for swarm inspiration … Two main things that come from swarm inspiration: Optimisation algorithms. Ants seem to find the shortest path to find food that may be quite distant from their nest. They do this via “stigmergy” – laying pheronomones on their path as they move. This has directly inspired the design of a very successful optimisation method, called Ant Colony Optimisation. Meanwhile, the adaptive culture model has led to a different, and also very successful, new optimisation algorithm, called Particle Swarm Optimisation Simulations of natural flocks. For the entertainment and gaming industries, for example. One other thing that come from swarm inspiration: Swarm-based construction Not yet applied much, but soon to be: we are working on it!. Swarm-based construction – how ants build their nests, bees build hives, and beavers build dams, etc – seems to be explainable by sets of simple rules that make use of stigmergy (as with other emergent behaviours). But in this case, the rules are about where the individual should put things, rather than where the individual should go. See section 2.1.3 of the recommended reading “Swarm Intelligence Chapter” on my teaching site. Craig Reynolds and “Boids” Craig Reynolds is a computer graphics researcher, who revolutionised animation in games and movies with his classic paper : Reynolds, C. W. (1987) Flocks, Herds, and Schools: A Distributed Behavioral Model, in Computer Graphics, 21(4) (SIGGRAPH '87 Conference Proceedings) pages 25-34. This paper is examinable reading, available on my teaching page. The story is: • before this paper, animations of flocks, swarms, groups, and so on, behaved nothing at all like the real thing. Nobody knew how to make it realistic. (we still have that problem with fire, explosions, and realistic human movement, etc …) • Reynold’s solved the problem by trying a very simple approach, which was inspired by a sensible view of how animals actually do it. The problem We would like these to move like a realistic flock of starlings. (The heading of each one is suggested by where it’s pointing) But what’s wrong to start with? The problem That’s better. Now what? Perhaps in the next timestep, they should all move the same small distance? They should all change their velocity in some way? What? Reynold’s Rules Reynolds came up with three simple rules that solve this Problem, resulting in entirely realistic flocking behaviour. To explain them, we first need to consider the perceptual system of an individual (which Reynolds called a boid). For realistic movement, you need a realistic view of perception. E.g. a starling’s movement is not influenced at all by the flockmates that it cannot see – such as those out of its line of sight, or too far away. A simple sensory system This picture is from Reynold’s boids page. The green boid can see a certain amount ahead, and is also aware of any flockmates within limits on either side (recall, birds tend to have eithers on the sides of their heads.) Two parameters, angle and distance, define the system. SO, this boid will only be influenced by those others it can sense according to these parameters. Rule 1: Separation At each iteration, a boid makes an adjustment to its velocity according to the following rule: Avoid getting too close to local (the ones it is aware of) flockmates. Rule 2: Alignment At each iteration, a boid makes an adjustment to match its velocity to the average of that of its local flockmates. Rule 3: Cohesion At each iteration, a boid makes an adjustment to its velocity towards the centroid of its flockmates. Notes: It’s not quite as simple as that to get realistic behaviour Need to define an appropriate distance for the perceptive range. What if this is too high, what if this is too small? Reynolds found that he had to be careful about how the vectors from the three rules get combined. It is not ideal to simply add them. Opposing “shouts” from two rules may cancel out, leading to the third winning – in what scenarios might this be a problem? Note that the cohesion rule is interesting – it leads to “bifurcating” around obstacles – a follow-the-leader approach to flocking would not achieve that. The simple rules also realistically lead to “flash expansion” if started too close together. Next (but one) time: Ant Colony Optimization