# Swarm Modelling with Dynamic Mode Decomposition

Emma Hansen1∗, Steven L. Brunton2 and Zhuoyuan Song3
1 Mechanical Engineering, University of Washington, Seattle, WA 98195, United
States
2 Mechanical Engineering, University of Washington, Seattle, WA 98195, United
States
3 Mechanical Engineering, University of Hawai‘i at Mānoa, Honolulu, HI 96822,
United States

###### Abstract

Modelling biological or engineering swarms is challenging due to the
inherently high dimension of the system, despite the often low-dimensional
emergent dynamics. Most existing swarm modelling approaches are based on first
principles and often result in swarm-specific parameterizations that do not
generalize to a broad range of applications. In this work, we apply a purely
data-driven method to (1) learn local interactions of homogeneous swarms
through observation data and to (2) generate similar swarming behaviour using
the learned model. In particular, a modified version of dynamic mode
decomposition with control, called swarmDMD, is developed and tested on the
canonical Vicsek swarm model. The goal is to use swarmDMD to learn inter-agent
interactions that give rise to the observed swarm behaviour. We show that
swarmDMD can faithfully reconstruct the swarm dynamics, and the model learned
by swarmDMD provides a short prediction window for data extrapolation with a
trade-off between prediction accuracy and prediction horizon. We also provide
a comprehensive analysis on the efficacy of different observation data types
on the modelling, where we find that inter-agent distance yields the most
accurate models. We believe the proposed swarmDMD approach will be useful for
studying multi-agent systems found in biology, physics, and engineering.

_Keywords–_ Swarms, multi-agent systems, reduced-order models, dynamic mode
decomposition, control, optimization

††∗ Corresponding author (ehansen@math.ubc.edu).

##  I Introduction

Emergent behaviours, such as swarming and flocking, are ubiquitous in natural
and engineered systems. Fascinating phenomena including birds flocking, fish
schooling, and ants colonizing have intrigued generations of biologists to
discover and understand the rules of life [1, 2, 3]. Fueled by the interplay
between the intra-swarm and swarm-environment interactions, swarms often
exhibit complex multi-scale dynamics, making them an interesting research
subject also for physicists and mathematicians. Inspired largely by the
biology community, engineers and roboticists study swarms in order to
understand the emergence of macroscopic organized behaviours for dynamics
modeling and prediction [4, 5, 6, 7], to build robotic platforms to directly
interact with biological swarms [8, 9, 10], and ultimately to design scalable
control and planning algorithms for artificial swarms [11, 12, 13, 14, 15, 16,
17].

One long-standing challenge in the study of swarms and emergent behaviours is
the discovery of optimal interaction laws that lead to various macroscopic
phenomena resembling our observations in nature. Although several
mathematically simple swarm interaction laws have been proposed to generate
compelling swarm or flocking behaviour [18, 19, 20, 21, 22, 23], there remains
a need for a principled approach that allows the extraction of the fundamental
interaction law from observations alone. To this end, in other fields data-
driven methods have proven effective in identifying unknown dynamics from
observation [24, 25, 26]. However, data-driven discovery of swarm interactions
is still nascent [27, 28].

Collective behaviour in biological swarms has been studied in depth across
organisms ranging from cellular systems [29] and midges [7], to jackdaw flocks
[30] and humans playing baseball [31]. Studies on the decision making
processes of biological swarms have shown geometry often plays a roll,
resulting in a binary process used across biological scales [32]; whereas
other studies have shown further structure is often needed to make general
statements across scales [29]. Much research has been conducted on the
initiation of large collective movements [30], showing that environmental cues
play an important role in their emergence [33]; and on disruptions to
collective behaviour showing that genetic mutations in zebra fish can cause
reduced cohesion in formations [34]. Such studies inform the development and
evaluation of methods for determining governing laws of swarm interactions
[35].

Many methods to learn swarm laws take a model-based approach [35]. Some of the
simplest models, aimed only at recreating the basic structure of emergent
patterns, include the alignment-based Vicsek model and its modifications [36,
37], a stochastic model by Aoki [38], and attraction-repulsion models [18,
39]. Although biologically inspired, these models were developed with the aim
of recreating similar dynamics to those seen in biological swarms, and not at
determining the actual underlying governing equations. Model-based methods
that do aim to discover governing equations, often make simplifying
assumptions [40, 41]. In recent years, machine learning [42] and game
theoretic [43] approaches are becoming more widely used.

Fully capturing the governing laws of a swarm system with a model-based
approach would likely require in a very complicated model. This promotes the
use of model-free, or data-driven methods, where the hope is that these
approaches can accurately capture dynamics without the need for restrictive
assumptions. Many model-free approaches exploit known properties of swarms,
such as the interchangeability of agents [27], the inherent network dynamical
interactions [31], and how pairwise distances between agents play an important
role in interactions [44].

In our proposed method, we take a fully data-driven approach inspired by
dynamic mode decomposition (DMD) [45, 46, 26, 47, 48, 49], a method
originating in fluid dynamics and capable of capturing system dynamics across
timescales. Using DMD with control as a starting point [50], we exploit the
general idea of how swarm agents update their states — using information about
their own state and their neighbours’ — to develop dynamic mode decomposition
for swarms (swarmDMD). The resulting modelling framework produces an optimal
linear approximation, distinguishing our approach from others which may seek
nonlinear estimates. As swarmDMD is a purely data-driven approach, with no
assumptions made for specific swarm systems, it is generalisable to many kinds
of multi-agent systems, and can use different types of state data that are
relevant to the dynamics. For data generated by the Vicsek model, it was shown
via a comparison of data types that swarmDMD performs the best with relative
position information (i.e., inter-agent distance), resulting in accurate
recreations of swarm dynamics during the training period and a window of
accurate prediction post-training.

The remainder of this paper is organized as follows. Section II provides an
overview of DMD for data-driven approximation of nonlinear dynamics. Section
III introduces swarmDMD and how it is developed from DMD. Section IV covers
the numerical simulation set-up, including the Vicsek model and modification
used for the ground truth swarm data sets, and evaluation metrics for the
swarmDMD results. Section V discusses the experimental results and major
findings.

##  II Preliminaries

In this section, we introduce important background material and concepts used
in the development of swarmDMD. Beginning with DMD, we then describe the DMD
with control variant, on which swarmDMD is based.

We focus on swarm behaviours that are induced by local interactions between
swarm agents. These emergent behaviours often give rise to coherent swarm
structures that can persist with inherently low-dimensional dynamics. For such
systems, a method like DMD, which captures low-order dynamics in high-order
systems, is promising in modelling the dominant modes of the systems and
providing a short window for prediction.

DMD approximates the dynamics of a high dimensional, and potentially
nonlinear, system with a linear model that advances the system state forward
in time [45, 46]. Although DMD was originally developed to study fluid systems
[45, 47], it has since been applied to a wide range of physics systems, such
as neuroscience [51, 52], and it has also been rigorously connected to
nonlinear systems through Koopman operator theory [46, 53, 49]. Let us
consider $\mathbf{x}(t)\in\mathbb{R}^{n}$ as the state vector of an
$n$-dimensional dynamical system at time $t$. In a discrete-time
representation with uniform interval $\Delta t$, we can denote the system
state at each time step with subscript $k\in\mathbb{Z}$ such as
$\mathbf{x}_{k}=\mathbf{x}(k\Delta t)$. Now consider $T$ time samples of the
state, i.e., $k\in\\{1,...,T\\}$, and define two state snapshot matrices
$\mathbf{X}=[\mathbf{x}_{1}\ ...\ \mathbf{x}_{T-1}]$ and
$\mathbf{X}^{\prime}=[\mathbf{x}_{2}\ ...\ \mathbf{x}_{T}]$. The goal of DMD
is to compute a state transition matrix, $\mathbf{A}\in\mathbb{R}^{n\times
n}$, that propagates the data forward by one time step, i.e., $\mathbf{A}$
such that $\mathbf{X}^{\prime}=\mathbf{A}\mathbf{X}$. To do so, DMD uses a
singular value decomposition (SVD) to compute the pseudo-inverse of the data
matrix $\mathbf{X}$, which has the added benefit of allowing a reduced-order
approximation to $\mathbf{X}$ based on how many modes, or singular values, are
kept. Thus, $\mathbf{A}$ provides a linear approximation of the system
dynamics.

The process of calculating $\mathbf{A}$ can be broken into the four steps
outlined below [26, 54]:

  1. 1.

Perform SVD on $\mathbf{X}$:

$\mathbf{X}=\mathbf{U}\mathbf{\Sigma}\mathbf{V}^{*},$

where $\mathbf{V}^{*}$ denotes the complex conjugate transpose of
$\mathbf{V}$.

  2. 2.

