Skip to main content
Erschienen in: Artificial Life and Robotics 2/2022

Open Access 26.11.2021 | Original Article

Application of neural ordinary differential equations to the prediction of multi-agent systems

verfasst von: Sebastian Herzog, Florentin Wörgötter

Erschienen in: Artificial Life and Robotics | Ausgabe 2/2022

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
download
DOWNLOAD
print
DRUCKEN
insite
SUCHEN
loading …

Abstract

Dynamic systems are usually described by differential equations, but formulating these equations requires a high level of expertise and a detailed understanding of the observed system to be modelled. In this work, we present a data-driven approach, which tries to find a parameterization of neural differential equations system to describe the underlying dynamic of the observed data. The presented method is applied to a multi-agent system with thousand agents.
Hinweise
This work was presented in part at the joint symposium with the 15th International Symposium on Distributed Autonomous Robotic Systems 2021 and the 4th International Symposium on Swarm Behavior and Bio-Inspired Robotics 2021(Online, June1–4, 2021).

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

1 Introduction

We present an approach to learn the dynamics of hundreds to thousands of agents in a system, where the underlying assumption is that the agents follow a collective dynamic, which is not obviously recognisable, but present. In this way, we hope to show scientists a method that allows them to verify model assumptions based on ordinary differential equations on their data. For the purposes of this report, we shall limit ourselves to the Hamiltonian of canonical classical mechanic equations with which movements of objects can be described by their position and velocity. Examples for such dynamics systems are flocks of birds or the movement of cell components. The underlying dynamics allow many conclusions, e.g. about the energy distribution in the system or whether there are symmetries or not.
To visualise the motion of many particles or of a swarm with many agents several approaches exists, like the group of optical flow methods [8, 9, 12], cross-correlation [1] and Kalman filters [19], these methods can be translated into more complex approaches like particle tracking velocimetry (PTV) [5, 14, 15, 20]. If a sufficient amount of data is available and agent/particle density is high enough, a vector field can be obtained by mapping the trajectories on a Cartesian grid. Thus, it is possible to visualise the dynamics of the underlying system. However, these approaches often result in an algorithmic frameworks of high complexity. The approach presented here is based on neural ordinary differential equations (nODEs) [3]. An artificial neural network (ANN) is used to approximate the Hamiltonian of canonical classical mechanic equations. This allows describing the underlying particle- or agent-swarm directly as a dynamic system without detours. To train the here-presented approach only a list of positions with their momentum is necessary. In this study, we derive the method for this and apply it to simulated data based on the boids [18] algorithm.

2 Methods

