From Swarm Simulations to Swarm Intelligence ∗

In self-organizing systems such as collective intelligent behaviors of animal or insect groups: ﬂocks of birds, colonies of ants, schools of ﬁsh, swarms of bees, etc. there are ever emergent patterns which cannot be reduced to a linear composition of elementary subsystems properly. This reduction is possible only due to many repellents and an artiﬁcial environment. The emergent patterns are studied in the so-called swarm intelligence. In this paper we show that any swarm can be represented as a conventional automaton such as Kolmogorov-Uspensky machine, but with a very low accuracy because of deleting emergent phenomena. Furthermore, we show as well that implementing some unconventional algorithms of p -adic arithmetic and logic are much more applicable than conventional automata. By using p -adic integers we can code diﬀerent emergent patterns.


INTRODUCTION
Recently, a new approach in unconventional computing called swarm intelligence has developed [5], [14], [33].For example, it was discovered experimentally that swarms of social insects [9] can solve complex computational problems in * This research is supported by FP7-ICT-2011-8.
In this paper we try to formulate swarms as labelled transition systems with the same set of labels (events, or actions): direction, splitting, fusion, repelling (Section 2).Then we show that these labelled transition systems can implement Kolmogorov-Uspensky machines, but with a low accuracy because of emergent patterns which occur if we have many states of appropriate transition system (Section 3).Then we propose p-adic arithmetic and logic to formalize emergent patterns of swarms (Section 4).
To sum up, we offer a general logical approach to swarm intelligence.

FROM EMERGENT COMPUTING TO SWARM COMPUTING
In conventional logic circuits some electrical properties of transistors are used.In particular, the voltage is managed to be in only one of two states: high (if the voltage runs the range from 2.8 to 5.0V) or low (if the voltage is in the range from 0 to 0.8V).The high state of voltage means '1' or logical true.The low state means '0' or logical false.The main idea of electric devices based on electrical properties of transistors is that the Boolean logic can be implemented with a very high accuracy.In this logic any complex logic expression is considered a composition of logical atoms (i.e., of simple logical propositions).In other words, there are no emergent phenomena.Let us recall that the emergence is detected, when new patterns of a highly structured collective behavior appear and these patterns cannot be reduced to a linear composition of simple subsystems.
Notably, emergent phenomena are key phenomena in all self-organizing systems such as collective intelligent behaviors of animal groups: flocks of birds, colonies of ants, schools of fish, swarms of bees, etc. Emergence is observed in the economy as well: macroeconomic fluctuations, traffic jams, hierarchy of cities, motion picture industry and mass protest behavior [18].There are attempts to formalize the notion of emergence by algorithmic complexity theory.However, the Kolmogorov complexity function is not computable.There is no way to define the emergence by minimum linear compositions.Wolfram proposed a more useful approach in a mathematical definition of emergency [34].He showed that the behavior of one-dimensional cellular automata is divided into the following four cases: • there are limit points of the system, i.e. we obtain a homogeneous state of the system; • there are limit cycles of the system, i.e. we obtain separated periodic structures; • there are chaotic attractors, i.e. we face chaotic patterns; • there are complex localized structures.
In the last case we deal with an emergent phenomenon in the true sense.On the basis of the Wolfram's approach the so-called emergent computing has developed.In this kind of computing (i) the computation process is distributed over a set of parallel and autonomous processing units; (ii) each unit computes locally and can interact directly only with a small number of other units; (iii) there is a consistency among the processing units; (iv) there are more outputs, than inputs.One of the most studied instance of emergent computing is represented by swarm computing [5], [15].This computing is based on labor division in animal groups.Any swarm as a result of collective behavior, such as birds flocking or fish schooling, is a self-organizing system, where, on the one hand, each unit responds to local stimuli individually and, on the other hand, all together they accomplish a global task (transporting, eating, self-protecting, etc.).
In the PSO it is assumed that the particles (agents) know (i) their best position 'local best' (lb) and (ii) their neighborhood's best position 'global best' (gb).The next position is determined by velocity.Let xi(t) denote the position of particle i in the search space at time step t, where t is discrete.Then the position xi is changed by adding a velocity to the current position: where vi(t+1) = vi(t)+c1r1(lb(t)−xi(t))+c2r2(gb(t)−xi(t)) and i is the particle index, c1, c2 are acceleration coefficients, such that 0 ≤ c1, c2 ≤ 2, r1, r2 are random values (such that 0 ≤ r1, r2 ≤ 1) regenerated every velocity update.
One of the possible PSO algorithms can be exemplified by the bird flocking [21], [22].In flocks 'local best' and 'global best' of birds are defined by the following three rules: (i) collision avoidance (birds fly away before they crash into one another); (ii) velocity matching (birds fly about the same speed as their neighbors in the flock); and (iii) flock centering (birds fly toward the center of the flock as they perceive it).So, the position of a bird i at time t is given by its placement xi at time t − 1 shifted by its current velocity vi.This vi is determined by the rules (i) -(iii).
All the algorithms PSO, BFOA, ABC, COA, SSO, ACO are used to simulate swarms of different insects or animals.Let us try to answer the question, whether swarms can be considered an unconventional computer, i.e. whether swarms can calculate.
Each swarm is a natural transition system T S = (S, E, T, I), where: • S is the non-empty set of states; • E is the set of events; • T ⊆ S × E × S is the transition relation; • I ⊆ S is the set of initial states.
Any transition system is a labeled graph with nodes corresponding to states from S, edges representing the transition relation T , and labels of edges corresponding to events from E.
Let us consider some examples.

