1 Introduction

The study of the behavior of interacting agents in groups of animals has gained increasing interest in various fields such as biology, engineering, mathematics (see [2, 8, 12, 15, 20]). One fascinating feature of such systems is the collective behavior described as formation patterns and can be found in many natural systems such as flocks of birds, schools of fish, chemical compounds, crowd dynamics. From the biological point of view, pattern motion is the consequence of two natural behaviors. On the one hand, agents desire to communicate and stay close to the group. On the other hand, when they stay too close, they try to keep a distance to avoid collision with other agents. Hence, for understanding these behaviors, it is indispensable to take biological phenomena into account. The research on mathematical modeling and simulation of these systems is of increasing interest, starting with the works of Reynolds [19]. Reynolds’s model, called the three-zone model, is the first principle model of swarming consisting of three fundamental characteristics of collective motion: cohesion, separation, and alignment rules. Further, this model has been extensively improved by adding many different effects and analyzed for different types of animals. For more details, see, e.g., [1, 3, 4, 10, 11, 14, 16]. In connection with these swarming models, it is essential to mention that the continuous models are developed through partial differential equations (PDEs) that describes the evolution of the particles’ density in the systems composed of a large number of interacting agents such as cell, molecular organism, or chemo-taxis with high drift effect; see [13, 21].

In the present day, despite a large number of works devoted to studying the stability of the swarm, it is still of paramount interest how agents form the pattern configuration when they are faced with situations where a converging stable state cannot be ensured, especially in the presence of communication with time delay which is a result of traffic congestion or finite speeds of transmission and spread. The stability of swarming concerning time delays is investigated in various models. Firstly, a well-known model is the Cucker–Smale flocking model, which describes agent’s motion based on its neighbor agents’ positions and velocities. The emergence of the flocking model described by the Cucker–Smale (CS) model with time delay was primarily investigated in [5, 6, 9, 17, 18]. In this model, time delays are included in the dynamic of velocities of agents. Besides, the model has been continuously extended by numerous researchers; for example, in [22] the authors consider the CS model by including a time delay in the communication function and velocities of agents, and the authors of [6] study the emergence of flocking where the interaction of agents is based on the CS communication function with a time delay and an attraction–repulsion force.

The contribution to this research effort is investigating the swarming model in which the interaction mechanism consists of attraction and repulsion functions which contain time delays. In particular, the first- and second-order models are studied. In the first-order model, time-delays are included in the agents’ position, while in the second-order model, agents adapt their velocity relative to other agents’ velocities with communication delay. Furthermore, based on these two models, the emergence of the swarm into the pattern formation is theoretically and numerically investigated. The stability of the swarm is related to parameters of the attraction and repulsion functions.

This work is organized as follows. In the next section, the first- and second-order swarm models with time-delay in the communication function are discussed. Additionally, in the first-order model, the stability of the swarm is analyzed and supplemented with two numerical test cases. In the second-order model, the dispersion and disagreement of the swarms that describe converging to pattern configuration are theoretically and numerically investigated. A conclusion in the last section completes the exposition of this work.

2 Swarm model and stability of swarm aggregation

In this section, we discuss the swarm model based on an agent-based model in an n-dimensional Euclidean space proposed in [7] where the attraction–repulsion function includes a time delay. The evolution of swarming for the first- and second-order models is discussed, and then for both models, its stability properties are theoretically and numerically investigated.

2.1 The first-order model

We consider the motion of N interacting individuals where their motion depends only on the position of an individual itself and its observation of other individuals’ positions. The equation of motion of the ith agent is given by

$$ \dot{x}_{i}(t)=-\frac{1}{N}\sum _{j\neq i}^{N}\nabla _{x_{i}}U\bigl( \bigl\Vert x_{i}(t)-x_{j}(t) \bigr\Vert \bigr),\quad i=1,\dots ,N, $$
(1)

where \(x_{i}(t) \in \mathbb {R}^{d}\) represents the position of the ith agent and \(\nabla _{x_{i}}U(\|x_{i}(t)-x_{j}(t)\|)\) denotes the gradient of U with respect to \(x_{i}\). Here \(\|x_{i}(t)-x_{j}(t)\|\) is the Euclidean distance between the ith and jth agents. The function \(U:(\mathbb{R}^{d})^{N}\rightarrow \mathbb{R}\) represents the Morse potential function, which contains attractive and repulsive parts. The Morse potential has the following form:

