Advertisement

Journal of Computational Social Science

, Volume 2, Issue 1, pp 77–84 | Cite as

Dynamic organization of flocking behaviors in a large-scale boids model

  • Norihiro MaruyamaEmail author
  • Daichi Saito
  • Yasuhiro Hashimoto
  • Takashi Ikegami
Research Article

Abstract

A simulation of a half-million flock is studied using a simple boids model originally proposed by Craig Reynolds. It was modeled with a differential equation in 3D space with a periodic boundary. Flocking is collective behavior of active agents, which is often observed in the real world (e.g., starling swarms). It is, nevertheless, hard to rigorously define flocks (or their boundaries). First, even within the same swarm, the members are constantly updated, and second, flocks sometimes merge or divide dynamically. To define individual flocks and to capture their dynamic features, we applied a DBSCAN and a non-negative matrix factorization (NMF) to the boid dataset. Flocking behavior has different types of dynamics depending on the size of the flock. A function of different flocks is discussed with the result of NMF analysis.

Keywords

Flocking Boids NMF Parallel computing 

Introduction

Collective behaviors can vary qualitatively in accordance with the number of agents, i.e., the size of a colony or group. According to the actual observation, the individual bees change their behaviors depending on the colony size [9], while fish change their performance of sensing the environmental gradient depending on the school size [7].

In previous works [3, 5, 6], we simulated a half-million birds ensemble using a boids model [8] and found that qualitatively different behavior emerges when the total number of individuals exceeds around 10,000. Flocks of different sizes and forms interact in a parallel way. Different types of fluctuation (i.e., density or velocity fluctuation) become dominant in different flock sizes; local density fluctuation dominates in larger flocks, while velocity fluctuation dominates in smaller flocks.

One purpose of this paper is to revisit the collective behavior of large-scale flocking behavior with a more effective simulation algorithm. In simple clustering methods such as density-based spatial clustering of applications with noise (DBSCAN) or self-organizing maps (SOM), we consider the different velocities of boids gives better clustering results [5]. In this paper, we compare the results of DBSCAN clustering with the results of non-negative matrix factorization (NMF) to study the dynamic modes of flocking behavior.

Simulation model and method

Boids model

The dynamics of individuals on the boids model are described by three simple rules based on Craig Reynold’s original model [8]. We translated the rules as a differential equation in 3D space with a periodic boundary condition.
$$\begin{aligned} \Delta \varvec{v_i} &= W_{\text {att}} \left( \varvec {x_i} - \frac{\Sigma _{j\in S_{\text {att}}} \varvec{x_j}}{n_{\text {att}}}\right) + W_{\text {rep}} \left( \Sigma _{j\in S_{\text {rep}}} \frac{\varvec{x_i} - \varvec{x_j}}{|\varvec{x_i} - \varvec{x_j}|}\right) \\ & \quad + W_{\text {ali}} \left( \varvec{v_i} - \frac{{\Sigma }_{j\in S_{\text {ali}}} v_j }{n_{\text {ali}}}\right) . \end{aligned}$$
The position of each boid (i) is updated based on the velocity, \(v_{i}\), deterministically and iteratively. The attraction, repulsion, and alignment terms are represented by the first, second, and third terms, respectively. Each rule has an interaction range around each agent, as denoted by \(S_{\text {att}}\), \(S_{\text {rep}}\), and \(S_{\text {ali}}\), respectively. In the equation, the amplitudes of those interactions are given by \(W_{\text {att}}\), \(W_{\text {rep}}\), and \(W_{\text {ali}}\), respectively. The interaction ranges, with a 3D circular sector of their angles toward the front, are fixed as \(\pi /2\), \(\pi /2\), and \(\pi /3\), respectively. To avoid any excessive increase or decrease in speed, we bound the amplitude of speed between \(V_{\min }\) and \(V_{\max }\), which we consider as important parameters. The system is investigated using the parameter values given in Table 1, which are the same as in our previous work [3, 5, 6].
Table 1

Parameter values used in the simulation

Parameter

Value

Parameter

Value

Range of attraction

0.05 (unit)

Angle of attraction

\(\pi /2\)

Range of alignment

0.05 (unit)

Angle of alignment

\(\pi /3\)

Range of repulsion

0.01 (unit)

Angle of repulsion

\(\pi /2\)

Field size

0.4–3.2 (unit)

Number of individuals

1024–524,288

Max speed

0.005 (unit/step)

Min speed

0.001 (unit/step)

\(W_{\text {att}}\)

0.008

\(W_{\text {ali}}\)

0.06

\(W_{\text {rep}}\)

0.002

Initial position

Randomly distributed

Initial velocity

Randomly distributed

Time step increment

1

Density

16,384 (num/unit\(^3\))

Boundary condition

Periodic