Ant Colony Transitions
Any ant colony is a swarm of ants localized first at the nest.This nest can be regarded as an initial state of ant colony transitions.Then ants use a special mechanism called stigmergy to build up all transitions.Stigmergy (stigma + ergon) means 'stimulation by work'.This mechanism has the following steps [8]: • At first ants are looking for food randomly, laying down pheromone trails.
• If ants find food, they return to the nest, leaving behind pheromone trails.So there is more pheromone on the shorter path than on the longer one.
• Ants prefer to go in the direction of the strongest pheromone smell.As a consequence, the concentration of pheromone is so strong on the shorter path, that all the ants prefer this path.
Thus, stigmergy allows ants to transport food to their nest in a remarkably effective way.Food localizations are considered new states and ant roads to food places are regarded as transitions.Let Pant = {n} be an initial state of ant transitions (i.e. the nest), Aant = {a1, a2, . . ., aj} be a set of food pieces (attractants) localized at different places, Vant = {r1, r2, . . ., ri} be a set of ant roads.So the ant colony transition system, T Sant = (Sant, Eant, Tant, Iant), can be defined as follows: • σ : Pant ∪ Aant → Sant assigning a state to each original point of the ant colony as well as to each attractant; • τ : Vant → Tant assigning a transition to each ant road; • ι : Pant → Iant assigning an initial state to the nest.
Each event of the set of events Eant is assigned to ant transitions in accordance with the following types of ant expansion: • direction (the ants move from one state / attractant / initial point to another state / attractant), • fusion (the ants move from different states / attractants to the same one state / attractant), • splitting (the ants move from one state / attractant / initial point to different states / attractants), • repelling (the ants stop to move in one direction).
The system T Sant can be used to solve the Travelling Salesman Problem formulated as follows: given a list of cities and the distances between each pair of cities, we must to define the shortest possible route that visits each city exactly once and returns to the origin city.This problem is NPhard.Let Pant be considered the origin city, Aant be a set of all other cities, and Vant be a set of all connections between cities.The Travelling Salesman Problem can be solved, because the ants lay down pheromone trails faster on the shortest path so that the shortest path gets reinforced with more pheromone to attract more future ants.As a result, pheromone trails on the edges between cities depend on the distance: more shorter, more attracting.This allows ants to find shorter tours of cities.