$$ U(r)=C_{r}e^{-\frac{r}{l_{r}}}-C_{a}e^{-\frac{r}{l_{a}}}, $$
(2)

where \(C_{r}e^{-\frac{r}{l_{r}}}\) and \(C_{a}e^{-\frac{r}{l_{a}}}\) model short-range repulsion and long-range attraction, respectively. Parameters \(C_{r}\), \(C_{a}\) represent repulsive and attractive strengths, respectively, whereas \(l_{r}\), \(l_{a}\) are repulsive and attractive length scales. The derivative of the Morse potential is expressed as follows:

$$ \frac{\partial }{\partial x_{i}}U\bigl( \bigl\Vert x_{i}(t)-x_{j}(t) \bigr\Vert \bigr)= \frac{x_{i}(t)-x_{j}(t)}{ \Vert x_{i}(t)-x_{j}(t) \Vert } \biggl( \frac{C_{a}}{l_{a}}e^{-\frac{ \Vert x_{i}(t)-x_{j}(t) \Vert }{l_{a}}}- \frac{C_{r}}{l_{r}}e^{-\frac{ \Vert x_{i}(t)-x_{j}(t) \Vert }{l_{r}}} \biggr). $$

Next, we discuss the swarming system described in (1) with the effect of time-delays on repulsion and attraction. In this system, the time delay is a positive constant and is denoted as τ. Time delays model the situation that agents receive information from other members in the group after a certain time delay. As a consequence, each agent needs time to elaborate its reaction to other agents in the group. The swarming system (1) including the effect of time delay is presented as follows:

$$ \dot{x}_{i}(t)=-\frac{1}{N}\sum _{j\neq i}^{N}\nabla _{x_{i}}U\bigl( \bigl\Vert x_{i}(t)-x_{j}(t- \tau ) \bigr\Vert \bigr),\quad i=1,\dots ,N. $$
(3)

For simplicity, we define

$$ r_{ij}(t,\tau )= \bigl\Vert x_{i}(t)-x_{j}(t- \tau ) \bigr\Vert , $$
(4)

and rewrite the derivative with respect to \(r_{ij}\) as

$$ U'(r_{ij})=\frac{C_{a}}{l_{a}}e^{-\frac{r_{ij}}{l_{a}}}- \frac{C_{r}}{l_{r}}e^{-\frac{r_{ij}}{l_{r}}}. $$
(5)

Therefore, the swarming system with time delay becomes

$$\begin{aligned} \dot{x}_{i}(t) =&-\frac{1}{N}\sum _{j\neq i}^{N}\nabla _{x_{i}}U(r_{ij}) \\ =&-\frac{1}{N}\sum_{j\neq i}^{N} \biggl( \frac{x_{i}(t)-x_{j}(t-\tau )}{r_{ij}} \biggr)U'(r_{ij}), \end{aligned}$$
(6)

for \(i=1,\dots ,N\), with given initial data

$$ x_{i}(s)=x_{i}^{0}(s) ,\quad \text{for } s\in [-\tau ,0]. $$

In the following, we consider numerical simulations with the swarming system in the one-dimensional case, \(d=1\), in two test cases: a system without time delay (\(\tau = 0\)) and a system with time delay \(\tau =3\). In both experiments, we consider three agents where the initial positions of agents are distributed randomly in \([-1, 1]\) and the parameters related to the model are \(C_{a} = 5\), \(C_{r} = 3\), \(l_{a}= 4 \), and \(l_{r} = 1\). The results of numerical experiments are shown in Fig. 1. It can be seen in Figs. 1(a) and 1(b) that, due to the effect of the time delay, agents’ motion fluctuates during the early time; however, after a certain time, they start self-organizing and then become stationary.

Figure 1
figure 1

Simulation of the swarming model with three agents. Panel (a) presents the position of agents where the communication function has no time-delay effect, while panel (b) shows agents’ position where the interaction between agents exhibits the time-delay effect

2.2 Stability analysis for the first-order model