Parallelization

Unlike the previous works, which are based on GPGPU computations [1, 2, 6], we perform the parallelized simulation with a computer cluster for investigating the dynamics of large populations. The advantage of using a computer cluster is its high scalability for the number of agents compared with GPGPU computation.

Initially, we simply partitioned the 3D simulation space into subspaces, which corresponded to each simulation node. Each simulation node only calculates and updates the position and velocity of agents belonging to its subspace, then the nodes exchange the result about agents which leave or enter the subspace with neighboring nodes. Since the computer cluster we used has six-dimensional inter-node connections (K-computer), three dimensions are adopted for arranging the simulation space.

In each simulation node, one of the simple algorithms that calculates the distance matrix of all agents needs time complexity \(O(N^2)\). But if we assume that there is an upper limit on the local density and the interaction distance between individuals is sufficiently short compared to the size of the space, this computation time can be reduced to O(N). In particular, the simulation space is divided into a grid about twice as large as the interaction distance, and individuals belonging to each grid are managed as a list. It is only necessary to calculate the distance matrix in this list and lists of the adjacent grid (see Fig. 1).
Fig. 1

Diagram of parallelization methods in a simulation node

A classification algorithm

We visualize the 3D boids dynamics as shown in Fig. 2.
Fig. 2

2D projection of simulation result with N = 32,768. Ball-like patterns (large black lump) and snake-like (string-like) patterns can be observed. The string-like swarm can be seen to connect the ball-like swarm by individual fast flowing

As seen in this figure, agents are inhomogeneously distributed in the space by taking characteristic shapes. Many flocks mutually interact with each other and dynamically change. As is discussed in the previous works [3, 6], the size distribution of different flocks show a power-law behavior and different kinds of fluctuation exist for different flock sizes [5].

However, all these analyses depend on how we classify flocks and on what type of algorithm we apply. We mainly applied two kinds of clustering algorithm; DBSCAN is a density based clustering algorithm that (briefly speaking) gathers the internal points surrounded by more than k points and the peripheral points that have the internal points in their neighbors but sparsely surrounded.

Figure 3 demonstrates an example of classifying the distinct flocks after dividing all the agents into two classes by their velocity amplitude. As seen in the upper column of the figure, we have slow boids agents (broad peak on the left) and fast boids agents (sharp peak on the right). Then we apply DBSCAN to each group to see how different flocks distribute over space (shown in the lower column).
Fig. 3

Top: distribution of velocity and velocity fluctuation of all individuals. Bottom: result of DBSCAN clustering for fast group and slow group. Different colors represent different flocks

The most unexpected observation here is that fast agents exist on the surface of larger flocks and also form string-like flocks. Flocks are organized temporally and will be generated or collapsed spontaneously. By the simple observation, agents escape from large flocks by forming string-like patterns. We thus adopted the following method to extract dynamic modes associated with the spontaneous organization and collapsing of flocking behaviors.

Non-negative matrix factorization analysis

To understand when and which type of dynamics modes of flocks are organized and collapsed, we used non-negative matrix factorization (NMF), which has become a popular decomposition algorithm [4]. Given a non-negative matrix \(\varvec{X}\) (\(m \times n\) matrix, \(\varvec{X}\)), NMF finds the non-negative matrix factors \(\varvec{W}\) and \(\varvec{H}\) such that
$$\begin{aligned} \varvec{X}\simeq \varvec{W} \varvec{H}. \end{aligned}$$
In the case of the current analysis, n is the number of individual agents and m is the size of the time frame. Each matrix entry is given by the magnitude of the agent’s velocity. This matrix can be approximately factorized into the \(m \times r\) matrix, \(\varvec{W}\) and the \(r \times n\) matrix, \(\varvec{H}\). Since relatively few basis vectors are used to represent any data vectors, a good approximation can only be achieved if the basis vectors discover the structure that is latent in the data. We here adopted the generalized Kullback–Leibler (KL) divergence to determine the matrix factorization.
A critical parameter in NMF is the factorization rank r, which defines the number of dynamic modes used to approximate the target matrix. Using the NMF method and the target matrix, a common way of setting the value of r is to try different values and compute some result quality measures, and then choose the best value for r accordingly. Here, we arbitrarily choose an r value that seems to correspond to flocking behaviors.
Fig. 4

Result of non-negative matrix factorization (NMF) conducted using the data with time steps of 1500–2500 and \(r=64\). Top: visualization of velocity component matrix extracted by NMF. The image shows the most dominant 16 rows in 64 components. Red represents high values and blue represents low values. The horizontal axis corresponds to time. The components matrix values are weighted by the number of agents. Therefore, this can be regarded as representing the momentum of the dynamics mode. Middle: three top dynamics modes detected by NMF (corresponds to top three rows of top figure). Bottom: three visualizations of boids at time steps of 1700, 2050, and 2400. Red points indicate individuals belonging to dynamics modes 0, 1 and 2