Bee Colony Transitions
A bee colony is another example of swarm intelligence [13].The bee nest is an initial state of bee colony transitions.Any bee colony exploits a mechanism called waggle dance to optimize the food transporting to the nest.This mechanism is as follows.In the nest there is an area for communication among bees.At this area the bees knowing, where the food source is precisely, exchange the information about the direction, distance, and amount of nectar on the related food source by a waggle dance.The direction of waggle dancing bees shows the direction of the food source in relation to the Sun, the intensity of the waggles is associated to the distance, and the duration of the dance shows the amount of nectar.Due to this form of communication the bee colony transitions are built up by the following steps [12]: • There are two kinds of bees: employed and unemployed.Employed bees know exactly, where a particular food source (nectar) is, and visit just this source.Unemployed bees do not know and seek a food source.The unemployed bees are divided into the following two groups: scouts and onlookers.A scout bee carries out search for new food sources without any guidance.An onlooker bee follows the instruction of a waggle dancing bee and visits the food source for the first time.An employed bee visits this source many times.So, the first step in constructing the bee transporting system is in sending scout bees.
• Then onlookers are sent.
• At the next step the food source is exploited by employed bees.
• An employed bee tests if the nectar amount of the new food source is higher than that of the previous one.If it is so, the bee memorizes the new place and forgets the old one.If the nectar amount decreased or exhausted and the employed bee dos not know a new place, this bee become an unemployed bee.So, at this step the employed bees exchange the nectar information of the food sources to change their decision.
Assume that P bee = {n} is an initial state of bee transitions (i.e. the bee nest), A bee = {a1, a2, . . ., aj} is a set of food sources (attractants) localized at different places, V onlooker = {r1, r2, . . ., r k } is a set of onlooker bee roads, and V employed = {r1, r2, . . ., r l } is a set of employed bee roads.Then the bee colony transition system, T S bee = (S bee , E bee , T bee , I bee ), can be defined thus: • σ : P bee ∪A bee → S bee assigning a state to each original point of the bee colony as well as to each attractant; • τ : V onlooker ∪ V employed → T bee assigning a transition to each bee road; • ι : P bee → I bee assigning an initial state to the bee nest.
In the set of events E bee there are the following types of labels for transitions: • direction (the onlooker or employed bees move from one state / attractant / initial point to another state / attractant), • fusion (the onlooker or employed bees move from different states / attractants to the same one state / attractant), • splitting (the onlooker or employed bees move from one state / attractant / initial point to different states / attractants), • repelling (the onlooker or employed bees stop to move in one direction).
The system T S bee , if we use only V employed as a set of roads, can solve the Travelling Salesman Problem, also.Thereby, P bee is examined as the origin city, A bee is a set of all other cities, and V employed is a set of all connections between cities.The point is that the greater the number of iterations in sending onlooker or employed bees, the higher the influence of the distance in attracting the bees to appropriate food sources.As a result, the shorter distance seems to be more attracting for employed bees.
There is another NP-hard problem that can be solved by T S bee , the so-called Generalized Assignment Problem formulated as follows: there are a number of agents and a number of tasks, each agent has a budget and each task assumes some cost and profit; we must find an assignment in which all agents do not exceed their budget and total profit of the assignment is maximized.In the case of the bee colony, the bees are regarded as agents, the nectar sources as tasks, the amount of nectar as profit, and the distance as cost.Hence, in this interpretation the bee colony can solve the Generalized Assignment Problem.