In this subsection, theoretical results concerning the formation pattern of the swarm are investigated. We begin by introducing a free agent, a swarm member who does not have any neighbors in its repulsive range.

Definition 1

An agent i is called a “free agent” with respect to time delay if \(r_{ij}(t, \tau )>\delta \), \(\forall j=1, \dots , N\), \(j\neq i\), and δ is a repulsive range such that \(U'(r_{ij})>0\).

Theorem 1

Let \(R(s)=\sup_{i}\{\|x_{i}(s)\|\}\), for \(i=1, \ldots , N\) and \(s\in [t-\tau ,t]\), be the swarming radius. If all members of the swarm are free agents with respect to some time delay, then their motion is towards the center.

Proof

Without loss of generality, we choose \(R=\|x_{1}\|\). Consider

$$\begin{aligned} \frac{d}{dt} \biggl(\frac{1}{2} \bigl\Vert x_{1}(t) \bigr\Vert ^{2} \biggr) =&\bigl\langle x_{1}(t), \dot{x}_{1}(t)\bigr\rangle \\ =& \Biggl\langle x_{1}(t),-\frac{1}{N}\sum _{j\neq 1}^{N} \biggl( \frac{x_{1}(t)-x_{j}(t-\tau )}{r_{1j}} \biggr)U'(r_{1j}) \Biggr\rangle \\ =&\frac{1}{N}\sum_{j\neq 1}^{N} \biggl( \frac{\langle x_{1}(t),x_{j}(t-\tau )\rangle - \Vert x_{1}(t) \Vert ^{2}}{r_{1j}} \biggr)U'(r_{1j}), \end{aligned}$$

where \(\lVert \cdot \rVert \) and \(\langle \cdot , \cdot \rangle \) denote the Euclidean norm and inner product, respectively. Since the first agent is free,

$$ \bigl\Vert x_{1}(t)-x_{j}(t-\tau ) \bigr\Vert > \delta ,\quad \forall j=2, \ldots , N, \quad\text{and}\quad U' \bigl( \bigl\Vert x_{1}(t)-x_{j}(t-\tau ) \bigr\Vert \bigr)=U'(r_{1j}) > 0. $$

As a consequence, \(\langle x_{1}(t),x_{j}(t-\tau )\rangle -\|x_{1}(t)\|^{2}\leq 0\). It follows that \(\frac{d}{dt} (\frac{1}{2}\|x_{1}(t)\|^{2} )\leq 0\).

Therefore R is a decreasing function, that is, all agents move towards the center. □

In the following theorem, the stability of swarming corresponding to dispersion and cohesion properties are investigated. These properties are related to attraction and repulsion parameters (\(C_{a}\), \(C_{r}\), \(l_{a}\), \(l_{r}\)) in Morse potential function. We denote \(C=C_{r}/C_{a}\) and \(l=l_{r}/l_{a} \).

Theorem 2

(Dispersion and cohesion under Morse potential)

  1. 1.

    For \(C\geq l>0\), the swarming radius becomes unbounded as \(t\rightarrow \infty \).

  2. 2.

    For \(l\leq \min \{1,C\}\), the swarming radius is bounded.

Proof

Without loss of generality, we choose the swarming radius \(R=\|x_{1}\|\). We consider

$$\begin{aligned} \frac{d}{dt} \biggl(\frac{1}{2} \bigl\Vert x_{1}(t) \bigr\Vert ^{2} \biggr) =& \Biggl\langle x_{1}(t),-\frac{1}{N}\sum_{j\neq 1}^{N} \biggl( \frac{x_{1}(t)-x_{j}(t-\tau )}{r_{1j}} \biggr)U'(r_{1j}) \Biggr\rangle \\ =&-\frac{1}{N}\sum_{j\neq 1}^{N} \biggl( \frac{ \Vert x_{1}(t) \Vert ^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle }{r_{1j}} \biggr) \biggl(\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}}- \frac{C_{r}}{l_{r}}e^{-\frac{r_{1j}}{l_{r}}} \biggr) \\ =&\frac{1}{N}\sum_{j\neq 1}^{N} \biggl( \frac{ \Vert x_{1}(t) \Vert ^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle }{r_{1j}} \biggr) \biggl(\frac{C_{r}}{l_{r}}e^{-\frac{r_{1j}}{l_{r}}}- \frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggr) \\ =&\frac{1}{N}\sum_{j\neq 1}^{N} \biggl( \frac{ \Vert x_{1}(t) \Vert ^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle }{r_{1j}} \biggr) \biggl[e^{-\frac{r_{1j}}{l_{a}}} \biggl( \frac{C_{r}}{l_{r}}e^{r_{1j}( \frac{1}{l_{a}}-\frac{1}{l_{r}})}-\frac{C_{a}}{l_{a}} \biggr) \biggr] \\ =&\frac{1}{N}\sum_{j\neq 1}^{N} \biggl( \frac{ \Vert x_{1}(t) \Vert ^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle }{r_{1j}} \biggr) \biggl[\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl( \frac{C}{l}e^{r_{1j}(\frac{l-1}{l_{r}})}-1 \biggr) \biggr]. \end{aligned}$$

Since \(R=\|x_{1}\|\), it follows that \(\|x_{1}(t)\|^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle \geq 0\). For \(C\geq l>1\),

$$ \frac{C}{l}e^{r_{1j}(\frac{l-1}{l_{r}})}-1 >0. $$

This yields that \(\frac{d}{dt} (\frac{1}{2}\|x_{1}(t)\|^{2} )\geq 0\). Therefore, the swarming radius becomes unbounded as \(t\rightarrow \infty \).

Further, we prove the second statement when \(l\leq \min \{1,C\}\). From

$$ \frac{d}{dt} \biggl(\frac{1}{2} \bigl\Vert x_{1}(t) \bigr\Vert ^{2} \biggr)= \frac{1}{N} \sum_{j\neq 1}^{N} \biggl( \frac{ \Vert x_{1}(t) \Vert ^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle }{r_{1j}} \biggr) \biggl[\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl( \frac{C}{l}e^{r_{1j}(\frac{l-1}{l_{r}})}-1\biggr) \biggr], $$

we know that \(\frac{\|x_{1}(t)\|^{2}-\langle x_{1}(t),x_{j}(t-\tau )\rangle }{r_{1j}} \geq 0\). Let us consider three cases.

Case I: If \(r_{1j}=\frac{l_{r}}{1-l}\ln (\frac{C}{l} )\), then

$$\begin{aligned} \frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{r_{1j}( \frac{l-1}{l_{r}})}-1 \biggr) =&\frac{C_{a}}{l_{a}}e^{- \frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{(\frac{l_{r}}{1-l})( \frac{l-1}{l_{r}})\ln (\frac{C}{l})}-1 \biggr) \\ =&\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{(-1) \ln (\frac{C}{l})}-1 \biggr) \\ =&\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l} \biggl( \frac{C}{l} \biggr)^{-1}-1 \biggr)=0. \end{aligned}$$