Project $\mathbf{A}$ onto the first $r$ most dominant modes:

$\widetilde{\mathbf{A}}=\mathbf{U}^{*}_{r}\mathbf{A}\mathbf{U}_{r}=\mathbf{U}^{*}_{r}\mathbf{X}^{\prime}\mathbf{V}_{r}\mathbf{\Sigma}^{-1}_{r},$

where $\mathbf{U}_{r}\in\mathbb{R}^{n\times r}$,
$\mathbf{V}_{r}\in\mathbb{R}^{(T-1)\times r}$, and
$\mathbf{\Sigma}_{r}\in\mathbb{R}^{r\times r}$ are the $r$-truncated singular
vector and value matrices.

  3. 3.

Compute the eigenvalues and eigenvectors of $\widetilde{\mathbf{A}}$:

$\widetilde{\mathbf{A}}\widetilde{\mathbf{W}}=\widetilde{\mathbf{W}}\mathbf{\Lambda}.$

The eigenvalues of $\widetilde{\mathbf{A}}$ are also eigenvalues of
$\mathbf{A}$.

  4. 4.

Compute the eigenvectors of $\mathbf{A}$:

$\mathbf{W}=\mathbf{X}^{\prime}\mathbf{V}_{r}\mathbf{\Sigma}^{-1}_{r}\widetilde{\mathbf{W}}.$

With the eigenvalues and eigenvectors of $\mathbf{A}$, the future state can be
predicted. Knowing $\mathbf{A}=\mathbf{W}\mathbf{\Lambda}\mathbf{W}^{*}$, and
that $\mathbf{A}$ provides a one time step forward approximation, we can write
$\mathbf{x}_{k+1}=\mathbf{A}\mathbf{x}_{k}$ and, we can write $\mathbf{x}_{k}$
as:

$\displaystyle\mathbf{x}_{k+1}\approx\mathbf{W}e^{k\Delta
t\mathbf{\Lambda}}\mathbf{W}^{*}\mathbf{x}_{1}.$

By projecting onto the dominant modes in Step 2, DMD provides a
computationally efficient way to compute the transition matrix $\mathbf{A}$,
thus making it a useful method when dealing with high-dimensional dynamics
[55, 56], such as for multi-agent systems. The dominant modes are those
singular vector groups with the largest magnitude singular values, indicating
that those corresponding singular vectors have the most influence on the
structure of the matrix. By choosing to keep only the most dominant modes, one
still retains the key properties of the matrix, without the computational
burden of performing an eigen-decomposition on a full-rank matrix.

Standard DMD does not explicitly model the influence of control inputs.
However, it is often convenient to represent the dynamics of an individual
swarm agent using a state-space model with a control input that is dependent
on the states of its neighboring agents. DMD with control (DMDc) [50] captures
this structure and is used as the base for the development of swarmDMD. DMDc
is used to determine the state transition matrix, $\mathbf{A}$, and the
control matrix, $\mathbf{B}$, of a linear system approximation of the form:

$\displaystyle\mathbf{x}_{k+1}=\mathbf{A}\mathbf{x}_{k}+\mathbf{B}\mathbf{u}_{k},$
(1)

where $\mathbf{x}_{k}$ is the system state and $\mathbf{u}_{k}$ is the control
input at time step $k$. Depending on whether $\mathbf{B}$ is known, DMDc can
be used to learn either just the $\mathbf{A}$ matrix or both $\mathbf{A}$ and
$\mathbf{B}$. As we will show in Section III, (1) motivates the development of
swarmDMD.

##  III DMD for Swarms

The swarmDMD algorithm is designed to use data we can observe/measure from the
swarm, such as agent position, velocity, and inter-agent distance, to create
an augmented “state” vector, which is used as the control input to an agent’s
position dynamics. We assume that the coupled multi-agent dynamics can be
considered control-affine. The goal is to determine the feedback control
matrix, which determines the inter-agent interactions.

Consider a swarm of $N$ agents. We define the 2D location of agent-$i$ at time
$t$ as
$\mathbf{p}^{i}_{t}=\mathbf{p}^{i}(t)\triangleq[x^{i}(t),y^{i}(t)]^{\textsf{T}}$
for $i\in(1,2,\dots,N)$, the velocity as
$\mathbf{v}^{i}_{t}=\mathbf{v}^{i}(t)\triangleq[v_{x}^{i}(t),v_{y}^{i}(t)]^{\textsf{T}}$,
and the heading as $\theta_{t}^{i}=\theta^{i}(t)$. The state of agent-$i$ at
time $t$ is denoted by $\mathbf{x}^{i}_{t}$, which could be comprised of any
of the aforementioned variables. By stacking the states of every agent we
obtain the state vector
$\mathbf{x}_{t}=[(\mathbf{x}^{1}_{t})^{\textsf{T}},...,(\mathbf{x}^{N}_{t})^{\textsf{T}}]^{\textsf{T}}\in\mathbb{R}^{Nw}$,
where $w$ is the number of state variables chosen for each agent. For any
variable written without a superscript, it is assumed that this variable has
been formed by concatenating over all agents. We consider discrete-time
systems, with $t=k\Delta t$ for some time step $\Delta t$, and simplify the
notation of time index to a subscript $k$.

Recall from the system dynamics in (1) that we must learn the forcing term
$\mathbf{B}\mathbf{u}_{k}$. Assuming the agents operate under a feedback-type
control law, we write $\mathbf{u}_{k}^{i}=\mathbf{F}^{i}\mathbf{y}_{k}^{i}$,
where $\mathbf{y}_{k}^{i}$ is an augmented state vector used to determine the
control input, and $\mathbf{F}^{i}$ is the feedback matrix for agent-$i$. This
augmented state vector $\mathbf{y}_{k}^{i}\in\mathbb{R}^{m}$ can include
measurement data of individual agents, such as agent position, velocity, and
heading as defined before, as well as derived quantities such as relative
position $\Delta\mathbf{p}_{k}^{ij}=|\mathbf{p}_{k}^{i}-\mathbf{p}_{k}^{j}|$,
relative distance $d^{ij}_{k}=||\mathbf{p}_{k}^{i}-\mathbf{p}_{k}^{j}||_{2}$,
relative heading $\Delta\theta^{ij}_{k}=|\theta_{k}^{i}-\theta_{k}^{j}|$,
relative velocity
$\Delta\mathbf{v}_{k}^{ij}=|\mathbf{v}_{k}^{i}-\mathbf{v}_{k}^{j}|$, and
relative speed $\Delta
v_{k}^{ij}=\left|||\mathbf{v}_{k}^{i}||_{2}-||\mathbf{v}_{k}^{j}||_{2}\right|$.
By stacking the control vectors we obtain
$\mathbf{y}_{k}=[(\mathbf{y}_{k}^{1})^{\textsf{T}},...,(\mathbf{y}_{k}^{N})^{\textsf{T}}]^{\textsf{T}}\in\mathbb{R}^{Nm}$.
Thus, (1) may be rewritten as:

$\displaystyle\mathbf{x}_{k+1}=\mathbf{x}_{k}+\mathbf{K}\mathbf{y}_{k},$ (2)

where $\mathbf{K}\in\mathbb{R}^{Nw\times Nm}$, and
$\mathbf{K}=\mathbf{B}\mathbf{F}$. Note that we have fixed the state dynamics
to be the identity, $\mathbf{A}=\mathbf{I}$, so that all interactions
influencing an agent are considered as external inputs and don’t depend on its
own internal state. Rearranging (2) yields

$\displaystyle\mathbf{x}_{k+1}-\mathbf{x}_{k}=\mathbf{K}\mathbf{y}_{k},$ (3)

resulting in a system that resembles the original DMD regression. Thus, DMD
can be used to determine $\mathbf{K}$. As in standard DMD, $T$ snapshots are
arranged into matrices $\mathbf{X}=[\mathbf{x}_{1}\ ...\ \mathbf{x}_{T-1}]$,
$\mathbf{X}^{\prime}=[\mathbf{x}_{2}\ ...\ \mathbf{x}_{T}]$ and
$\mathbf{Y}=[\mathbf{y}_{1}\ ...\ \mathbf{y}_{T-1}]$. Equation (2) may be
written in matrix form as

$\displaystyle\mathbf{X}^{\prime}-\mathbf{X}=\mathbf{K}\mathbf{Y}.$

By defining $\mathbf{S}=\mathbf{X}^{\prime}-\mathbf{X}$, we arrive at a linear
approximation of the swarm dynamics

$\mathbf{S}=\mathbf{K}\mathbf{Y}.$ (4)