Paenibacillus vortex Transitions
Notice that there are bacteria with intelligent and successful swarming strategies such as Paenibacillus vortex [4].These strategies help Paenibacillus vortex bacteria to carry out a cooperative colonization of new territories.When Paenibacillus vortex is inoculated on hard agar surfaces with peptone, it develops complex colonies of vortices.When it is inoculated on soft agar surfaces, it organizes a special network of swarms with intricate internal traffic.In contrast to Escherichia coli, the Paenibacillus vortex swarms are sensitive to chemotaxis (attractants).As a consequence, the Paenibacillus vortex network is built up on the basis of interactions between swarms allowing them to transport nutrients, spores and other organisms [11], [29].
The four types of labels for transitions in the set of events Eone P.v.: • direction: the Paenibacillus vortex bacterium moves from one state / attractant / initial point to another state/attractant presented by a nutrient gradient; • tumbling: the Paenibacillus vortex bacterium can tumble for a while; • repelling: the Paenibacillus vortex bacterium stops to move in one direction, as it avoids some chemical concentrations; • repropuction: the health bacterium splits into two bacteria.
Paenibacillus vortex bacteria can be organized in swarms.The locomotion in a swarm can be explained hydrodynamically by collisions among the bacteria and by the boundary of the layer of lubricant collectively generated by them.However, interactions among swarms can be considered intelligent.Each swarm has a snake-like formation.It looks for food and can cross each other's trail.When food is detected, swarms change their direction.The Paenibacillus vortex swarms can split and fuse in accordance with topology of nutrients.
So, for these swarms we can propose another transition system T SP.v.swarm = (SP.v.• ι : PP.v.swarm → IP.v.swarm is to assign initial states to initial positions of Paenibacillus vortex swarms.
Each event of the set of events EP.v.swarm is assigned to swarm motions according to the following types of maneuvers: • direction: the Paenibacillus vortex swarm moves from one state / attractant / initial point to another state / attractant, • fusion: the Paenibacillus vortex swarms move from different states / attractants / initial points to the same one state/attractant, • splitting: the Paenibacillus vortex swarm moves from one state / attractant / initial point to different states / attractants (for the experimental details see [10]), • repelling: the Paenibacillus vortex swarm stops to move in one direction if it faces a repellent.
As we see, the Paenibacillus vortex transition system for swarms can solve the Travelling Salesman Problem, too.

Conclusion: Towards Physarum machines
In the project Physarum Chip Project: Growing Computers From Slime Mould [2] supported by FP7 we are going to design an unconventional computer on plasmodia of Physarum polycephalum.Notice that Physarum polycephalum is a one-cell organism whose plasmodia behave as a swarm organizing a network for transporting sources and information.In order to simulate Physarum polycephalum networks we have proposed Physarumsoft [28], a software tool for programming Physarum computing and simulating Physarum expansions.
Taking into account the fact that any plasmodium can be considered a typical intelligent swarm, we can use Physarumsoft for demonstrating computational powers of different swarms: ant colonies, bee colonies, and Paenibacillus vortex swarms.Indeed, let T S P.polycephalum = (S P.polycephalum , E P.polycephalum , T P.polycephalum , I P.polycephalum ) be a transition system for plasmodia and this system is defined standardly.Let f be a mapping from S P.polycephalum to S and from I P.polycephalum to I , where ∈ {ant, bee, P.v.swarm}.Assume that all transitions denoted by −→ are the same for all systems: T S P.polycephalum , T Sant, T S bee , T SP.v.swarm.For example, we have the same direction, fusion, splitting, and repelling.The function f is a homomorphism if and only if • for all s ∈ (S P.polycephalum ∪ I P.polycephalum ), if s −→ s , for some s ∈ S P.polycephalum , then f (s) −→ f (s ); • for all s ∈ S P.polycephalum , if f (s) −→ t, for some t ∈ S , then there exists s ∈ S P.polycephalum with s −→ s and f (s ) = t.
If f : S P.polycephalum ∪ I P.polycephalum → S ∪ I is a homomorphism as well as f −1 : S ∪ I → S P.polycephalum ∪ I P.polycephalum is a homomorphism, then f is an isomorphism.So, for any T S , where ∈ {ant, bee, P.v.swarm}, there is an isomorphism from S P.polycephalum to S and from I P.polycephalum to I .This means that it is enough to study the Physarum machine T S P.polycephalum to know computational properties of different swarms: ant colonies, bee colonies, Paenibacillus vortex swarms, etc.
According to our previous study of T S P.polycephalum we know that it is impossible to define Physarum transitions as atomic acts [26], [25].For instance, under the same conditions, the plasmodium can follow splitting or direction, fusion or direction, etc.Nevertheless, with a low accuracy we can implement some conventional algorithms in T S P.polycephalum .

CONVENTIONAL ALGORITHMS ON PHYSARUM MACHINES
It is known that, theoretically, Turing machines and Kolmogorov-Uspensky machines [17], [32] have the same expressibility power.In other words, the class of functions computable by these machines is the same.For the first time A. Adamatzky [1] experimentally showed that the Physarum machine T S P.polycephalum can be represented as a kind of Kolmogorov-Uspensky machines.Hence, we can implement conventional algorithms in T S P.polycephalum .
Let us show that T S P.polycephalum can be considered a Kolmogorov-Uspensky machine.Let Γ = S P.polycephalum ∪ I P.polycephalum be an alphabet, k = |E P.polycephalum | a natural number.We say that a tree is (Γ, k)-tree, if one of nodes is designated and it is called root and all edges are directed.Each node is labelled by one of signs of Γ and each edge from the same node is labelled by different numbers {1, . . ., k} (so, each node has not more than k edges).We see that by this definition of (Γ, k)-tree, the plasmodium grows from the one active zone (so, we simulate the expansion from the one nest of ants or bees, or from the one inoculation of Paenibacillus vortex swarms), where all attractants are labelled by signs of Γ and protoplasmic tubes (roads of ants or roads of bees) are labelled by numbers of {1, . . ., k}.Thus, T S P.polycephalum (as well as T Sant, T S bee , or T SP.vortex swarm) can be represented as a (Γ, k)-tree.
(Γ, k)-Physarum complex is any initial finite digraph which is connected (i.e. each vertex is accessible from the initial one by a directed path), each node is labelled by one of signs of Γ, and each edge from the same node is labelled by different numbers {1, . . ., k}.The set of all vertices of (Γ, k)-Physarum complex U is denoted by v(U ).
The r-neighborhood of (Γ, k)-complex is represented by a (Γ, k)-complex which consists of edges and vertices of initial complex that are accessible from initial vertex by a directed path that is not longer than r.Notice that r can be arbitrary.Any property of (Γ, k)-complex which is dependent just of r-neighborhood is called r-local property of (Γ, k)-complex.Hence, we can ever project Physarum transitions (using attractants and repellents) for inducing different numbers r and appropriate local properties.
A program of Physarum Kolmogorov-Uspensky machine is any r-local action transforming some (Γ, k)-complexes of growing plasmodia into other (Γ, k)-complexes of growing plasmodia: The algorithm of transformation complexes S → S * is as follows [17], [32]: • r-Neighborhood of complex S is the same as of U .• The initial vertex of W is an initial vertex of S and we delete in S all vertices (with appropriate edges) which are not accessible from the initial one.In this way we obtain S * .
Unfortunately, the computational complexity of implementations Kolmogorov-Uspensky machines on the Physarum polycephalum medium is very high.The point is that not every computable functions can be simulated by plasmodium behaviors: • first, the plasmodium has a free will and can make different decisions under the same conditions; • second, the plasmodium follows emergent patterns which are fully eliminated in conventional automata such as Kolmogorov-Uspensky machines, although these patterns are natural for occupying many attractants.
Thus, swarm intelligence can be reduced to conventional automata, but with very low accuracy.

UNCONVENTIONAL ALGORITHMS ON PHYSARUM MACHINES
Let us take a set of edges, X = {0, 1, . . ., p − 1}, where p − 1 = |E P.polycephalum |, from each node.The set of alphabet Γ = S P.polycephalum ∪I P.polycephalum is identified with attractants.Hence, we have assumed that at each step of plasmodium propagation there are not more than p−1 neighboring attractants which can be directly occupied.This means that our universe is p-adic and the plasmodium transition system can be coded by p-adic integer.Let us remember that the set of p-adic integers is denoted by Zp and each p-adic integer n ∈ Zp has the following meaning: where ai ∈ {0, 1, . . ., p − 1}, and the following notation: n = . . .aiai−1 . . .a1a0.
For each transition s −→ s , the state s ∈ Γ is called the child of s ∈ Γ.For each two transitions s −→ s and s −→ s , the state s ∈ Γ is called the grandchild of s ∈ Γ.Let us consider just strings γ0γ1 . . .γ k , where γ1 is a grandchild for γ0, γ2 is a grandchild for γ1, . . ., γ k is a grandchild for γ k−1 .Let each string γ0γ1 . . .γ k have a numeric value [γ0γ1 . . .γ k ] ∈ Zp which is defined as follows: • Let [γ0] denote an integer ≤ p − 1 for the node γ0 ∈ X.
This integer is equal to the number of children for γ0.
• Let [γ0] and [γ1] denote some integers ≤ p − 1 for the nodes γ0, γ1 ∈ X, where γ1 is a grandchild of γ0.The integer [γ0] is equal to the number of children for γ0 and the integer [γ1] is equal to the number of neighbours for γ1 occupied by the plasmodium.If γ1 has no grandchildren, then the value of γ0γ1 is coded by a p-adic integer . . .0000[γ1][γ0].
• . . .Let Aγ 0 be a set of all strings started from γ0 and this set be coded by [Aγ 0 ], a set of p-adic integers obtained for each string from Aγ 0 .Now we can define compositions of two sets Aγ 0 and A γ 0 , where γ0 = γ 0 : • If no strings from Aγ 0 have joint nodes with some strings from A γ 0 , then we have A γ 0 ,γ 0 = Aγ 0 ∪ A γ 0 and this system is coded by • If some strings from Aγ 0 have joint nodes with some strings from A γ 0 , then we have A γ 0 ,γ 0 = Aγ 0 +A γ 0 and this set contains all strings started from γ0 and started from γ 0 .The system A γ 0 ,γ 0 is coded by [A γ 0 ,γ 0 ].

CONCLUSIONS
In any intelligent swarm behaviour there are emergent patterns that cannot be reduced to linear combinations of subsystems properly.Therefore conventional algorithms such as Kolmogorov-Uspensky machines have very low accuracy of their implementations on swarm systems (Section 3).Nevertheless, we can define a p-adic valued logic that can describe a massive-parallel behavior of swarms (Section 4).
there is a, b in S and γ(b) is defined, then a, γ(b) is an edge in S with the same number as a, b .• If a ∈ U , b ∈ S\U , there is a, b in S and δ(a) is defined, then δ(a), b is an edge in S with the same number as a, b (due to injectivity of δ we have different numbers for different edges from the same vertex).

Figure 1 :
Figure 1: At each step of plasmodium propagation, there are only two attractants which can be occupied.At the first time step the plasmodium expansion is coded by the 3-adic integer . . .000001.Let us analyze the case when we have two strings γ0γ1 . . .γ k and γ0γ 1 . . .γ m started from the same state γ0.Suppose that γi k (0 ≤ i k ≤ k) and γ im (0 ≤ im ≤ m) have some neighboring attractants occupied by the plasmodium.This means that we face a splitting of the plasmodium at the node γ0.Assume that there is not more splitting for nodes from γ0γ1 . . .γ k and γ0γ 1 . . .γ m and only γ0γ1 . . .γ k and γ0γ 1 . . .γ m are non-empty.Then the transition system is coded by the set {[γ0γ1 . . .γ k ], [γ0γ 1 . . .γ m ]}.Another similar situation is observed when we have two strings γ0γ1γ2 . . .γ k and γ0γ1γ 2 . . .γ m started from the same state γ0 and with the splitting at the node γ1.If only γ0γ1γ2 . . .γ k and γ0γ1γ 2 . . .γ m are non-empty, then the transition system is coded by the set {[γ0γ1γ2 . . .γ k ], [γ0γ1γ 2 . . .γ m ]}.

Figure 2 :
Figure 2: At each step of plasmodium propagation, there are only three attractants which can be occupied.At the first time step the plasmodium expansion is coded by the 4-adic integer . . .000002.

Figure 3 :
Figure 3: At each step of plasmodium propagation, there are not more than four attractants which can be occupied.At the first time step the plasmodium expansion is coded by the 5-adic integer . . .000002.

Figure 4 :::
Figure 4: At each step of plasmodium propagation, there are not more than four attractants which can be occupied.At the time step t > 0 the plasmodium expansion is coded by the 4-adic integer . . .00000232.
swarm → TP.v.swarm, where VP.v.swarm = {r1, r2, . . ., r k } is a set of paths for each Paenibacillus vortex swarm.The function τ is to assign a transition to each path of each Paenibacillus vortex swarm;