We get that \(\frac{d}{dt} (\frac{1}{2}\|x_{1}(t)\|^{2} )=0\). Therefore, the swarming radius is norm-preserving.

Case II: If \(r_{1j}=\frac{l_{r}}{1-l}\ln (\frac{2C}{l} )> \frac{l_{r}}{1-l}\ln (\frac{C}{l} )\), then

$$\begin{aligned} \frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{r_{1j}( \frac{l-1}{l_{r}})}-1 \biggr) =&\frac{C_{a}}{l_{a}}e^{- \frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{(\frac{l_{r}}{1-l})( \frac{l-1}{l_{r}})\ln (\frac{2C}{l})}-1 \biggr) \\ =&\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{(-1) \ln (\frac{2C}{l})}-1 \biggr) \\ =&\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l} \biggl( \frac{2C}{l} \biggr)^{-1}-1 \biggr) \\ =&\frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(-\frac{1}{2} \biggr)< 0. \end{aligned}$$

It follows that \(\frac{d}{dt} (\frac{1}{2}\|x_{1}(t)\|^{2} )<0\). Therefore, the swarming radius is decreased.

Case III: If \(r_{1j}=\frac{l_{r}}{1-l}\ln (\frac{C}{2l} ) < \frac{l_{r}}{1-l}\ln (\frac{C}{l} )\), then