Taking the rank-$r$ SVD of $\mathbf{Y}$ to obtain
$\mathbf{U}\in\mathbb{R}^{Nm\times r},\mathbf{\Sigma}\in\mathbb{R}^{r\times
r}$, and $\mathbf{V}\in\mathbb{R}^{(T-1)\times r}$, it is possible to
approximate $\mathbf{K}$ as:

$\displaystyle\mathbf{K}\approx\mathbf{S}\mathbf{V}\mathbf{\Sigma}^{-1}\mathbf{U}^{*},$
(5)

which can be used to predict future dynamics as:

$\displaystyle\mathbf{x}_{k+1}=\mathbf{x}_{k}+\mathbf{K}\mathbf{y}_{k}.$

The swarmDMD process, from data collection to the computation of $\mathbf{K}$,
is outlined in Figure 1.

Figure 1: Illustration of the swarmDMD process for 2D swarm data, from data
collection to the computation of the control matrix $\mathbf{K}$. Data is
first collected from the desired swarm, in this case position information
(blue), and is then used to calculate other desired properties such as
velocity (orange), heading (yellow), and inter-agent distance (brown). We then
take the state, $\mathbf{x}$, to be position, and the control, $\mathbf{y}$,
to be the concatenation of position, velocity, heading, and inter-agent
distance. This is then used to calculate the feedback control matrix
$\mathbf{K}$.

We note that (4) is different from the conventional DMD formulation in that
$\mathbf{S}$ may have a different shape than $\mathbf{Y}$, leading to a
rectangular $\mathbf{K}$. There are several reasons for this formulation, as
opposed to simply stacking the desired data (velocity, heading, inter-agent
distance, etc.) in the state vector and using standard DMD. First, the
swarmDMD formulation yields a particular interpretation, as discussed below.
Further, it can be shown that for any combination of data in swarmDMD that
includes at least one data type that is not position, the computational
complexity of swarmDMD is less than that of a traditional stacked DMD.
Moreover, stacked DMD would seek a model for the evolution of all of the
variables, which is known to have closure issues [49].

Note that additional regularizers $R(\cdot)$ may be included in the swarmDMD
optimization problem

$\displaystyle\operatorname*{arg\rm{}min}_{\mathbf{K}}\|\mathbf{S}-\mathbf{K}\mathbf{Y}\|+\lambda
R(\mathbf{K}).$ (6)

For example, sparsity may be useful to promote an influence matrix
$\mathbf{K}$ where each agent uses minimal information in its control law.
Similarly, group sparsity may be used to promote a group of agents having
similar influence laws. Both of these are promising avenues of ongoing
research.

###  III-A Interpreting $\mathbf{K}$

To interpret the swarm influence matrix $\mathbf{K}$, it is important to note
how the variables are grouped in the vector $\mathbf{y}$. Each variable type,
such as the $x$ or $y$ component of the agent position, are grouped together
across all agents, and then these variable groups are concatenated as in
Figure 1.

If the state corresponds to the agents’ positions, then $w=2$. From the
definition of $\mathbf{K}$ in (5), recall
$\mathbf{S}=\mathbf{X}^{\prime}-\mathbf{X}$ a matrix of component-wise speeds
of each agent at each time step. The rows of $\mathbf{S}$ contain, for each
agent $i$, the $x$ and $y$-components of the agent’s speed,
$\mathbf{s}^{\textsf{T}}_{i,x}$ and $\mathbf{s}^{\textsf{T}}_{i,y}$
respectively, for $i\in\\{1,..,N\\}$. Define the concatenated vector as
$\mathbf{s}^{T}_{i}$ and let

$\displaystyle\begin{split}&\mathbf{S}=\left[\begin{array}[]{c}\mathbf{s}^{\textsf{T}}_{1}\\\
\vdots\\\ \mathbf{s}_{2N}^{\textsf{T}}\end{array}\right],\
\mathbf{V}=\left[\begin{array}[]{ccc}\mathbf{v}_{1}&\cdots&\mathbf{v}_{r}\end{array}\right],\\\
&\mathbf{\Sigma}=\textbf{diag}(\sigma_{1},...,\sigma_{r}),\
\mathbf{U}=\left[\begin{array}[]{c}\mathbf{u}_{1}^{\textsf{T}}\\\ \vdots\\\
\mathbf{u}_{Nm}^{\textsf{T}}\end{array}\right].\end{split}$ (7)

The individual entries, $k_{i,j}$, of $\mathbf{K}$ can be written as:

$\displaystyle k_{i,j}=\sum_{\ell=1}^{r}\sigma_{\ell}^{-1}u_{\ell
j}\mathbf{s}_{i}^{\textsf{T}}\mathbf{v}_{\ell}=\bar{\mathbf{u}}_{j}^{\textsf{T}}\mathbf{\Sigma}^{-1}\mathbf{V}^{\textsf{T}}\mathbf{s}_{i}$
(8)

where $\bar{\mathbf{u}}^{\textsf{T}}_{j}\in\mathbb{R}^{r}$ is the $j$-th row
of $\mathbf{U}$. Each entry $k_{i,j}$ of $\mathbf{K}$ is a projection of the
speed onto the $j$-th component of each column of $\mathbf{U}$. Since the
columns of $\mathbf{U}$ are left singular vectors correspond to modes, and
these modes are ordered from most influential to least influential, then each
subsequent entry in $\bar{\mathbf{u}}_{j}^{\textsf{T}}$ carries less influence
than the last. Thus, each row of $\mathbf{K}$, which determines the
combination of data that each agent receives for its $x$\- and $y$-positions,
is given by:

$\displaystyle\mathbf{k}_{i}=\left[\begin{array}[]{ccc}\bar{\mathbf{u}}_{1}^{\textsf{T}}\mathbf{\Sigma}^{-1}\mathbf{V}^{\textsf{T}}\mathbf{s}_{i}&\cdots&\bar{\mathbf{u}}_{Nm}^{\textsf{T}}\mathbf{\Sigma}^{-1}\mathbf{V}^{\textsf{T}}\mathbf{s}_{i}\end{array}\right].$
(10)

Recall $\mathbf{s}_{i}^{\textsf{T}}$ is the vector of speed snapshots at each
time step and $\mathbf{V}$ encodes the temporal correlation within the
snapshot data. Starting with $\mathbf{V}^{\textsf{T}}\mathbf{s}_{i}$, the
columns $\mathbf{v}_{k}$ of $\mathbf{V}$ indicate which instants are most
influential to the change of state-$i$. This influence is scaled by
$\mathbf{\Sigma}^{-1}$. Finally, multiplying with $\bar{\mathbf{u}}_{j}$
determines which components $j$ will have the greatest influence on component
$i$, looking over the entire row $i$ in (10). In a sense, $\mathbf{K}$ selects
the states, neighbors, and time instants that are most influential to an
agent’s position change, acting as a control matrix that encodes the multi-
agent interaction laws inherent to the observation data.

###  III-B Alternative Dynamics Formulations

In addition to the dynamics given in (2), which we will call the standard
dynamics, we also considered implementations which assumed first-order
Cartesian and polar dynamics. The first-order Cartesian dynamics formulation
is set up as

$\displaystyle\mathbf{x}_{k+1}=\mathbf{x}_{k}+\mathbf{v}_{k}\Delta
t+\mathbf{K}\mathbf{y}_{k},$ (11)

where

$\displaystyle\mathbf{x}_{k}=\mathbf{p}_{k},\;\mathbf{y}_{k}=\left[\begin{array}[]{c}\Delta\mathbf{p}_{k}\\\
\Delta\mathbf{v}_{k}\end{array}\right],$ (14)

and $\mathbf{v}_{k}$ is defined as before. Similarly, the first-order polar
dynamics formulation is set up as

$\displaystyle\mathbf{x}_{k+1}=\mathbf{x}_{k}+\left[\begin{array}[]{c}v_{k}\cos\theta_{k}\\\
v_{k}\sin\theta_{k}\end{array}\right]\Delta t+\mathbf{K}\mathbf{y}_{k},$ (17)

where

$\displaystyle\mathbf{x}_{k}=\mathbf{p}_{k}\textnormal{ and
}\mathbf{y}_{k}=\left[\begin{array}[]{c}\Delta d_{k}\\\ \Delta v_{k}\\\
\Delta\theta_{k}\end{array}\right].$ (21)

These alternative formulations provide flexibility in capturing various types
of swarm behavior and dynamics.

##  IV Experiment Set-up

In this section, we introduce the swarm simulation and the metrics that were
used to assess the performance of swarmDMD. Swarm data is generated from the
flocking behaviour following the Vicsek model. We provide information about
the swarmDMD set-up, the ground truth models used for training, and the
metrics used in evaluating the results.

###  IV-A Vicsek Model