Considering a set of N coordinates \((\varvec{q},\varvec{p})\), where \(\varvec{q} \in \mathbb {R}^N\) represents the positions and \(\varvec{p} \in \mathbb {R}^N\) their momentum. A scalar function \(\mathcal {H}(\varvec{q}, \varvec{p})\) is called the Hamiltonian if:
$$\begin{aligned} \dot{\varvec{q}}= \frac{d \varvec{q}}{d t} = \frac{\partial \mathcal {H}}{\partial \varvec{p}} \text { and } \dot{\varvec{p}} = \frac{d \varvec{p}}{d t } = -\frac{\partial \mathcal {H}}{\partial \varvec{q}}. \end{aligned}$$
(1)
This system can be rephrased without restricting generality to
$$\begin{aligned} \dot{\varvec{q}} = \nabla _{\varvec{p}} \mathcal {H}(\varvec{q}, \varvec{p}) \text { and } \dot{\varvec{p}} = -\nabla _{\varvec{q}} \mathcal {H}(\varvec{q}, \varvec{p}), \end{aligned}$$
(2)
where \(\nabla\)
is the gradient operator. For nODEs it is common to approximate (Eq. 2) by ANNs, denoted by \(\mathcal {H}_{\varvec{\theta }}(\varvec{q}, \varvec{p})\), where \(\varvec{\theta }\) is a vector with all parameters of the ANN. A (feedforward) artificial neural network, also known as a multi-layer perceptron (MLP), is a series of logistic regression models stacked on top of each other. MLPs can be used for classification problems as well as for regression problems, depending on the final layer. In this work, we are solving regression problems defined by:
$$\begin{aligned} p(y| \varvec{x}, \varvec{\theta })&=\mathcal {N}(y | \varvec{w}^T \varvec{z} (\varvec{x}), \sigma ^2)\\ \nonumber \varvec{z}(\varvec{x})&= q(\varvec{V} \varvec{x})=[g(\varvec{v}_1^T \varvec{x}), \dots , g(\varvec{v}_H^T \varvec{x})], \end{aligned}$$
(3)
where y is the desired regression output, \(\varvec{x}\) the input vector, \(\varvec{w}\) the weight matrix, \(\varvec{v}_j = \varvec{V}_{j,:}\) is the jth row of \(\varvec{V}\), hidden layers \(\varvec{z}(\varvec{x})= \phi (\varvec{x}, \varvec{V})\) of size H, where g is the so-called activation function. \(\mathcal {N}(\cdot ,\sigma ^2)\) is the symbol for the normal distribution with variance \(\sigma ^2\). The hyperbolic tangent (tanh) is used as the activation function. To use (Eq. 3) for \(\mathcal {H}_{\varvec{\theta }}(\varvec{q}, \varvec{p})\) the framework of nODEs is used, which are a family of ANNs where the hidden layers parameterize the derivative of the hidden state using a neural network and the output of the network is computed using a black-box differential equation solver, where backpropagation [2, 4, 10] through the ODE solver is applied [3]. A special feature of nODEs is that the gradient is calculated using the adjoined sensitivity method [17], allowing a linear relation between problem size and computational complexity and a low memory consumption. After obtaining the gradient, the parameters of \(\mathcal {H}_{\varvec{\theta }}(\varvec{q}, \varvec{p})\) are trained by a gradient method with adaptive moment estimation, called ADAM [11]. The input data are all pairs of \((\varvec{q}, \varvec{p})\) in the training-set. And the loss function which is supposed to be optimised is
$$\begin{aligned} l_\theta&= \Vert \dot{ \varvec{q}} - \nabla _{\varvec{p}} \mathcal {H}_{\varvec{\theta }}(\varvec{q}, \varvec{p}) \Vert _2^2 \\ \nonumber &\quad + \Vert \dot{ \varvec{p}} - \nabla _{\varvec{q}} \mathcal {H}_{\varvec{\theta }}(\varvec{q}, \varvec{p}) \Vert _2^2 + \alpha \Vert \varvec{\theta }\Vert _1, \end{aligned}$$
(4)
where the first two terms simply describe the quadratic deviation, \(\Vert . \Vert _2^2\) denotes the \(l_2\)-norm and the third term \(\alpha \Vert \varvec{\theta }\Vert _1\), with \(\Vert . \Vert _1\) denotes the \(l_1\)-norm and forces sparisty on \(\varvec{\theta }\) for with \(\alpha \in \mathbb {R}\) a weighting parameter (in this work \(\alpha =0.3\)). While the details mentioned above may only differ in technical details from the nODE approach as described in [3], the addition of the sparsity term is a novelty to [3] which has proven to be necessary for the convergence to achieve the results discussed later. The implementation of \(\mathcal {H}_{\varvec{\theta }}(\varvec{q}, \varvec{p})\) was done with PyTorch [16] and is based on [3]. The network architecture consists of five dense layers, each layer has an activation layer with tanh. The first layer expects 2 inputs and has 128 nodes, followed by four more layers with 128 nodes and finally output layer with one output node.
In this work, we have deliberately avoided dividing the data into a training, validation and test set, because we are interested in the vector field in the end, which is not directly evident from the data anyhow. A generalization beyond the spatio-temporal domain of the training data is not the goal of this study. In the following results two points are examined. First, the learned vector field is validated if it can reproduce the ground truth trajectories from the boid algorithm, when using the initial conditions from the boid algorithm. Second, the trained system is used on new data, but with the same parameters for the random sources and compared to the nearest neighbours of the training data.

3 Results