$$\begin{aligned} \frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{r_{1j}( \frac{l-1}{l_{r}})}-1 \biggr) =& \frac{C_{a}}{l_{a}}e^{- \frac{r_{1j}}{l_{a}}} \biggl(\frac{C}{l}e^{(\frac{l_{r}}{1-l})( \frac{l-1}{l_{r}})\ln (\frac{C}{2l})}-1 \biggr) \\ =& \frac{C_{a}}{l_{a}}e^{-\frac{r_{1j}}{l_{a}}}>0, \end{aligned}$$

that is, \(\frac{d}{dt} (\frac{1}{2}\|x_{1}(t)\|^{2} ) >0\). Hence, the swarming radius is increased. □

From the three cases discussed above, it can be concluded that if the distance between the first agent who has maximum swarming radius and the jth agent is equal to \(r_{1j}=\frac{l_{r}}{1-l}\ln (\frac{C}{l} )\), then the swarming radius is bounded. On the other hand, if \(r_{1j}\) is greater than \(\frac{l_{r}}{1-l}\ln (\frac{C}{l} )\), then the swarming radius is decreased to zero. While, if the distance between the first and jth agent is less than \(\frac{l_{r}}{1-l}\ln (\frac{C}{l} )\), then swarming radius is increased. It shows that agents get far away from the center.

We present results of experiments to numerically verify Theorem 2.

It can be seen from Fig. 2 that for \(C\geq l>1\), when \(t\rightarrow \infty \), each agent moves far away from the origin, whereas Fig. 3 illustrates that for \(l\leq \min \{1,C\}\) the swarming radius is bounded.

Figure 2
figure 2

Trajectories of solutions to swarming system with time delay (\(\tau =5\)) in time \(t\in [0,50]\) for \(N=5\) where parameters are \(C_{a}=1\), \(l_{a}=2\), \(C_{r}=4\), and \(l_{r} =3\)

Figure 3
figure 3

Simulation of the swarming system with time delay (\(\tau = 5\)) for \(N=5\) in time \(t\in [0,50]\) where parameters are given as \(C_{a}=1\), \(l_{a}=2\), \(C_{r}=4\), and \(l_{r} =1\)

2.3 The second-order model

In this section, we focus on the swarming model which includes rules for orientation. In particular, this model contains a mechanism of self-propulsion in which each agent moves with constant speed and adopts the average direction among its neighbors. The second-order model is given by the following equations:

$$\begin{aligned}& \dot{x}_{i}(t) = v_{i}(t), \\& \dot{v}_{i}(t) = \bigl(\alpha -\beta \bigl\Vert v_{i}(t) \bigr\Vert ^{2}\bigr)v_{i}(t)- \frac{1}{N}\sum_{j\neq i}^{N}\nabla _{x_{i}}U\bigl( \bigl\Vert x_{i}(t)-x_{j}(t- \tau ) \bigr\Vert \bigr),\quad i=1,\dots ,N, \end{aligned}$$
(7)

where \(x_{i} ,v_{i} \in \mathbb{R}^{d}\) are position and velocity of the ith agent, respectively. The term \((\alpha -\beta \|v_{i}(t)\|^{2})v_{i}(t)\) models self-propulsion and friction forces where parameters \(\alpha >0\) and \(\beta >0\) represent self-propulsion and friction, respectively. The second term is the Morse potential function including interaction with a time delay.

In the following, we theoretically and numerically study the stability of the swarm described as converging to the pattern configuration. For investigation of pattern properties, we calculate dispersion \(X(t)\) and disagreement \(V(t)\) proposed in [17].

Definition 2

Let \(\mathbf {x}(t) =(x_{1}(t), \ldots , x_{N}(t))\) and \(\mathbf {v}(t)=(v_{1}(t), \dots , v_{N}(t))\) be the solution of the swarming model (7). We define dispersion and disagreement as

$$ X(t):=\max_{i,j} \bigl\Vert x_{i}(t)-x_{j}(t) \bigr\Vert \quad\text{and}\quad V(t):= \max_{i,j} \bigl\Vert v_{i}(t)-v_{j}(t) \bigr\Vert , $$
(8)

for \(i, j=1, \ldots , N\). We say that the solution \((\mathbf {x}(t), \mathbf {v}(t))\) tends to consensus if