We use the Vicsek swarm model to generate data for training and analysis. The
Vicsek model is a simple and well-studied model that produces flocking
behaviour similar to that exhibited in biological swarm systems [36]. In the
original Vicsek model, agents possess a constant forward speed and interact
with the swarm by aligning their heading direction with the average heading of
their neighbors in a certain Euclidean radius.

The agent dynamics of the Vicsek model follow:

$\displaystyle\mathbf{x}^{i}_{k+1}=\mathbf{x}^{i}_{k}+\mathbf{v}^{i}_{k}\Delta
t,$ (22)

where $\mathbf{v}^{i}_{k}$ is the velocity of agent-$i$, which acts like a
control input to the linear system, and $\Delta t$ is the length of the time
step. The velocity at time step $k$ is determined from the heading angle
$\theta^{i}_{k}$ and the constant speed $\nu$, where
$\theta^{i}_{k}=\langle\boldsymbol{\theta}_{k-1}\rangle_{r}+\hat{\theta}^{i}$,
and $\langle\boldsymbol{\theta}_{k-1}\rangle_{r}$ is the average direction of
the agents, including agent-$i$, in a radius $r$ about agent-$i$, formally
defined as:

$\displaystyle\langle\boldsymbol{\theta}_{k-1}\rangle_{r}=\arctan(\langle\sin\boldsymbol{\theta}_{k-1}\rangle_{r}/\langle\cos\boldsymbol{\theta}_{k-1}\rangle_{r}).$

Here, $\hat{\theta}^{i}$ is a random heading perturbation chosen with uniform
probability from the interval $[-\eta/2,\eta/2]$. The values of the
interaction radius, $r$, and randomness, $\eta$, characterize the emergent
behaviour of a Vicsek swarm.

In addition to conventional flocking behaviours, we are also interested in how
swarmDMD performs on systems with more complicated dynamics, such as milling.
As a result, we also consider the modification to the original Vicsek model
presented by Costanzo and Hemelrijk [37]. In this modification, the field of
view of each agent is restricted and a bound is placed on the agents’ angular
velocity, such that