To investigate the presented approach empirically, a simulation of the flocking behaviour of birds is used. For this simulation 1000 agents with separation, alignment and cohesion rules were modelled by the boids algorithm [18]. The boids algorithm with reflecting boundaries was implemented using python [21] and the numpy package [7]. The 1000 agents were placed randomly centred around (0, 0) (Fig. 1) but without overlap and with random initial velocities from \(\mathcal {U}[0.2,5]\) and random accelerations of \(\mathcal {U}[0,0.03]\), where \(\mathcal {U}[a,b]\) is the uniform distribution between a and b. The system was simulated \(t_{max}=5000\) time steps. These data were then used to train the presented approach with early stopping [6] and a patience of 15. In (Fig. 2) the values of the loss function over the epochs are plotted. Early stopping ends the training if the loss function does not improve over the last 15 epochs. The system was trained on a Nvidia GTX 1080, an epoch calculates on average \(61\pm 3\) seconds. In total 54 min 54 s, but probably half of the time would also be sufficient. After training the vector field of the nODE can be visualised, by generating an equidistant grid with \(n=50\) points and applying the learned \(\mathcal {H}_\theta (\cdot , \varvec{0})\) to each point. The resulting vector field is illustrated in (Fig. 3). Based on the learned vector field it’s possible to predict trajectories, using some values for \(\varvec{q}\) and \(\varvec{p}\) as initial conditions and applying this to the field. To check if the presented approach learned the underlying dynamic from the boid algorithm, all \(\varvec{q}\) and \(\varvec{p}\) from the training data were selected. A few exemplary trajectories are shown in (Fig. 4). The corresponding statistics are available in blue in (Fig. 5). It can be seen (Fig. 5) that the trajectories deviate about 7 units of length in the median, but there are also cases where the deviate exceeds 80 units, with a domain size of \(10^3 \times 10^3\) this is a comparably small error. To validate our approach further, we took the predicted nODE and randomly initialised 1000 agents with the same scheme as above and calculated the trajectories based on nODE over 5000 time steps. For each trajectory, the nearest neighbour of the original trajectories was searched and the \(l_2\)-deviation was calculated. This deviations can be seen in Fig. 5 in light orange. The expectation of the distribution is about 80 length units, which in relation to the total domain size again is not much.

4 Discussion