$$ \sup_{t>0}X(t)< +\infty \quad\text{and}\quad \lim _{t \rightarrow +\infty }V(t)=0. $$
(9)

Proposition 1

Let \((\mathbf {x}(t), \mathbf {v}(t))\) be the solution of system (7). If the solution \((\mathbf {x}(t), \mathbf {v}(t))\) converges to consensus, then

$$ \lim_{t\rightarrow \infty } \frac{1}{N}\bigl\lVert x_{i}(t)-x_{j}(t- \tau )\bigr\rVert = \frac{\l _{r}}{1-l}\ln \biggl(\frac{C}{l} \biggr) \quad\textit{and}\quad \lim_{t\rightarrow \infty } \frac{1}{N} \bigl\lVert v_{i}(t)\bigr\rVert = \sqrt{\frac{\alpha }{\beta }}. $$
(10)

Proof

From the dynamical system (7), we consider \(\dot{v_{i}}(t)=0\), for \(i=1, \ldots , N\), that is,

$$ \bigl(\alpha -\beta \bigl\Vert v_{i}(t) \bigr\Vert ^{2}\bigr)v_{i}(t) =0 \quad\text{and}\quad \frac{1}{N}\sum_{j\neq i}^{N}\nabla _{x_{i}}U\bigl( \bigl\Vert x_{i}(t)-x_{j}(t- \tau ) \bigr\Vert \bigr) =0. $$

We consider \((\alpha -\beta \|v_{i}(t)\|^{2})v_{i}(t) =0 \) and assume that \(v_{i}(t) \neq 0\). Then it yields

$$\begin{aligned}& \alpha -\beta \bigl\Vert v_{i}(t) \bigr\Vert ^{2} = 0, \\& \bigl\lVert v_{i}(t) \bigr\rVert = \sqrt{\frac{\alpha }{\beta }}. \end{aligned}$$

Next, consider \(\frac{1}{N}\sum_{j\neq i}^{N}\nabla _{x_{i}}U(\|x_{i}(t)-x_{j}(t- \tau )\|) =0\), which can be written as

$$\begin{aligned} -\frac{1}{N}\sum_{j\neq i}^{N} \biggl( \frac{x_{i}(t)-x_{j}(t-\tau )}{r_{ij}} \biggr) \biggl( \frac{C_{a}}{l_{a}}e^{-\frac{r_{ij}}{l_{a}}}- \frac{C_{r}}{l_{r}}e^{- \frac{r_{ij}}{l_{r}}} \biggr) =&0. \end{aligned}$$

Since \((\frac{x_{i}(t)-x_{j}(t-\tau )}{r_{ij}} ) \neq 0\), we have \((\frac{C_{a}}{l_{a}}e^{-\frac{r_{ij}}{l_{a}}}- \frac{C_{r}}{l_{r}}e^{-\frac{r_{ij}}{l_{r}}} ) =0 \).

Consequently, \(r_{ij} = \lVert x_{i}(t)-x_{j}(t-\tau )\rVert = \frac{l_{r}}{1-l} \ln (\frac{C}{l})\). It can be concluded that when the system (7) tends to consensus, the velocity of each agent converges to value \(\sqrt{\frac{\alpha }{\beta }}\) and

$$ \lim_{t\rightarrow \infty } \frac{1}{N}\bigl\lVert x_{i}(t)-x_{j}(t- \tau )\bigr\rVert = \frac{\l _{r}}{1-l}\ln \biggl(\frac{C}{l} \biggr). $$

 □

In the sequel, we present results of numerical experiments to validate some aspects of theoretical findings and demonstrate the stability of swarms in two dimensions. For this purpose, we consider the following four test-cases:

Case I: \(C_{a}>C_{r}\) and \(l_{a}>l_{r}\) (see Figs. 46).

Figure 4
figure 4

Simulation of the second-order swarming model with time delay (\(\tau =5\)) for five agents, \(N=10 \) in time \(t\in [0,1000]\). The corresponding parameters are given as \(\alpha =0.7\), \(\beta =0.5\), \(C_{a}=5\), \(l_{a}=100\), \(C_{r}=1 \), and \(l_{r}=1\). The position of each agent is depicted by a circle and the velocity is represented by a vector at agent’s position