As seen in Fig. 4, the extracted modes do not correspond to actual flocking behaviors, partially because no spatial information is taken into account in this analysis. It should also be noted that the larger flocks have agents more slower, so the agents in a larger flock will not be visible in the second column of the figure.

On the other hand, we see that some of the extracted modes correspond to actual flocks in space. For example, in mode 1, where the time step is 2400, a string-like subgroup of agents escapes from or comes into the main big group. This phenomenon is captured by NMF as the dominant contribution to a system in the first and second column. In other words, escaping boids from a large, but slow flock have a faster speed and a string-like shape. This picture is consistent with the previous DBSCAN classification.

Based on this figure and on applying NMF to other time frames, we hypothesize that spontaneous collapse of flocks can be captured by the NMF analysis.

Discussion

Large-scale collectives can be a source for emergent phenomena [3]. Considering biological organizations (e.g., DNA, cells, organs, bodies), we expect new structures to emerge for each spatial scale of the order of roughly three or four. Although the organization of flocks is hard to define formally, we tried to define it in the space–time entity. NMF analysis in this paper provides one candidate for finding such emergent phenomena. More sophisticated analysis by using NMF is currently in progress.

Notes

Acknowledgements

This study is supported by MEXT as “Challenging Research on Post-K Computer”: Modeling and Application of Multiple Interaction of Social and Economic Phenomena (Project ID: hp180208) and partially supported by the JSPS KAKENHI project A “Organization and Realization of Collective Intelligence Based on the Ethological and Life-Theoretical Investigations” (17H01249).

References

  1. 1.
    Erra, U., Frola, B., Scarano, V., & Couzin, I. (2009) An efficient GPU implementation for large scale individual-based simulation of collective behavior. In 2009 International Workshop on High Performance Computational Systems Biology (pp. 51–58). IEEE .  https://doi.org/10.1109/HiBi.2009.11
  2. 2.
    Husselmann, A.V., & Hawick, K.A. (2011). Simulating species interactions and complex emergence in multiple Flocks of boids with GPUS. In: Parallel and Distributed Computing and Systems. ACTAPRESS, Calgary, AB, Canada.  https://doi.org/10.2316/P.2011.757-012
  3. 3.
    Ikegami, T., Mototake, Y. I., Kobori, S., Oka, M., & Hashimoto, Y. (2017). Life as an emergent phenomenon: studies from a large-scale boid simulation and web data. Philosophical Transactions Series A, Mathematical, Physical, and Engineering Sciences, 375(2109), 20160351.  https://doi.org/10.1098/rsta.2016.0351.CrossRefGoogle Scholar
  4. 4.
    Lee, D. D., & Seung, H. S. (1999). Learning the parts of objects by non-negative matrix factorization. Nature, 401(6755), 788–791.  https://doi.org/10.1038/44565.CrossRefGoogle Scholar
  5. 5.
    Maruyama, N., Hashimoto, Y., Mototake, Y., Saito, D., & Ikegami, T. (2017). Revisiting classification of large scale flocking. In: SWARM 2017: The 2nd International Symposium on Swarm Behavior and Bio-Inspired Robotics (pp. 307–310)Google Scholar
  6. 6.
    Mototake, Y., & Ikegami, T. (2015). A Simulation Study of Large Scale Swarms. In: SWARM 2015: The First International Symposium on Swarm Behavior and Bio-Inspired Robotics October 28–30, Kyoto, Japan (pp. 446–450). No. i.Google Scholar
  7. 7.
    Puckett, J. G., Pokhrel, A. R., & Giannini, J. A. (2018). Collective gradient sensing in fish schools. Scientific Reports, 8(1), 1–11.  https://doi.org/10.1038/s41598-018-26037-9.CrossRefGoogle Scholar
  8. 8.
    Reynolds, C.W., W., C., & Reynolds, W., C. (1987). Flocks, herds and schools: A distributed behavioral model. In Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques—SIGGRAPH ’87. vol. 21, pp. 25–34. ACM Press, New York, New York, USA .  https://doi.org/10.1145/37401.37406
  9. 9.
    Smith, M. L., Koenig, P. A., & Peters, J. M. (2017). The cues of colony size: how honey bees sense that their colony is large enough to begin to invest in reproduction. Journal of Experimental Biology, 220(9), 1597–1605.  https://doi.org/10.1242/jeb.150342.CrossRefGoogle Scholar

Copyright information

© Springer Nature Singapore Pte Ltd. 2019

Authors and Affiliations

  1. 1.The Graduate School of Arts and SciencesUniversity of TokyoTokyoJapan

Personalised recommendations