The approach presented here is an extension of the classic nODE approach. By adding a sparse regularisation term to (Eq. 4), it was possible to train the nODE network to learn the underlying dynamic of the agent motions from the boids algorithm. Surprisingly, even the resulting trajectories from the learned system only have a maximum deviation of 7 length units (divided by the domain width this equals \(0.7\%\)) compared to the ground truth data, which means that the underlying dynamic of the training data can be reconstructed. Here, it should be taken into account that the ANN used to learned the vector field has a very high degree of freedom which allows it to overfit the training data and describe even complex trajectories. Considering randomly initialised agents, from the same source distribution, the deviation increases in the median to up to 80 length units (or \(8\%\)) which is an increase of a factor of 10, but given the large domain this is still quite a good result. It also should be noted that no hyperparameter optimisation was considered for the approach presented at this stage. It is, therefore, to be expected that, if the loss function or the architecture of the network is further adapted, even better results could be achieved. It is also worth mentioning that we have chosen ADAM [11] because of its fast convergence, other algorithms such as SGD [13] may achieve better results, too. Methods like these need further investigation to understand in detail in which cases they generalise and in which not. However, we hope that approaches like the presented one can be helpful to gain new insights into systems where models based on first principles are hard to obtain. Especially, applications where only a part of the dynamics are described by first-principles can benefit from such “hybrid” modelling approaches where the unknown part of the dynamic is approximated by an nODE.
Open AccessThis article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://​creativecommons.​org/​licenses/​by/​4.​0/​.

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Literatur
1.
Zurück zum Zitat Bracewell RN, Bracewell RN (1986) The Fourier transform and its applications, vol 31999. McGraw-Hill New York Bracewell RN, Bracewell RN (1986) The Fourier transform and its applications, vol 31999. McGraw-Hill New York
2.
Zurück zum Zitat Bryson AE (1961) A gradient method for optimizing multi-stage allocation processes. In: Proc. Harvard Univ, Symposium on digital computers and their applications Bryson AE (1961) A gradient method for optimizing multi-stage allocation processes. In: Proc. Harvard Univ, Symposium on digital computers and their applications
3.
Zurück zum Zitat Chen Ricky TQ, Rubanova Y, Bettencourt J, Duvenaud D (2018) Neural ordinary differential equations. In: Proceedings of the 32nd International Conference on Neural Information Processing Systems, NIPS’18, page 6572-6583, Red Hook, NY, USA, Curran Associates Inc Chen Ricky TQ, Rubanova Y, Bettencourt J, Duvenaud D (2018) Neural ordinary differential equations. In: Proceedings of the 32nd International Conference on Neural Information Processing Systems, NIPS’18, page 6572-6583, Red Hook, NY, USA, Curran Associates Inc
5.
Zurück zum Zitat Fuchs T, Hain R, Kähler CJ (2017) Non-iterative double-frame 2D/3D particle tracking velocimetry. Exp. Fluids 58:119CrossRef Fuchs T, Hain R, Kähler CJ (2017) Non-iterative double-frame 2D/3D particle tracking velocimetry. Exp. Fluids 58:119CrossRef
7.
Zurück zum Zitat Harris CR, Millman KJ, van der Gommers Walt SJ, Virtanen PR, Cournapeau D, Wieser E, Taylor J, Berg S, Smith NJ, Kern R, Picus M, Hoyer S, Kerkwijk MH, van Brett M, Haldane A, del R’ıo JF, Wiebe M, Peterson P, G’erard-Marchant P, Sheppard K, Reddy T, Weckesser W, Abbasi H, Gohlke C, Oliphant TE, (2020) Array programming with NumPy. Nature 585(7825):357–362 Harris CR, Millman KJ, van der Gommers Walt SJ, Virtanen PR, Cournapeau D, Wieser E, Taylor J, Berg S, Smith NJ, Kern R, Picus M, Hoyer S, Kerkwijk MH, van Brett M, Haldane A, del R’ıo JF, Wiebe M, Peterson P, G’erard-Marchant P, Sheppard K, Reddy T, Weckesser W, Abbasi H, Gohlke C, Oliphant TE, (2020) Array programming with NumPy. Nature 585(7825):357–362
8.
Zurück zum Zitat Berthold KPH, Schunck BG (1981) Determining optical flow. Artif Intell 17(1):185–203 Berthold KPH, Schunck BG (1981) Determining optical flow. Artif Intell 17(1):185–203
9.
Zurück zum Zitat Jason JY, Harley AW, Derpanis KG (2016) Back to basics: unsupervised learning of optical flow via brightness constancy and motion smoothness. In: European Conference on Computer Vision, pages 3–10. Springer Jason JY, Harley AW, Derpanis KG (2016) Back to basics: unsupervised learning of optical flow via brightness constancy and motion smoothness. In: European Conference on Computer Vision, pages 3–10. Springer
10.
Zurück zum Zitat Kelley HJ (1960) Gradient theory of optimal flight paths. ARS J 30(10):947–954CrossRef Kelley HJ (1960) Gradient theory of optimal flight paths. ARS J 30(10):947–954CrossRef
11.
Zurück zum Zitat Diederik PK, Jimmy B (2017) A method for stochastic optimization, Adam Diederik PK, Jimmy B (2017) A method for stochastic optimization, Adam
12.
Zurück zum Zitat Kroeger T, Timofte R, Dai D, Gool LV (2016) Fast optical flow using dense inverse search. In: European Conference on Computer Vision, pages 471–488. Springer Kroeger T, Timofte R, Dai D, Gool LV (2016) Fast optical flow using dense inverse search. In: European Conference on Computer Vision, pages 471–488. Springer
13.
Zurück zum Zitat LeCun YA, Bottou L, Orr Genevieve B, Müller K-R (2012) Efficient BackProp. Springer, Berlin, Heidelberg, pp 9–48 LeCun YA, Bottou L, Orr Genevieve B, Müller K-R (2012) Efficient BackProp. Springer, Berlin, Heidelberg, pp 9–48
14.
Zurück zum Zitat Gruen A, Maas HG, Papantoniou D (1993) Particle tracking velocimetry in three-dimensional flows. Exp. Fluids 15(2):133–146CrossRef Gruen A, Maas HG, Papantoniou D (1993) Particle tracking velocimetry in three-dimensional flows. Exp. Fluids 15(2):133–146CrossRef
15.
Zurück zum Zitat Nishino K, Kasagi N, Hirata M (1989) Three-dimensional particle tracking velocimetry based on automated digital image processing Nishino K, Kasagi N, Hirata M (1989) Three-dimensional particle tracking velocimetry based on automated digital image processing
16.
Zurück zum Zitat Paszke A, Gross S, Massa F, Lerer A, Bradbury J, Chanan G, Killeen T, Lin Z, Gimelshein N, Antiga L, Desmaison A, Kopf A, Yang E, DeVito Z, Raison M, Tejani A, Chilamkurthy S, Steiner B, Fang L, Bai J, Chintala S (2019) Pytorch: an imperative style, high-performance deep learning library. In: Wallach H, Larochelle H, Beygelzimer A, d Alché-Buc F, Fox E, Garnett R (eds) Advances in Neural Information Processing Systems 32, pages 8024–8035. Curran Associates, Inc Paszke A, Gross S, Massa F, Lerer A, Bradbury J, Chanan G, Killeen T, Lin Z, Gimelshein N, Antiga L, Desmaison A, Kopf A, Yang E, DeVito Z, Raison M, Tejani A, Chilamkurthy S, Steiner B, Fang L, Bai J, Chintala S (2019) Pytorch: an imperative style, high-performance deep learning library. In: Wallach H, Larochelle H, Beygelzimer A, d Alché-Buc F, Fox E, Garnett R (eds) Advances in Neural Information Processing Systems 32, pages 8024–8035. Curran Associates, Inc
17.
Zurück zum Zitat Pontryagin LS (2018) Mathematical theory of optimal processes. Routledge Pontryagin LS (2018) Mathematical theory of optimal processes. Routledge
18.
Zurück zum Zitat Reynolds CW (1987) Flocks herds and schools: A distributed behavioral model. In: Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’87, page 25–34. Association for Computing Machinery, New York Reynolds CW (1987) Flocks herds and schools: A distributed behavioral model. In: Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’87, page 25–34. Association for Computing Machinery, New York
19.
Zurück zum Zitat Jinya S, Li B, Chen W-H (2015) On existence, optimality and asymptotic stability of the kalman filter with partially observed inputs. Automatica 53:149–154MathSciNetCrossRef Jinya S, Li B, Chen W-H (2015) On existence, optimality and asymptotic stability of the kalman filter with partially observed inputs. Automatica 53:149–154MathSciNetCrossRef
20.
Zurück zum Zitat Tanida Y, Miyashiro H (1992) Flow visualization VI, chapter: 3D particle tracking velocimetry-its possibilities and limitations. Springer, BerlinCrossRef Tanida Y, Miyashiro H (1992) Flow visualization VI, chapter: 3D particle tracking velocimetry-its possibilities and limitations. Springer, BerlinCrossRef
21.
Zurück zum Zitat Van Rossum Guido, Drake Fred L (2009) Python 3 reference manual. CreateSpace, Scotts Valley Van Rossum Guido, Drake Fred L (2009) Python 3 reference manual. CreateSpace, Scotts Valley
Metadaten
Titel
Application of neural ordinary differential equations to the prediction of multi-agent systems
verfasst von
Sebastian Herzog
Florentin Wörgötter
Publikationsdatum
26.11.2021
Verlag
Springer Japan
Erschienen in
Artificial Life and Robotics / Ausgabe 2/2022
Print ISSN: 1433-5298
Elektronische ISSN: 1614-7456
DOI
https://doi.org/10.1007/s10015-021-00719-6

Weitere Artikel der Ausgabe 2/2022

Artificial Life and Robotics 2/2022 Zur Ausgabe

Neuer Inhalt