In Case I, attraction parameters are stronger than those of repulsion. Hence, agents get closer to each other. As a consequence, the swarm is formed as a tight cluster, as showed in Fig. 4. In addition, it can be seen from Fig. 5 that \(X(t)\) and \(V(t)\) are periodical in amplitude and bounded by some value.

Figure 5
figure 5

Dispersion and disagreement of Case I for \(t\in [0,1000]\)

Figure 6
figure 6

The average distance between agents and the velocity of agents for Case I and \(t\in [0,1000]\). Panel (a) shows the comparison of the average distance between agents with the value \(\frac{l_{r}}{1-l}\ln (\frac{C}{l})\). Panel (b) shows the average velocity of agents compared with the value \(\sqrt{\frac{\alpha }{\beta }}\)

Case II: \(C_{a}>C_{r}\) and \(l_{a}< l_{r}\) (see Figs. 79).

Figure 7
figure 7

Simulation of the second-order swarming model with time delay (\(\tau =5\)) for five agents, \(N=10 \), and time \(t\in [0,100]\). The corresponding parameters are given as \(\alpha =0.7\), \(\beta =0.5\), \(C_{a}=5\), \(l_{a}=1\), \(C_{r}=1 \), and \(l_{r}=100\). The position of each agent is depicted by a circle and the velocity is represented by a vector at agent’s position

Case III: \(C_{a}< C_{r}\) and \(l_{a}< l_{r} \) (see Figs. 1012).

In Cases II and III, the repulsive length has a greater magnitude than the attractive one. It means that agents are repelled from others. It follows that the pattern configuration would not be formed, as shown in Figs. 8 and 11.

Figure 8
figure 8

Dispersion and disagreement of Case II for \(t\in [0,100]\)

Figure 9
figure 9

The average distance between agents and the average velocity of agents of Case II for \(t\in [0,100]\)

Figure 10
figure 10

Simulation of the second-order swarming model with time delay (\(\tau =5\)) for five agents, \(N=10 \), and time \(t\in [0,100]\). The corresponding parameters are given as \(\alpha =0.7\), \(\beta =0.5\), \(C_{a}=1\), \(l_{a}=1\), \(C_{r}=5 \), and \(l_{r}=100\). The position of each agent is depicted by a circle and the velocity is represented by a vector at agent’s position

Figure 11
figure 11

Dispersion and disagreement of Case III for \(t\in [0,100]\)

Figure 12
figure 12

The average distance between agents and average velocity of agents of Case II for \(t\in [0,100]\)

Case IV: \(C_{a}< C_{r}\) and \(l_{a}>l_{r}\) (see Figs. 1315).

Figure 13
figure 13

Simulation of the second-order swarming model with time delay (\(\tau =5\)) for five agents, \(N=10 \), and time \(t\in [0,1000]\). The corresponding parameters are given as \(\alpha =0.7\), \(\beta =0.5\), \(C_{a}=1\), \(l_{a}=100\), \(C_{r}=2 \), and \(l_{r}=1\). The position of each agent is depicted by a circle and the velocity is represented by a vector at agent’s position

It can be seen from Figs. 14 and 15 that, when \(t\rightarrow \infty \), \(X(t)\) becomes constant and \(V(t)\) tends to zero. This means that the swarm converges to an asymptotic state. Pattern configuration is formed and each agent moves with the same velocity.

Figure 14
figure 14

Dispersion and disagreement of Case IV for \(t\in [0,1000]\)

Figure 15
figure 15

The average distance between agents and average velocity of agents of Case I for \(t\in [0,1000]\). Panel (a) shows the comparison of the average distance between agents with the value \(\frac{l_{r}}{1-l}\ln (\frac{C}{l})\). Panel (b) shows the average velocity of agents compared with the value \(\sqrt{\frac{\alpha }{\beta }}\)

3 Conclusion

This work presented the emergence of swarm with delayed communication. First, the first- and second-order models of the swarm were described, where in the interaction function the time delay was taken into account. Further, the stability of the swarm was analyzed. For both models, agents’ movement to a stable state depended on the attraction–repulsion strengths and length scale in the Morse potential function. Finally, numerical results demonstrated the emergence of the swarm and referred that the swarm converges to an asymptotic state. Pattern configuration was formed, and each agent moved with the same velocity.