$\displaystyle\theta^{i}_{k}=\left\\{\begin{array}[]{ll}\langle\boldsymbol{\theta}_{k-1}\rangle_{r,\phi}+\hat{\theta}^{i}&|\Delta\theta^{i}|<\omega\Delta
t\\\ \theta^{i}_{k-1}+\omega\Delta
t+\hat{\theta}^{i}&\Delta\theta^{i}\geq\omega\Delta t\\\
\theta^{i}_{k-1}-\omega\Delta
t+\hat{\theta}^{i}&\Delta\theta^{i}\leq-\omega\Delta t\end{array}\right..$
(26)

Here, $\langle\boldsymbol{\theta}_{k-1}\rangle_{r,\phi}$ is the average agent
heading, as before, except now only agents in the field of view
$\phi\in[0,2\pi]$ of agent-$i$ are considered, $\omega\in[0,\pi/\Delta t]$ is
the maximal angular velocity, and $\Delta\theta^{i}\in[-\pi,\pi]$ is the
difference between the current orientation and the average orientation. Please
see [37] for precise definitions of the field of view and difference in
orientation.

The parameter values used in the ground truth simulations are given in Table
I. A time step of 0.1s is used in the standard Vicsek model simulation and the
swarmDMD recreation, and a time step of $1$s is used in the modified Vicsek
model for milling. The training period is 5s and the prediction period is 5s
post-training. Before being used in swarmDMD, the milling swarm data was
interpolated to have a time step of $0.1$s, and the number of agents was
reduced to 200 via random sampling. We use the first eight most dominant DMD
modes in our swarmDMD recreation and prediction.

TABLE I: Parameters used in the Vicsek models for ground truth simulations. Parameters are compiled from [36, 37].  | Standard | Milling
---|---|---
$N$ | 50 | 1000
$\Delta t$ | 0.1 | 1
$\rho$ | 16 | 2.5
$r$ | 0.05, 0.25, 0.5 | 1
$\phi$ | N/A | $\pi/2$
$\omega$ | N/A | $\pi/18$
$\eta$ | 0, $\pi/12$ | $0.5\omega/\Delta t$
$\nu$ | 0.03 | $1.03r\omega$
Figure 2: A visual representation of key parameters used in simulations:
domain size, interaction radius, noise in heading; and four of the metrics
used to analyse the results: heading error, position error, and polarisation.
In the first frame at $t=0$, swarmDMD is initialzed with the ground truth
agent positions. In a future frame ($t=k$) when positions predicted by
swarmDMD have diverged from the ground truth, the ground truth agent position
is shown in orange, and the swarmDMD prediction in blue. Here, $L$ is the
width of the square simulation domain, and $l$ the width of the square domain
within which agents are initialized following a uniform distribution. The
large grey arrows in the background of the Polarisation frames indicate the
average direction of the swarm.

###  IV-B Evaluation Metrics

We now discuss the metrics used to evaluate reconstruction and prediction. The
metrics we consider are: position error, heading error, polarisation error,
error in angular momentum, and agent distribution about a focal agent. The
first three metrics and the key simulation parameters are shown in Figure 2.

The position and heading errors are direct comparisons between the absolute
position measurements from the ground truth and swarmDMD reconstruction. An
agent’s position error is the distance between the reconstructed and actual
position. Similarly, an agent’s heading error is defined as the absolute
heading difference between the swarmDMD reconstruction and the ground truth.
These two errors are averaged over all agents.

The calculations of polarisation and angular momentum are borrowed from [42].
We are interested in these two metrics as polarisation and angular momentum
describe the collective motion of the swarm, and the degree to which the swarm
is acting as one cohesive unit. Polarisation is calculated as:

$\displaystyle P_{k}$
$\displaystyle=\left|\left|\frac{\sum_{i=1}^{N}\mathbf{v}^{i}_{k}}{\sum_{i=1}^{N}||\mathbf{v}^{i}_{k}||_{2}}\right|\right|_{2}\in[0,1],$
(27)

and it provides a characterisation of the orientation of the swarm and takes
values between $0$ and $1$. A value of $P_{k}$ close to $1$ means the majority
of agents in the swarm are travelling in a similar direction, i.e., they have
similar orientation. Angular momentum is calculated as:

$\displaystyle\begin{split}M_{k}&=\left|\left|\frac{\sum_{i=1}^{N}\mathbf{p}^{i}_{k}\times\mathbf{v}^{i}_{k}}{\sum_{i=1}^{N}||\mathbf{p}^{i}_{k}||_{2}\
||\mathbf{v}^{i}_{k}||_{2}}\right|\right|_{2}\in[0,1],\end{split}$ (28)

and it takes values between $0$ and $1$, describing the normalised momentum of
the swarm. Angular momentum gives a notion of the rotational motion within a
swarm. The polarisation and angular momentum errors are calculated as the
absolute difference between the ground truth and swarmDMD results.

The final metric considered is the distribution of neighbours, which helps to
characterise the general structure of the swarm. Our distribution calculations
are based on those in [57]. To calculate the neighbour distribution for a
single focal agent, a neighbourhood about the agent is divided into bins, and
the number of neighbours in each bin is counted and divided by the total
number of agents in the neighbourhood. Then, these bin counts are averaged
over all agents in the swarm (one by one, treating each agent as a focal
agent), and over the desired time frame. An illustration of the process for
each time step $k$ is given in Figure 3.

Figure 3: An illustration of the process for computing the density
distribution of neighbours for each time step. The domain about each agent is
discretised into bins, the number of neighbours in each bin is counted,
converted to a percentage of the total number of agents in the neighbourhood,
and then averaged over all agents in the swarm. The bins are distance $d$
apart and have width $l$.

##  V Results

We now discuss the performance of swarmDMD on several example scenarios and in
two different implementation styles. The ground truth swarms in the first
three scenarios are created from the standard Vicsek model, one scenario per
interaction radius in Table I and fixing $\eta=0$. The fourth scenario uses
the Vicsek milling model. The two implementation styles presented here both
use the standard swarmDMD dynamics, but are initialised in different ways. The
first implementation initialises the swarmDMD agents at the start time of the
training period (termed Basic), whereas the second re-initialises the agents
with the positions and headings of the ground truth agents every $g$ seconds,
and propagates this for $h$ seconds (termed Re-initialisation); we take
$g=0.5s$ and $h=10s$. The re-initialisation implementation was only applied to
the standard Vicsek model scenarios. A short discussion of the performance of
swarmDMD with the first-order Cartesian and polar dynamics is given at the end
of the section, with the corresponding figures in the Appendix.

Figure 4 shows the swarmDMD reconstruction and prediction error in agents’
positions. During the training period, the error is rarely above $10^{-4}$,
demonstrating the ability of swarmDMD to accurately reconstruct the swarm
dynamics. This is further reinforced by the agent density distribution shown
in Figure 5 for standard flock behaviour and Figure 6 for milling, which
indicate that the swarmDMD recreation captures the general structure of agents
within the swarm. In addition, Figure 7 plots the trajectories of the agents
during the training period under different inter-agent interaction radii
settings, and the difference between the ground truth and the swarmDMD
recreation is imperceptible during the training period. It should also be
noted that in Figure 4, the error associated with the $r=0.5$ case is so small
that it is not included in the plot.

Figure 4: The resulting position error of the standard dynamics is compared
across ground truth interaction radii, $r$, 0.05 (blue), 0.25 (orange), and
0.5 (green), and milling results (purple). Ground truth has $\eta=0$ for basic
and re-initialisation. Three things are of note: (1) the low error during
training across all interaction radii for both the basic and re-initialisation
implementations, (2) the error is so small for $r=0.5$ that it is off the
plot, and (3) initialising the algorithm outside the training period does not
result in an increase in error. Figure 5: Agent distribution analysis of
swarmDMD with standard dynamics during the training period where the ground
truth has $\eta=0$. On the left is the ground truth distribution, and on the
right is the swarmDMD recreation. SwarmDMD captures the most prominent
features in the case $r=0.05$, and is almost identical in the case $r=0.5$.
Figure 6: Agent distribution analysis of swarmDMD with standard dynamics
during the training period where the ground truth is the milling case. On the
left is the ground truth distribution, and on the right is the swarmDMD
recreation. SwarmDMD does a decent job of capturing the ring-like pattern and
three of the higher-likelihood areas.

Figure 7: SwarmDMD agent trajectories for $r=0.05$ (blue), $r=0.5$ (green),
and milling (purple). In all plots the ground truth trajectories are given in
grey. The large circles outlined in black are the positions of the swarmDMD
agents at the beginning of each time period, and the pluses outlined in light
grey the positions of the ground truth agents; the lines leaving each of these
indicate the trajectories of the agents over the specified time period.

Considering the post-training period of 5-10s, there is a window where the
position error is still sufficiently small, indicating that swarmDMD can
accurately predict agents’ dynamics post-training for a short horizon. This is
most evident in the position and heading error in Figures 4 and 8, but can
also be seen to some extent across all error figures. In addition, the density
distributions during prediction, given in Figures 9 and 10, show that the
general structure is captured by swarmDMD, though not as accurately as during
training. This is a promising result that indicates the potential for swarmDMD
models to be used for the control of swarms. It should be noted that of the
“basic” scenario plots are only included for $r=0.05$ and $r=0.5$, to avoid
cluttering. It is encouraging that in all scenarios presented, swarmDMD
captures the dominant distributions amongst agents during both training and
prediction.

Figure 8: The resulting heading error of the standard dynamics is compared
across ground truth interaction radii, $r$, 0.05 (blue), 0.25 (orange), and
0.5 (green), and milling results (purple). Ground truth has $\eta=0$ for basic
and re-initialisation. Figure 9: Agent distribution analysis of swarmDMD with
standard dynamics over a period of 5s prediction, ground truth has $\eta=0$.
On the left is the ground truth distribution, and on the right is the swarmDMD
recreation. Again, swarmDMD captures the most prominent features (the diagonal
stripe, and ring around the edges) in the case $r=0.05$, and is almost
identical in the case $r=0.5$.  Figure 10: Agent distribution analysis of
swarmDMD with standard dynamics over a period of 5s prediction, ground truth
is the milling case. On the left is the ground truth distribution, and on the
right is the swarmDMD recreation. It is interesting to note that here swarmDMD
seems to capture the prominent patterns better than during the training
period. (need to fix sizes of plots)

The fact that the position error is very small for the milling scenario
(Figure 4) is significant; not only can swarmDMD recreate basic swarm flocking
behaviours, it can reproduce milling motion and combined motions of milling
and flocking in a single simulation. Figures 11 and 12 also indicate that
swarmDMD performs well with these more complicated dynamics, as the milling
error is comparable to the “basic” scenario errors with $r=0.25$. However,
swarmDMD does have limitations, as seen in Figure 8, where the algorithm
struggles with keeping the heading error low in the milling scenario.
Importantly, by examining the re-initialisation results in Figures 4, 8, and
12, we observe that initialising the agents outside of the training period
does not noticeably increase error, providing evidence of robustness in the
model.

Figure 11: The resulting polarisation error of the standard dynamics is
compared across ground truth interaction radii, $r$, 0.05 (blue), 0.25
(orange), and 0.5 (green), and milling results (purple). Ground truth has
$\eta=0$ for basic and re-initialisation. Figure 12: The resulting angular
momentum error of the standard dynamics is compared across ground truth
interaction radii, $r$, 0.05 (blue), 0.25 (orange), and 0.5 (green), and
milling results (purple). Ground truth has $\eta=0$ for basic and re-
initialisation.

Tables II and III summarize the results shown before based on two metrics: the
average error during the training period, and the amount of time the error
stays below 1e-01 during the post-training prediction period. In these tables
we also include the data from the scenarios with $\eta=\pi/12$, for which the
results are shown in Figure 13 in the Appendix. We can see that swarmDMD does
perform better in the scenarios with less randomness in the motion of the
agents. During training this is most noticeable in the position and heading,
as the average polarisation and angular momentum errors during training for
the scenarios with $\eta=\pi/12$ are of the same magnitude as those in the
scenarios with $\eta=0$. This is expected, as the randomness in the agents’
positions, if small enough, should only affect the motion of individual agents
and not the general behaviour of the swarm.

TABLE II: Average error during training for the standard algorithm. $r$ | $\eta$ | $e_{x}$ | $e_{\theta}$ | $e_{P}$ | $e_{M_{ang}}$
---|---|---|---|---|---
0.05 | 0 |  $2.95$e-05 |  $1.03$e-02 |  $4.11$e-03 |  $3.69$e-03
0.25 | 0 | 7.07e-05 | 1.91e-02 | 4.74e-03 | 5.43e-03
0.5 | 0 | 7.60e-07 | 1.95e-04 | 1.45e-06 | 1.20e-05
Milling | 3.67e-05 | 2.79e-02 | 1.21e-03 | 8.17e-03
0.05 | $\pi/12$ | 1.29e-04 | 5.79e-02 | 6.17e-03 | 8.04e-03
0.25 | $\pi/12$ | 1.49e-04 | 6.66e-01 | 6.63e-03 | 7.14e-03
0.5 | $\pi/12$ | 1.39e-04 | 6.17e-02 | 3.19e-03 | 5.44e-03
TABLE III: Length of time (in seconds) post-training that error remains below 1e-01 for the standard algorithm. The “$-$” indicates the error is never larger than 1e-01 over the whole time period. $r$ | $\eta$ | $t_{x}$ | $t_{\theta}$ | $t_{P}$ | $t_{M_{ang}}$
---|---|---|---|---|---
0.05 | 0 | 12.7 | 1.3 | 3.7 | 5.3
0.25 | 0 | 18.1 | 1.6 | 5.8 | 6.7
0.5 | 0 | $-$ | $-$ | $-$ | $-$
Milling | 6.6 | 0 | 9 | 3.6
0.05 | $\pi/12$ | 5.7 | 0 | 2.4 | 3.3
0.25 | $\pi/12$ | 7.6 | 0 | 2.6 | 2.2
0.5 | $\pi/12$ | $-$ | 0.9 | $-$ | 5.3

Tables IV and V give the average error during the training period, and the
amount of time post-training for which the error stays below 1e-01,
respectively, for the first-order Cartesian and polar dynamics, given by (11)
and (17), respectively. It is clear that the first-order Cartesian and polar
dynamics do not perform as well as the standard implementation. Further
discussion of these results can be found in the Appendix.

TABLE IV: Average error during training for the Cartesian and polar algorithms with $\eta=0$. | $r$ | $e_{x}$ | $e_{\theta}$ | $e_{P}$ | $e_{M_{ang}}$
---|---|---|---|---|---
Cart. | 0.05 | 2.51e-04 | 1.31e-02 | 5.20e-03 | 4.57e-03
0.25 | 7.44e-02 | 5.55e-01 | 2.11e-01 | 1.94e-01
0.5 | 2.01e-01 | 1.13e+00 | 5.46e-01 | 4.88e-01
Polar | 0.05 | 9.14e-04 | 3.51e-02 | 9.76e-03 | 8.64e-03
0.25 | 8.71e-03 | 2.11e-01 | 4.04e-02 | 5.69e-02
0.5 | 1.18e-03 | 2.41e-02 | 9.02e-03 | 8.51e-03
TABLE V: Length of time (in seconds) post-training that error remains below 1e-01 for the Cartesian and polar algorithms with $\eta=0$.  | $r$ | $t_{x}$ | $t_{\theta}$ | $t_{P}$ | $t_{M_{ang}}$
---|---|---|---|---|---
Cartesian | 0.05 | 8.1 | 1 | 3.8 | 3.4
0.25 | 0 | 0 | 0 | 0
0.5 | 0 | 0 | 0 | 0
Polar | 0.05 | 14 | 1.8 | 7.8 | 6.7
0.25 | 1.9 | 0 | 0 | 0
0.5 | 4.8 | 1.1 | 2.2 | 1.8

##  VI Conclusions

In this paper, we introduced for the first time the method of swarmDMD to
learn local interaction laws that give rise to swarm motions from pure
observation data. We demonstrated the performance of swarmDMD on both flocking
and milling swarm motions generated with the Vicsek model and its variants. It
was concluded that swarmDMD can not only reconstruct the swarm behaviour
faithfully but also predict the swarm motion sufficiently accurately within a
short window after the training period. We tested swarmDMD on different
observation data types and found inter-agent distance to give the best
reconstruction and prediction performance. These results suggest that swarmDMD
can be a powerful tool in analyzing biological swarms and engineering
intelligent multi-agent systems.

There are a number of future directions that are suggested by this work.
First, it may be possible to learn nonlinear interaction laws using nonlinear
generalizations of DMD, such as the sparse identification of nonlinear
dynamics (SINDy) [25] or tensor DMD formulations [58, 59]. Moreover, sparsity
promoting algorithms may be useful for inferring minimal network connectivity
and causality [60]; sparsity-promoting DMD has already been introduced to
identify a minimal set of modes [61], but may be adapted for sparse dynamics
matrices. For higher order systems, or systems with partially observed
dynamics, incorporating time delays will also be important [53, 49].
Similarly, if data is collected in partial and overlapping domains, it may be
possible to merge these data by aligning the phase between different DMD
models [62]. It may also be important to cluster the swarm into distinct
regions, where different local rules are applied, for example using cluster
reduced order modeling [63, 64]. Finite-time Lyapunov exponents and Lagrangian
coherent structures may also provide further insights into swarm dynamics and
behavioral regimes [65, 66, 67, 68, 69]. It will also be interesting to expore
the effectiveness of swarmDMD models for active feedback control of the swarm,
for example by manipulating the behavior of a small subset of agents. Finally,
it will be important to apply these methods to other canonical swarm models
and also to real-world data to explore the strengths and weaknesses of these
various algorithms.

## Acknowledgments

SLB and ZS would like to thank the National Science Foundation (NSF) for
partial funding under award AI Institute in Dynamic Systems (CBET-2112085).
SLB would like to acknowledge the Air Force Office of Scientific Research
(AFOSR FA9550-21-1-0178). ZS would also like to thank NSF’s support under
award EPSCoR Research Infrastructure (OIA-2032522).

## Code Availability

The code for this work has been made available on GitHub at
https://github.com/e-vic/swarmDMD.

## References

  * [1] E. Bonabeau, M. Dorigo, and G. Theraulaz, _Swarm Intelligence: From Natural to Artificial Systems_ , ser. Santa Fe Institute Studies on the Sciences of Complexity. Oxford University Press, 1999.
  * [2] R. Lukeman, Y.-X. Li, and L. Edelstein-Keshet, “Inferring individual rules from collective behavior,” _Proceedings of the National Academy of Sciences_ , vol. 107, no. 28, pp. 12 576–12 580, jul 2010.
  * [3] W. Bialek, A. Cavagna, I. Giardina, T. Mora, O. Pohl, E. Silvestri, M. Viale, and A. M. Walczak, “Social interactions dominate speed control in poising natural flocks near criticality,” _Proceedings of the National Academy of Sciences_ , vol. 111, no. 20, pp. 7212–7217, May 2014. [Online]. Available: https://doi.org/10.1073/pnas.1324045111
  * [4] S. Berman, Q. Lindsey, M. S. Sakar, V. Kumar, and S. C. Pratt, “Experimental study and modeling of group retrieval in ants as an approach to collective transport in swarm robotic systems,” _Proceedings of the IEEE_ , vol. 99, no. 9, pp. 1470–1481, 2011.
  * [5] T. Vicsek and A. Zafeiris, “Collective motion,” _Physics Reports_ , vol. 517, no. 3-4, pp. 71–140, 2012. [Online]. Available: http://dx.doi.org/10.1016/j.physrep.2012.03.004
  * [6] M. Brambilla, E. Ferrante, M. Birattari, and M. Dorigo, “Swarm robotics: A review from the swarm engineering perspective,” _Swarm Intelligence_ , vol. 7, no. 1, pp. 1–41, 2013.
  * [7] D. H. Kelley and N. T. Ouellette, “Emergent dynamics of laboratory insect swarms,” _Scientific Reports_ , vol. 3, p. 1073, 2013.
  * [8] D. Strömbom, R. P. Mann, A. M. Wilson, S. Hailes, A. J. Morton, D. J. T. Sumpter, and A. J. King, “Solving the shepherding problem: heuristics for herding autonomous, interacting agents,” _Journal of The Royal Society Interface_ , vol. 11, no. 100, p. 20140719, 2014. [Online]. Available: https://royalsocietypublishing.org/doi/abs/10.1098/rsif.2014.0719
  * [9] A. A. Paranjape, S.-J. Chung, K. Kim, and D. H. Shim, “Robotic herding of a flock of birds using an unmanned aerial vehicle,” _IEEE Transactions on Robotics_ , vol. 34, no. 4, pp. 901–915, 2018.
  * [10] D. Romano, E. Donati, G. Benelli, and C. Stefanini, “A review on animal–robot interaction: from bio-hybrid organisms to mixed societies,” _Biological Cybernetics_ , vol. 113, no. 3, pp. 201–225, 2019. [Online]. Available: https://doi.org/10.1007/s00422-018-0787-5
  * [11] A. Prorok, N. Correll, and A. Martinoli, “Multi-level spatial modeling for stochastic distributed robotic systems,” _The International Journal of Robotics Research_ , vol. 30, no. 5, pp. 574–589, 2011.
  * [12] M. Rubenstein, A. Cornejo, and R. Nagpal, “Robotics. Programmable self-assembly in a thousand-robot swarm.” _Science (New York, N.Y.)_ , vol. 345, no. 6198, pp. 795–9, 2014.
  * [13] S.-J. Chung, A. A. Paranjape, P. Dames, S. Shen, and V. Kumar, “A survey on aerial swarm robotics,” _IEEE Transactions on Robotics_ , vol. 34, no. 4, pp. 837–855, aug 2018. [Online]. Available: https://ieeexplore.ieee.org/document/8424838/
  * [14] K. N. McGuire, C. D. Wagter, K. Tuyls, H. J. Kappen, and G. C. H. E. de Croon, “Minimal navigation solution for a swarm of tiny flying robots to explore an unknown environment,” _Science Robotics_ , vol. 4, no. 35, p. eaaw9710, 2019. [Online]. Available: https://www.science.org/doi/abs/10.1126/scirobotics.aaw9710
  * [15] M. Schranz, M. Umlauft, M. Sende, and W. Elmenreich, “Swarm robotic behaviors and current applications,” _Frontiers in Robotics and AI_ , vol. 7, 2020\. [Online]. Available: https://www.frontiersin.org/article/10.3389/frobt.2020.00036
  * [16] F. Berlinger, M. Gauci, and R. Nagpal, “Implicit coordination for 3D underwater collective behaviors in a fish-inspired robot swarm,” _Science Robotics_ , vol. 6, no. 50, p. eabd8668, 2021.
  * [17] M. Dorigo, G. Theraulaz, and V. Trianni, “Swarm robotics: Past, present, and future [point of view],” _Proceedings of the IEEE_ , vol. 109, no. 7, pp. 1152–1165, 2021.
  * [18] C. W. Reynolds, “Flocks, herds and schools: A distributed behavioral model,” _ACM SIGGRAPH Computer Graphics_ , vol. 21, no. 4, pp. 25–34, Aug. 1987. [Online]. Available: https://dl.acm.org/doi/10.1145/37402.37406
  * [19] W. M. Spears, D. F. Spears, J. C. Hamann, and R. Heil, “Distributed, physics-based control of swarms of vehicles,” _Autonomous Robots_ , vol. 17, no. 2-3, pp. 137–162, 2004.
  * [20] R. Olfati-Saber, “Flocking for multi-agent dynamic systems: Algorithms and theory,” _IEEE Transactions on Automatic Control_ , vol. 51, no. 3, pp. 401–420, mar 2006.
  * [21] M. A. Hsieh, V. Kumar, and L. Chaimowicz, “Decentralized controllers for shape generation with robotic swarms,” _Robotica_ , vol. 26, no. 26, pp. 691–701, 2008.
  * [22] L. C. A. Pimenta, G. A. S. Pereira, N. Michael, R. C. Mesquita, M. M. Bosque, L. Chaimowicz, and V. Kumar, “Swarm coordination based on smoothed particle hydrodynamics technique,” _IEEE Transactions on Robotics_ , vol. 29, no. 2, pp. 383–399, 2013.
  * [23] Z. Song, D. Lipinski, and K. Mohseni, “Multi-vehicle cooperation and nearly fuel-optimal flock guidance in strong background flows,” _Ocean Engineering_ , vol. 141, pp. 388–404, sep 2017.
  * [24] M. Schmidt and H. Lipson, “Distilling free-form natural laws from experimental data,” _Science_ , vol. 324, no. 5923, pp. 81–85, 2009.
  * [25] S. L. Brunton, J. L. Proctor, and J. N. Kutz, “Discovering governing equations from data by sparse identification of nonlinear dynamical systems,” _Proceedings of the National Academy of Sciences_ , vol. 113, no. 15, pp. 3932–3937, Apr. 2016.
  * [26] J. N. Kutz, S. L. Brunton, B. W. Brunton, and J. L. Proctor, _Dynamic Mode Decomposition: Data-driven Modeling of Complex Systems_. SIAM, 2016.
  * [27] M. Hüttenrauch, A. Šošić, and G. Neumann, “Deep reinforcement learning for swarm systems,” _Journal of Machine Learning Research_ , vol. 20, no. 54, pp. 1–31, 2019. [Online]. Available: http://jmlr.org/papers/v20/18-476.html
  * [28] M. Zhong, J. Miller, and M. Maggioni, “Data-driven discovery of emergent behaviors in collective dynamics,” _Physica D: Nonlinear Phenomena_ , vol. 411, p. 132542, oct 2020. [Online]. Available: https://doi.org/10.1016/j.physd.2020.132542https://linkinghub.elsevier.com/retrieve/pii/S0167278919308152
  * [29] J. D. Davidson, M. Vishwakarma, and M. L. Smith, “Hierarchical approach for comparing collective behavior across scales: Cellular systems to honey bee colonies,” _Frontiers in Ecology and Evolution_ , vol. 9, p. 581222, Feb. 2021. [Online]. Available: https://www.frontiersin.org/articles/10.3389/fevo.2021.581222/full
  * [30] H. Ling, G. E. Mclvor, J. Westley, K. van der Vaart, J. Yin, R. T. Vaughan, A. Thornton, and N. T. Ouellette, “Collective turns in jackdaw flocks: kinematics and information transfer,” _Journal of the Royal Society Interface_ , vol. 16, no. 159, p. 20190450, Oct. 2019. [Online]. Available: https://royalsocietypublishing.org/doi/10.1098/rsif.2019.0450
  * [31] K. Fujii, N. Takeishi, M. Hojo, Y. Inaba, and Y. Kawahara, “Physically-interpretable classification of biological network dynamics for complex collective motions,” _Scientific Reports_ , vol. 10, no. 1, p. 3005, Dec. 2020. [Online]. Available: http://www.nature.com/articles/s41598-020-58064-w
  * [32] V. H. Sridhar, L. Li, D. Gorbonos, M. Nagy, B. R. Schell, T. Sorochkin, N. S. Gov, and I. D. Couzin, “The geometry of decision-making in individuals and collectives,” _Proceedings of the National Academy of Sciences_ , vol. 118, no. 50, p. e2102157118, Dec. 2021. [Online]. Available: http://www.pnas.org/lookup/doi/10.1073/pnas.2102157118
  * [33] K. van der Vaart, M. Sinhuber, A. M. Reynolds, and N. T. Ouellette, “Environmental perturbations induce correlations in midge swarms,” _Journal of The Royal Society Interface_ , vol. 17, no. 164, p. 20200018, Mar. 2020. [Online]. Available: https://royalsocietypublishing.org/doi/10.1098/rsif.2020.0018
  * [34] W. Tang, J. D. Davidson, G. Zhang, K. E. Conen, J. Fang, F. Serluca, J. Li, X. Xiong, M. Coble, T. Tsai, G. Molind, C. H. Fawcett, E. Sanchez, P. Zhu, I. D. Couzin, and M. C. Fishman, “Genetic control of collective behavior in zebrafish,” _iScience_ , vol. 23, no. 3, p. 100942, Mar. 2020\. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S2589004220301267
  * [35] D. J. T. Sumpter, _Collective Animal Behavior_. Princeton University Press, 2010.
  * [36] T. Vicsek, A. Czirók, E. Ben-Jacob, I. Cohen, and O. Shochet, “Novel type of phase transition in a system of self-driven particles,” _Physical Review Letters_ , vol. 75, no. 6, pp. 1226–1229, Aug. 1995. [Online]. Available: https://link.aps.org/doi/10.1103/PhysRevLett.75.1226
  * [37] A. Costanzo and C. K. Hemelrijk, “Spontaneous emergence of milling (vortex state) in a Vicsek-like model,” _Journal of Physics D: Applied Physics_ , vol. 51, no. 13, p. 134004, Apr. 2018. [Online]. Available: https://iopscience.iop.org/article/10.1088/1361-6463/aab0d4
  * [38] I. Aoki, “A simulation study on the schooling mechanism in fish,” _Nippon Suisan Gakkaishi_ , vol. 48, no. 8, pp. 1081–1088, 1982.
  * [39] D. Helbing and P. Molnár, “Social force model for pedestrian dynamics,” _Physical Review E_ , vol. 51, no. 5, pp. 4282–4286, May 1995. [Online]. Available: https://link.aps.org/doi/10.1103/PhysRevE.51.4282
  * [40] H. Schaeffer, G. Tran, and R. Ward, “Extracting sparse high-dimensional dynamics from limited data,” _SIAM Journal on Applied Mathematics_ , vol. 78, no. 6, pp. 3279–3295, Jan. 2018. [Online]. Available: https://epubs.siam.org/doi/10.1137/18M116798X
  * [41] M. Sinhuber, K. van der Vaart, Y. Feng, A. M. Reynolds, and N. T. Ouellette, “An equation of state for insect swarms,” _Scientific Reports_ , vol. 11, no. 1, p. 3773, Dec. 2021. [Online]. Available: http://www.nature.com/articles/s41598-021-83303-z
  * [42] D. Bhaskar, A. Manhart, J. Milzman, J. T. Nardini, K. M. Storey, C. M. Topaz, and L. Ziegelmeier, “Analyzing collective motion with machine learning and topology,” _Chaos: An Interdisciplinary Journal of Nonlinear Science_ , vol. 29, no. 12, p. 123125, Dec. 2019.
  * [43] W. Mei, N. E. Friedkin, K. Lewis, and F. Bullo, “Dynamic models of appraisal networks explaining collective learning,” _IEEE Transactions on Automatic Control_ , vol. 63, no. 9, pp. 2898–2912, Sep. 2018. [Online]. Available: https://ieeexplore.ieee.org/document/8115275/
  * [44] F. Lu, M. Zhong, S. Tang, and M. Maggioni, “Nonparametric inference of interaction laws in systems of agents from trajectory data,” _Proceedings of the National Academy of Sciences_ , vol. 116, no. 29, pp. 14 424–14 433, Jul. 2019. [Online]. Available: http://www.pnas.org/lookup/doi/10.1073/pnas.1822012116
  * [45] P. J. Schmid, “Dynamic mode decomposition of numerical and experimental data,” _Journal of Fluid Mechanics_ , vol. 656, pp. 5–28, 2010.
  * [46] C. W. Rowley, I. Mezić, S. Bagheri, P. Schlatter, and D. Henningson, “Spectral analysis of nonlinear flows,” _Journal Fluid Mechanics_ , vol. 645, pp. 115–127, 2009.
  * [47] P. Schmid, L. Li, M. Juniper, and O. Pust, “Applications of the dynamic mode decomposition,” _Theoretical and Computational Fluid Dynamics_ , vol. 25, no. 1-4, pp. 249–259, 2011.
  * [48] P. J. Schmid, “Dynamic mode decomposition and its variants,” _Annual Review of Fluid Mechanics_ , vol. 54, pp. 225–254, 2022.
  * [49] S. L. Brunton, M. Budišić, E. Kaiser, and J. N. Kutz, “Modern Koopman theory for dynamical systems,” _arXiv preprint arXiv:2102.12086_ , 2021.
  * [50] J. L. Proctor, S. L. Brunton, and J. N. Kutz, “Dynamic mode decomposition with control,” _SIAM Journal on Applied Dynamical Systems_ , vol. 15, no. 1, pp. 142–161, Jan. 2016\.
  * [51] B. W. Brunton, L. A. Johnson, J. G. Ojemann, and J. N. Kutz, “Extracting spatial–temporal coherent patterns in large-scale neural recordings using dynamic mode decomposition,” _Journal of Neuroscience Methods_ , vol. 258, pp. 1–15, 2016.
  * [52] J. M. Kunert-Graf, K. M. Eschenburg, D. J. Galas, J. N. Kutz, S. D. Rane, and B. W. Brunton, “Extracting reproducible time-resolved resting state networks using dynamic mode decomposition,” _Frontiers in Computational Neuroscience_ , p. 75, 2019.
  * [53] S. M. Hirsh, S. M. Ichinaga, S. L. Brunton, J. Nathan Kutz, and B. W. Brunton, “Structured time-delay models for dynamical systems with connections to frenet–serret frame,” _Proceedings of the Royal Society A_ , vol. 477, no. 2254, p. 20210097, 2021.
  * [54] S. L. Brunton and J. N. Kutz, _Data-Driven Science and Engineering: Machine Learning, Dynamical Systems, and Control_. Cambridge University Press, 2019.
  * [55] K. Taira, S. L. Brunton, S. Dawson, C. W. Rowley, T. Colonius, B. J. McKeon, O. T. Schmidt, S. Gordeyev, V. Theofilis, and L. S. Ukeiley, “Modal analysis of fluid flows: An overview,” _AIAA Journal_ , vol. 55, no. 12, pp. 4013–4041, 2017.
  * [56] K. Taira, M. S. Hemati, S. L. Brunton, Y. Sun, K. Duraisamy, S. Bagheri, S. Dawson, and C.-A. Yeh, “Modal analysis of fluid flows: Applications and outlook,” _AIAA Journal_ , vol. 58, no. 3, pp. 998–1022, 2020.
  * [57] Y. Katz, K. Tunstrom, C. C. Ioannou, C. Huepe, and I. D. Couzin, “Inferring the structure and dynamics of interactions in schooling fish,” _Proceedings of the National Academy of Sciences_ , vol. 108, no. 46, pp. 18 720–18 725, Jul. 2011. [Online]. Available: https://doi.org/10.1073/pnas.1107583108
  * [58] S. Klus, P. Gelß, S. Peitz, and C. Schütte, “Tensor-based dynamic mode decomposition,” _Nonlinearity_ , vol. 31, no. 7, p. 3359, 2018.
  * [59] K. D. Harris, A. Aravkin, R. Rao, and B. W. Brunton, “Time-varying autoregression with low-rank tensors,” _SIAM Journal on Applied Dynamical Systems_ , vol. 20, no. 4, pp. 2335–2358, 2021.
  * [60] G. Stepaniants, B. W. Brunton, and J. N. Kutz, “Inferring causal networks of dynamical systems through transient dynamics and perturbation,” _Physical Review E_ , vol. 102, no. 4, p. 042309, 2020.
  * [61] M. R. Jovanović, P. J. Schmid, and J. W. Nichols, “Sparsity-promoting dynamic mode decomposition,” _Physics of Fluids_ , vol. 26, no. 2, p. 024103, 2014.
  * [62] A. G. Nair, B. Strom, B. W. Brunton, and S. L. Brunton, “Phase-consistent dynamic mode decomposition from multiple overlapping spatial domains,” _Physical Review Fluids_ , vol. 5, no. 7, p. 074702, 2020.
  * [63] E. Kaiser, B. R. Noack, L. Cordier, A. Spohn, M. Segond, M. Abel, G. Daviller, J. Osth, S. Krajnovic, and R. K. Niven, “Cluster-based reduced-order modelling of a mixing layer,” _Journal of Fluid Mechanics_ , vol. 754, pp. 365–414, 2014.
  * [64] E. Kaiser, M. Morzynski, G. Daviller, J. N. Kutz, B. W. Brunton, and S. L. Brunton, “Sparsity enabled cluster reduced-order models for control,” _Journal of Computational Physics_ , vol. 352, pp. 388–409, 2018.
  * [65] G. Haller, “Lagrangian coherent structures from approximate velocity data,” _Physics of Fluids_ , vol. 14, no. 6, pp. 1851–1861, June 2002.
  * [66] S. C. Shadden, F. Lekien, and J. E. Marsden, “Definition and properties of Lagrangian coherent structures from finite-time Lyapunov exponents in two-dimensional aperiodic flows,” _Physica D_ , vol. 212, pp. 271–304, 2005\.
  * [67] S. C. Shadden, K. Katija, M. Rosenfeld, J. E. Marsden, and J. O. Dabiri, “Transport and stirring induced by vortex formation,” _Journal of Fluid Mechanics_ , vol. 593, pp. 315–331, 2007.
  * [68] G. Haller, “Lagrangian coherent structures,” _Annual Review of Fluid Mechanics_ , vol. 47, pp. 137–162, 2015.
  * [69] P. Gunnarson, I. Mandralis, G. Novati, P. Koumoutsakos, and J. O. Dabiri, “Learning efficient navigation in vortical flow fields,” _arXiv preprint arXiv:2102.10536_ , 2021.

Here we will briefly discuss the performance of standard swarmDMD when trained
on the ground truth cases where $\eta=\pi/12$, and of the first-order (FO)
Cartesian and polar implementations.

Figure 13: From left to right, the resulting position, heading, polarisation,
and angular momentum errors of the standard dynamics are compared across
ground truth interaction radii, $r$, 0.05 (blue), 0.25 (orange), and 0.5
(green). Ground truth has $\eta=\pi/12$ for basic and re-initialisation.

Figure 14: Agent distribution analysis of swarmDMD with standard dynamics over
the training period, ground truth has $\eta=\pi/12$. On the left is the ground
truth distribution, and on the right is the swarmDMD recreation.

Figure 15: Agent distribution analysis of swarmDMD with standard dynamics over
a period of 5s prediction, ground truth has $\eta=\pi/12$. On the left is the
ground truth distribution, and on the right is the swarmDMD prediction.

### Standard Dynamics

Position, heading, polarisation, and angular momentum — seen in Figure 13 —
all show increases in error values from the $\eta=0$ cases, with heading error
increasing multiple orders of magnitude. Polarisation and angular momentum
errors show a significant increase in noisiness of the plots. These are all
expected results as the uncertainty in the headings of the ground truth agents
is now non-zero. It is also interesting to note that with the increase in
uncertainty in the ground truth swarm, changes in interaction radius seem to
have less effect on the results.

Figures 15 and 15 show the agent density distribution during the training and
prediction periods, respectively. Even with increased uncertainty in the
ground truth swarms, swarmDMD still does a reasonable job of capturing the
structure of the agents within the swarm, with the general patterns showing up
in both training and predictions for $r=0.05$, and the almost identical
pattern during training for $r=0.5$.

### First-Order Dynamics

Figure 16 shows the position, heading, polarisation, and angular momentum
plots for the FO Cartesian and polar dynamics. In general, FO polar performs
better than FO Cartesian. This is reasonable since FO Cartesian uses position
and velocity information, which in the datatype analysis resulted in higher
error than when relative distance or heading were used. It is interesting to
note that across error metrics the difference in error magnitude between
training and prediction periods is not as significant as when the standard
dynamics are used; the error often begins to increase during the training
period.

Figures 17 and 18 give the agent density distribution for the FO Cartesian and
polar dynamics. The FO polar distributions are almost identical for both the
training and prediction periods, whereas the distributions for the FO
Cartesian dynamics only capture the general pattern for training and
prediction with $r=0.05$, and capture almost none of the pattern for $r=0.5$.

Figure 16: From left to right, the resulting position, heading, polarisation,
and angular momentum errors of the first order Cartesian and polar dynamics
compared across ground truth interaction radii, $r$, 0.05 (blue), 0.25
(orange), and 0.5 (green). Ground truth has $\eta=0$.

Figure 17: Agent distribution analysis of swarmDMD with FO Cartesian and polar
dynamics over the training period, ground truth has $\eta=0$. On the left are
the distributions for $r=0.05$, and on the right the distributions for
$r=0.5$. The ground truth distributions are shown in the first row.  Figure
18: Agent distribution analysis of swarmDMD with FO Cartesian and polar
dynamics over a period of 5s prediction, ground truth has $\eta=0$. On the
left are the distributions for $r=0.05$, and on the right the distributions
for $r=0.5$. The ground truth distributions are shown in the first row.