Gathering Teams of Deterministic Finite Automata on a Line
Abstract
Several mobile agents, modelled as deterministic finite automata, navigate in an infinite line in synchronous rounds. All agents start in the same round. In each round, an agent can move to one of the two neighboring nodes, or stay idle. Agents have distinct labels which are integers from the set . They start in teams, each of which consists of agents, for some fixed integer . Agents in a team have the same starting node. The adversary decides the compositions of teams, and their starting nodes. Whenever an agent enters a node, it sees the entry port number and the states of all collocated agents; this information forms the input of the agent on the basis of which it transits to the next state and decides the current action. The aim is for all agents to gather at the same node and stop. Gathering is feasible, if this task can be accomplished for any decisions of the adversary, and its time is the worst-case number of rounds from the start till gathering.
We consider the feasibility and time complexity of gathering teams of agents, and give a complete solution of this problem. It turns out that both feasibility and complexity of gathering depend on the crucial parameter which is the size of teams. For the oriented line, gathering is impossible if , and it can be accomplished in time , for , where is the distance between the starting nodes of the most distant teams. This complexity is of course optimal. For the unoriented line, the situation is different. For , gathering is also impossible, but for , the optimal time of gathering is , and for the optimal time of gathering is .
Solving the gathering problem for agents that are finite automata navigating in an infinite environment requires new methodological tools. Traditional gathering techniques in graphs are count driven: agents make decisions based on counting steps. Since distances between agents may be unbounded, agents have to count unbounded numbers of steps. When agents are finite automata, counting unbounded numbers of steps is impossible, hence we must use different methods. In all our gathering algorithms, changes of the agents’ behavior are triggered not by counting steps but by events which are meetings between agents during which they interact. Hence our new technique is event driven. Designing the behavior of the agents based on meeting events, so as to guarantee gathering regardless of the adversary’s decisions is our main methodological contribution.
Keywords and phrases:
Gathering, deterministic finite automaton, mobile agent, team of agents, line, timeFunding:
Younan Gao: Partially supported by the Research Chair in Distributed Computing at the Université du Québec en Outaouais and MUR 2022YRB97K, PINC, Pangenome Informatics: from Theory to Applications.Copyright and License:
![[Uncaptioned image]](x1.png)
2012 ACM Subject Classification:
Theory of computation Distributed algorithmsEditors:
Silvia Bonomi, Letterio Galletta, Etienne Rivière, and Valerio SchiavoniSeries and Publisher:

1 Introduction
The background and the problem.
Several mobile agents, navigating in a network, have to meet at the same node. This basic task, known as gathering, has been thoroughly studied in the literature. It has many applications, both in everyday life and in computer science. Mobile agents can be people who have to meet in a city whose streets form a network. In computer science applications, agents can represent either software agents in computer networks, or mobile robots in networks formed by, e.g., corridors of a contaminated mine, where the access is dangerous for humans. The purpose of gathering may be to exchange data previously collected by software agents that accessed a distributed database, or to coordinate some future task of mobile robots, such as network decontamination, based on previously collected samples of the ground or of air. Since, due to cost reasons, mobile agents are often simple devices with limited memory, sensor capacity and computation power, it is natural to model them as deterministic finite automata that can interact only when they meet.
We consider the feasibility and time complexity of gathering mobile agents, modelled as automata, in one of the simplest networks that is the infinite line, i.e. the infinite graph all of whose nodes have degree 2. While the gathering problem in networks has a long research history, mobile agents in this context were usually modelled either as machines with unbounded memory or it was assumed that agents can “see” other agents at a distance. To the best of our knowledge, this classic problem has never been investigated before for agents modelled as deterministic finite automata navigating in an infinite environment and interacting with other agents only at meetings.111It could seem that the recent paper [17] is a counterexample to this rule. However, the focus of [17] is on computing functions by teams of automata, and the environment in which agents navigate is the rooted oriented half-line. In this graph, gathering is trivial: all agents go toward the root and stop.
The model.
The environment in which agents navigate is modelled as an infinite line, i.e., the infinite graph all of whose nodes have degree 2. Nodes of the line do not have labels, and ports at each node are labeled and . We consider two variations of this port-labeled graph: in the oriented line, ports corresponding to any edge at both extremities of it are different; in the unoriented line, port labeling at any node is arbitrary.
There are several agents navigating in a line. They are modelled as deterministic finite Mealy automata. Agents move in synchronous rounds. All agents start in the same round 0. In each round, an agent can choose one of the following actions: take the port , take the port 1, or stay idle. Agents have distinct labels which are integers from the set . Agents start in teams, each of which consists of agents, for some fixed integer , where . Agents in a team have the same starting node, called the base of the team. The integer , the size of the space of labels and the total number of teams are known in advance and can be used in the design of the agents. 222The discussion of the above assumptions is deferred to the full version of this paper. Throughout the paper, we assume that . If there is only one team, gathering is trivially achieved in the wake-up round. The adversary knows all the agents and decides the composition of teams and their bases. In the case of the unoriented line, the adversary also decides the port labeling at each node.
When entering a node, an agent sees the entry port number, and sees the set of states of all currently collocated agents. If in the current round the agent stays idle, it also sees this set of states. (This is how agents interact). This information, together with the size of the label space and the number of teams, forms the input of the agent in a given round. ( and form the fixed part of the input that never changes). Based on its state and this input, the agent transits to some state, and produces an output action belonging to the set , to be executed in the next round. Output action means taking port , output action means taking port , and output action means staying idle in the next round. The sequence of the above actions forms the trajectory of an agent. Each agent has a special state STOP, upon transition to which, it stays idle forever.
We now formalize the above intuitions. All agents are represented by the same deterministic finite Mealy automaton ). The agent with label has the set of states , where all sets are pairwise disjoint. Thus the label of an agent can be recognized from each of its states. denotes the union of sets of states of all the agents. The size of , i.e., the number of states of the automaton, is denoted by . Let be the set of all subsets of . The common input alphabet for all agents is the set . This corresponds to the intuition that an input is a triple whose first term is the fixed part of the input consisting of the pair of integers , whose second term is the move part of the input which is either the entry port number in the current round or 0 if the agent is idle in the current round (it is also 0 in round 0), and whose third term is the states part of the input which is the set of states of other currently collocated agents. This set may be empty, if the agent is currently alone. The common output alphabet corresponds to the output actions intuitively described above.
It remains to define the transition function and the output function . The transition function takes the current state of an agent and its current input, and produces the state to which this agent transits in the next round. The fact that is the set of states of agent is reflected by the following restriction: if , then , for any input , i.e., under any input, the transition function maps a state of a given agent to a state of the same agent. The output function takes the current state of an agent and its current input, and produces the output action to be executed in the next round.
According to the established custom in the literature on automata navigating in graphs, we present the behavior of our automata by designing procedures that need only remember a constant number of bits, and thus can be executed by deterministic finite automata, rather than formally describing the construction of a Mealy automaton by defining its output and state transition functions.
The aim is for all agents to gather at the same node and transit to state STOP. The first round in which all the agents are at the same node in state STOP is called the gathering round. Gathering is feasible, if this task can be accomplished for any decisions of the adversary, and its time is the worst-case (largest) gathering round, over all decisions of the adversary.
Our results.
We give a complete solution of the problem of feasibility and time complexity of gathering teams of agents on the infinite line. It turns out that both feasibility and complexity of gathering depend on the crucial parameter which is the size of teams. For the oriented line, gathering is impossible if , and it can be accomplished in time , for any , where is the distance between the bases of the most distant teams. The first fact means that, for and for arbitrary agents, the adversary can place them in the oriented line (at distinct nodes) in such a way that they will never gather. The second fact means that, for any and any , there exist agents, each assigned a distinct label drawn from , where , such that if the adversary composes them in arbitrary teams of size and selects the bases of the teams as arbitrary nodes of the oriented line with the most distant nodes at distance , then the agents will gather in time . This complexity is of course optimal.
For the unoriented line, the situation is different. For , gathering is also impossible which means that, for and for arbitrary agents, the adversary can choose a port labeling of the line, and can place the agents at distinct nodes in such a way that they will never gather. This directly follows from the above impossibility result on the oriented line, as the adversary can choose the port labeling as in the oriented line.
However, for , the optimal time of gathering in the unoriented line turns out to be . To show this, we prove two facts. First, we show that there exist agents, each assigned a distinct label drawn from , where , such that if the adversary chooses an arbitrary port labeling of the line, composes the agents in arbitrary teams of size and selects the bases of the teams as arbitrary nodes of the line with the most distant nodes at distance , then the agents will gather in time . Second, we prove that this complexity is optimal, even for two teams of agents, each of size 2. In fact, we show that the “difficult” port labeling of the line can be chosen the same for any agents: it is the homogeneous port labeling in which, for every edge , port numbers at both extremities of are equal. More precisely, we show that for any agents, the adversary can select two teams of agents of size 2 and choose bases of these teams as nodes at an arbitrarily large distance on the line with homogeneous port labeling, so that the gathering time will be at least , for some constant . This shows that the complexity is tight.
Finally, we show that, for any and any , there is an algorithm that gathers all agents partitioned in arbitrary teams of size , in time , which is clearly optimal.
Solving the gathering problem for agents that are finite automata navigating in an infinite environment requires new methodological tools. Traditional gathering techniques in graphs are count driven: agents make decisions based on counting steps. Since distances between agents may be unbounded, agents have to count unbounded numbers of steps. When agents are finite automata, counting unbounded numbers of steps is impossible333This is the reason for our impossibility result in case of teams of size 1., hence we must use different methods. In all our gathering algorithms, changes of the agents’ behavior are triggered not by counting steps but by events which are meetings between agents during which they interact. Hence our new technique is event driven. Designing the behavior of the agents based on meeting events, so as to guarantee gathering regardless of the adversary’s decisions is our main methodological contribution.
While we assume that agents operate in the infinite line, all our positive results remain true also for arbitrary bounded lines and for arbitrary rings.
Related work.
Gathering mobile agents in graphs, also called rendezvous if there are only two agents, is a well studied topic in the distributed computing literature.
In the majority of the papers on gathering, it is assumed that nodes do not have distinct identities, and agents cannot mark nodes: we follow these assumptions in the present paper. However, departures from this model exist: rendezvous was also considered in graphs whose nodes are labeled [8, 15], or when marking nodes by agents is allowed [14]. Randomized rendezvous was surveyed in [1] and deterministic rendezvous – in [18].
Most of the literature on rendezvous considered finite graphs and assumed the synchronous scenario, where agents move in rounds. In [19], the authors gave rendezvous algorithms with time polynomial in the size of the graph and the length of agents’ labels. Gathering many agents in the presence of Byzantine agents that can behave arbitrarily was studied in [6].
In the above cited papers, agents are modeled as Turing machines and their memory is unbounded. Other studies concern the minimum amount of memory that agents must have in order to accomplish rendezvous [9, 13]. In this case, agents are modeled as state machines and the number of states is a function of the size of graphs in which they operate.
Several authors studied synchronous rendezvous in infinite graphs. In all cases, agents had distinct identities and were modeled as Turing machines. In [8], the authors considered rendezvous in infinite trees and grids, under the assumption that the agents know their location in the graph (then the initial location can serve as a label). In [3], rendezvous in infinite trees was investigated. Rendezvous in arbitrary graphs, finite or infinite, was studied in [4, 16]. Rendezvous in the oriented grid was investigated, e.g., in [2, 4, 5, 8].
In several papers, asynchronous gathering was studied in the plane [7, 12] and in graphs [5, 2, 11]. In the plane, agents are modeled as moving points, and it is usually assumed that they can see the positions of other agents. In graphs, an agent chooses the edge to traverse, but the adversary controls the speed of the agent. Then rendezvous at a node cannot be guaranteed even in the two-node graph, hence the agents are permitted to meet inside an edge. For asynchronous rendezvous, the optimization criterion is the cost, i.e., the total number of edge traversals. In [2], the authors designed almost optimal algorithms for asynchronous rendezvous in infinite multidimensional grids, assuming that an agent knows its position in the grid. In [5, 11] this assumption was replaced by a weaker assumption that agents have distinct identities. In [5], a polynomial-cost algorithm was designed for the infinite oriented two-dimensional grid, and in [11] – for arbitrary finite graphs.
2 Preliminaries
In this section, we introduce the notions, notations and basic facts used throughout the paper. All proofs omitted in this section are deferred to the full version of this paper.
For any port labeling of a line, we will use two notions describing the two directions of the line. For any node, we define the plus direction and the minus direction as the directions corresponding to port and port , respectively. We also define the left and right directions of any line. For the oriented line, the left (resp. right) direction is the minus (resp. plus) direction. For any other port labeling, these directions are chosen arbitrarily. Hence, in the oriented line, agents can identify directions left and right. For an arbitrary port labeling, agents cannot identify them, so we will use these expressions only in comments and in the analysis. For any two nodes and in a line, we define their distance as the number of edges between them.
Agents are identified with their labels. The node at which a team of agents are woken up is referred to as the base of the agents in the team. For any port labeling of a line, and for any base of a single agent, navigating in the line, we define the trajectory of this agent as the infinite sequence of terms with the following meaning. The th term of the trajectory is 0 if the agent stays put in the th round, it is if the agent takes port in the th round, and it is 1 if the agent takes port 1 in the th round.
We say that a trajectory of an agent has a period of length if there exists an integer , such that, for any fixed , the th term of the trajectory is the same for all . The sequence of terms corresponding to indices is called a period of this trajectory, and the sequence of terms corresponding to indices is called a prefix corresponding to this period. A trajectory that has a period is called periodic.
Apart from the port labeling that yields the oriented line (port numbers at both extremities of each edge are different), we consider another important port labeling, called homogeneous, in which, for every edge , port numbers at both extremities of are equal. A line with this port labeling will be called homogeneous.
Proposition 1.
The trajectory of any agent navigating either in the oriented or in the homogeneous line and starting at any node of it is periodic.
The notion of a period permits us to define three important notions concerning the trajectory of an agent navigating in the oriented or in the homogeneous line: boundedness, the progress direction and the speed. We first define these notions for an agent in the oriented line. Consider any starting node (base) of the agent, and consider a period of length of its trajectory . Let and be nodes where the agent is situated at the beginning of two consecutive periods. There are three cases: is left of , , and is right of . For the oriented line, this is independent of the base of the agent. It is easy to see that:
-
if is left (resp. right) of then the agent visits all nodes of the line left (resp. right) of the base and only a finite number (resp. ) of nodes right (resp. left) of the base ( and are independent of the base); in this case we say that the trajectory of the agent is left-progressing (resp. right-progressing);
-
if then the agent visits only a finite number of nodes: at most nodes on each side of the base ( is independent of the base); in this case we say that the trajectory of the agent is bounded;
If the trajectory of the agent is left- or right-progressing, its speed is defined as . The definition of the speed does not depend on the choice of the period of the trajectory.
In the case of the homogeneous line, the situation is slightly different for two reasons. First, the progress direction of a trajectory depends on the base. Hence we will use notions minus progressing and plus progressing, where the directions are defined with respect to the base. Second (unlike in the oriented line), it is possible that the node at the beginning of a period is different from the node at the beginning of the preceding period but after two consecutive periods these nodes are the same. This happens, e.g., when the period is . Hence, in order to define progress direction and boundedness properly, we consider double periods: a period is double, if it is the concatenation , for some period . For double periods, the above issue disappears.
Consider any base of the agent, and consider a double period of length of its trajectory . Let and be nodes where the agent is situated at the beginning of two consecutive periods. We use the plus and minus direction with respect to . There are three cases: is in minus direction from , , and is in plus direction from . We have:
-
if is in minus (resp. plus) direction from then the agent visits all nodes of the line in minus (resp. plus) direction from and only a finite number (resp. ) of nodes in plus (resp. minus) direction from ( and are independent of the base); in this case we say that the trajectory of the agent is minus-progressing (resp. plus-progressing);
-
if then the agent visits only a finite number of nodes: at most nodes on each side of the base ( is independent of the base); in this case we say that the trajectory of the agent is bounded;
If the trajectory of the agent is minus- or plus-progressing, its speed is defined as , for any double period. Similarly as before, the definition of the speed does not depend on the choice of the double period of the trajectory. Notice that in the case of the homogeneous line, for a fixed base of an agent, we can still use the expression “left-” or “right-progressing” with respect to its trajectory, although, unlike for the oriented line, these notions also depend on the base and not only on the trajectory.
The following proposition bounds the length of a prefix and of a period of trajectories.
Proposition 2.
For any periodic trajectory , denote by the length of the shortest period of and by the length of the prefix preceding the first period of length . Then .
We use the following fact holding both for the oriented and the homogeneous line. Consider two agents and with bases and , respectively. We say that agent follows agent , if either the trajectories of both of them are left-progressing and is left of , or the trajectories of both of them are right-progressing and is right of . The following proposition says intuitively that, if the initial distance between the agents is sufficiently large, then:
-
(i)
if the follower is not faster than the followed agent, then agents can never meet, and
-
(ii)
if the difference between the speeds of the agents is small, then they cannot meet soon.
Proposition 3.
Consider two agents, and , with bases and , respectively, either in the oriented line or in the homogeneous line, such that and agent follows agent . Let , where and denote the speeds of the trajectories of and , respectively.
-
i)
If , then agents and can never meet;
-
ii)
If , then agents and cannot meet before round .
3 The Impossibility Result
In this section we show that, if the team size is , then gathering is impossible for some port labeling of the line. This port labeling is that of the oriented line. The proof of the following theorem is deferred to the full version of this paper.
Theorem 4.
Consider an arbitrary set of agents in teams of size , i.e., . The adversary can place these agents at distinct nodes of the oriented line in such a way that no pair of agents will ever meet.
4 The Oriented Line
In this section, we consider gathering of teams of agents in the oriented line. In view of Theorem 4, if the size of each team is one, then the adversary can prevent gathering. So, we assume that , throughout this section. Due to space limitation, we only present the high-level idea of the algorithm, while its detailed description and the proof of its correctness and complexity are deferred to the full version of this paper.
We now describe Algorithm Oriented that accomplishes gathering of arbitrary teams of agents in the oriented line, in optimal time , where is the distance between the bases of the most distant teams.
Modes.
In each round of the algorithm execution, each agent is in some mode, encoded in the state of the agent. In each mode, an agent performs some action. All modes and their corresponding actions, used in Algorithm Oriented, are listed in Table 1.
Mode | Action |
---|---|
Move one step right, stay put for one round, and repeat | |
Move one step right in each round | |
Move one step left in each round | |
Stay put |
The high-level idea of the algorithm.
After waking up, the agent with the smallest label in each team assigns itself mode which means that it moves right with speed one-half, and the other agents in the team assign themselves mode and stay put at their base. An agent in mode (except the agent from the rightmost team) will meet agents in mode . Each time such a meeting happens, agent counts the total number of agents in mode it has seen so far. Notice that among all the agents in mode , only the agent from the leftmost team will meet agents in mode (except agents from its own team). After meeting agents in mode , agent switches to mode which means that it moves right with speed 1. It is the only agent that ever switches to mode . Speed 1 allows it to meet agents in mode that it follows. Each time agent meets an agent in mode , agent counts the total number of agents in mode it has seen so far, and the agent in mode switches to mode . After meeting agents in mode , agent switches to mode . Let be the agent in mode that agent met. At this meeting, agent also switches to mode .
So, both agents and move together left with speed 1. At this time, all the other agents are in mode , left of agents and . Then, each time a meeting between agents in mode and agents in mode happens, all the agents in mode switch to mode and move together with the other agents in mode . In the end, all agents gather at the base of the leftmost team. They know that this happened, by counting the number of agents at , and transit to state STOP. The following theorem states the correctness and complexity of Algorithm Oriented. Its proof is deferred to the full version of this paper.
Theorem 5.
Algorithm Oriented gathers teams of agents each, in the oriented line in rounds, where denotes the distance between the bases of the most distant teams.
5 The Unoriented Line
In this section, we consider gathering in the unoriented line, in which the port labeling at each node is arbitrary. We will use the expressions “left” and “right”, to denote the two directions of the line but we need to keep in mind that agents cannot identify these directions, so we will use these expressions only in comments and in the analysis.
It follows from Section 3 that, if the team size is , then gathering is impossible for some port labeling, namely that of the oriented line. This section is devoted to showing that, in the unoriented line, the optimal gathering time is , for , and it is , for , where is the distance between the bases of the most distant teams. We first consider the case .
5.1 Teams of size 2
Results of this section are by far the most technically difficult. The section is organized as follows. First we prove that, regardless of the finite deterministic automaton used, and even for two teams of size 2, the adversary can choose a particular port labeling of the line, namely the homogeneous port labeling, and it can choose the bases at an arbitrarily large distance and a composition of teams in such a way that the time of gathering is at least , for some positive constant . Then we show, for any number of teams of size 2, an algorithm that always guarantees gathering in time . In view of the above lower bound, this complexity is optimal. Proofs omitted in this section are deferred to the full version of this paper.
5.1.1 The lower bound
Consider the homogeneous line. Let . We will consider the following teams of size 2: , , … , . For each of those teams , there are fixed trajectories and corresponding to agents and , respectively, yielded by the finite deterministic automaton used. Each of the above teams is called one-way if either both corresponding trajectories are plus-progressing, or both are minus-progressing, or at least one of them is bounded.
Lemma 6.
If there exist two one-way teams and , for odd , then there exist arbitrarily large integers such that the adversary can place these teams at two bases at distance , so that gathering will never happen.
In view of Lemma 6, we may assume that there is at most one one-way team. Hence there exist teams , for odd that are not one-way. Call these teams canonical. By definition, for every canonical team, one of the corresponding trajectories is plus-progressing and the other is minus-progressing. Call the plus-progressing (resp. minus-progressing) trajectory the plus-trajectory (resp. the minus-trajectory) of the team. Agents corresponding to these trajectories are called the plus-agent (resp. minus-agent) of the team.
Consider two agents and with bases and , respectively, such that is left of . We say that the agents are diverging, if the trajectory of is left-progressing and the trajectory of is right-progressing.
Lemma 7.
If the distance between the bases and of diverging agents is larger than then these agents can never meet.
We will use the following lemma that is a direct consequence of [10, Theorem 3.1]. 444[10, Theorem 3.1] holds even in a ring and even if agents are Turing machines.
Lemma 8.
Consider a set of agents, each of which is assigned a trajectory. There exist two agents in this set, such that if they start at two nodes of a line at distance and follow their trajectories then the first meeting between them occurs after at least rounds.
The main result of this subsection is the following theorem.
Theorem 9.
For any finite deterministic automaton formalizing the agents, there exists a positive constant such that, for arbitrarily large , the adversary can choose two canonical teams and their bases at distance on the homogeneous line, so that gathering takes time at least .
Proof.
Let . We consider the partition of the interval into subintervals , where , for . For any , denote . Hence, form a partition of the square into squares. We assign each canonical team to one of these squares as follows: a canonical team is assigned to square , if the speed of the minus-trajectory of the team is in and the speed of the plus-trajectory of the team is in . Since there are squares and canonical teams, there is at least one square to which at least canonical teams are assigned. Let denote any such square (there can be many of them).
We now describe the decisions of the adversary. Let be any odd integer larger than . There are two cases.
Case 1. .
Consider the plus-agents of the teams assigned to . There are at least of them. By Lemma 8, there exist two of them, and , such that if they are placed at any two nodes at distance and follow their trajectories, then they cannot meet before rounds. Now the adversary makes its first choice: it chooses canonical teams to which and belong. These are teams and , where denote the minus agents in each team. (Note that we do not know which of the agents has an even label and which has an odd label in each team). It remains to choose the bases. As , the adversary chooses any node in the line, such that port is in the right direction, and chooses as the (unique) node at distance right of . Finally the adversary chooses as the base of team and chooses as the base of team .
Case 2. .
Now the decisions of the adversary are symmetric with respect to Case 1. This time, consider the minus-agents of the teams assigned to . There are at least of them. By Lemma 8, there exist two of them, and , such that if they are placed at any two nodes at distance and follow their trajectories, then they cannot meet before rounds. The adversary chooses canonical teams to which and belong. These are teams and , where denote the plus agents in each team. It remains to choose the bases. As the adversary chooses any node in the line such that port is in the right direction, and chooses as the (unique) node at distance right of . Finally the adversary chooses as the base of team and chooses as the base of team (here nothing changes).
Claim 10.
There is a positive constant such that, for the above choices of the adversary, the first meeting between agents of different teams occurs after at least rounds.
Proof.
In order to prove the claim, we consider Case 1. The argument in Case 2 is similar.
The choice of teams and guarantees that the meeting between agents and requires at least rounds, as .
Agent , based at , is a minus-agent and its trajectory is left-progressing; agent , based at , is a minus-agent and its trajectory is right-progressing. Hence, agents and are diverging. As , agents and can never meet, in view of Lemma 7.
Observe that agent follows agent . First, suppose that . The speed of the trajectory of is larger than the speed of the trajectory of . As , agent can never meet agent , in view of Proposition 3 (i). Next, suppose that . Then , because and are both in the interval . If , then agent can never meet agent , in view of Proposition 3 (i). Otherwise, as , Proposition 3 (ii) implies that the meeting between and cannot be achieved before round . Symmetrically, agent follows agent . Using similar arguments, agents and either never meet or meet after time . It follows that for a sufficiently small constant , any meeting between agents and or and cannot happen before round . Hence, for a sufficiently small constant , the first meeting between agents of different teams occurs after at least rounds.
Claim 10 concludes the proof of the Theorem.
5.1.2 The algorithm
We now describe Algorithm Small Teams Unoriented that guarantees gathering teams of size 2 in an unoriented line, in time . More precisely, the algorithm accomplishes gathering of arbitrary teams of size 2 in time , where is the distance between the bases of the most distant teams, and the port labeling of the line is arbitrary.
In our algorithm, we will use the following procedure Dance . Its parameter is a finite binary sequence, and its parameter is one of the possible ports or . Intuitively, procedure Dance is an infinite procedure divided into phases of rounds each, where is the length of the binary sequence . In each phase, the agent first chooses the edge on which the dance will be executed, and then performs the dance itself on edge . In the first phase, corresponds to port , and in each subsequent phase, is the edge incident to the current node, which is different from the edge on which the dance in the previous phase was executed. The agent processes bits of the sequence in consecutive rounds as follows: if the bit is 1, then traverse edge ; otherwise, stay idle. The pseudo-code of procedure Dance is deferred to the full version of this paper.
While procedure Dance is formulated as an infinite procedure, it will be interrupted in some round of the execution of the algorithm, and a new procedure Dance with different parameters will be started.
Label transformation.
Recall that labels of all agents are different integers from the set . Let denote . Consider a label . We represent it by the unique binary sequence which is the binary representation of , with a string of zeroes possibly added as a prefix, to get length .
Let . We now define the transformed label obtained from . This is the binary sequence of length defined as follows: In , replace each bit 1 by the string 11, replace each bit 0 by the string 00, add the string 10 as a prefix and the string 00 as a suffix. Due to the added prefix string 10, always contains an odd number of bits . For example, if is and is , then is the binary sequence , and is the binary sequence .
Modes.
In each round of the algorithm execution, each agent is in some mode, encoded in the state of the agent. In each mode, an agent performs some action. Four of these modes instruct the agent to execute procedure Dance with various parameters, and three other modes instruct it to stay put. Modes are changed at meetings of the agents, called events. In Table 2, we list seven modes in which an agent can be.
Mode | Action |
---|---|
Dance | |
Dance | |
Dance | |
Dance | |
Stay put | |
Stay put | |
Stay put |
We now explain the roles that are played by the seven modes. An agent in any of the modes , , or stays at the current node until a new event happens at this node. Mode is used only in the first rounds of the algorithm, while modes and are used in the remaining rounds. In particular, mode is only assigned to the leftmost and rightmost agents, once these agents identify themselves as such.
Modes and will be called slow modes, and modes and will be called fast modes. For simplicity, we call an agent in slow (resp. fast) mode a slow (resp. fast) agent. In view of procedure Dance, a slow or fast agent dances along the same edge in each phase. We call the edge endpoint, at which a phase starts, the dancing source of the agent, in this phase. Let denote the label of an agent, and let and . As shown in Table 2, a slow or a fast agent executes procedure Dance with binary sequences and , respectively. Observe that the sequences and used in modes slow and fast have an odd number of bits . Hence, after each phase, the dancing source of a slow or fast agent is changed to be the other endpoint of this edge. During an execution of procedure Dance, the way that the dancing source changes looks like an object moving on the unoriented line exactly one step in the same direction in each phase. We call the direction, in which the dancing source of an agent executing Dance moves, the progress direction of the agent. Although the port numbers at each node are assigned arbitrarily by the adversary and a slow or fast agent cannot tell which direction is left or right, it is always aware of its progress direction. Indeed, consider an agent that arrives at node in some round of the execution of Dance. The agent knows if, in this phase, is the dancing source or not. If is the dancing source of , then the port via which arrives at , indicates its progress direction; otherwise, its progress direction is indicated by the other port at . This is true, because sequences and start with bit , end with bit , and contain an odd number of bits .
An agent in mode or mode (resp. mode or mode ) leaves the current node via port (resp. ), in the first round of the execution of procedure Dance. This is because the second parameter in the procedure is (resp. ) and sequences and both start with bit . We will prove that two slow agents, moving towards each other while executing procedure Dance, will meet in a phase, when their dancing sources are at a distance either or .
Meetings of a fast and a slow agent happen for a different reason. When a fast agent meets a slow agent progressing in the same direction, we will say that the fast agent catches the slow agent. In view of definitions of sequences and , each phase of procedure Dance in a slow mode lasts rounds, while each phase in a fast mode lasts only four rounds. This means that the dancing source of a slow agent changes every rounds, while the dancing source of a fast agent changes every four rounds. Observe that any -bit sub-segment of is different from . Due to this observation and the difference of the dancing source changing frequency for slow and fast agents, we will show that a fast agent following a slow agent progressing in the same direction always catches it.
The high-level idea of the algorithm.
In the wake-up round, agents are at their bases in teams of size 2. Since they can see each other’s labels, they can compare them and assign modes as follows: the agent with smaller label assigns itself mode and the agent with larger label assigns itself mode . Conceptually, we number agents as follows (see Fig. 1).
Consider the -th team from the left, where . Agent is the agent from the -th team that first moves left, and agent is the agent from the -th team that first moves right. Agent will be called the left agent of the -th team, and agent will be called the right agent of the -th team. Notice that an agent does not know in which team it is, and it does not know if it is the left or the right agent in a team, due to the adversarial port labeling of the undirected line. Let’s call agents and neighbors, for any .
Our algorithm guarantees that in some round of its execution, all neighbors will meet in pairs. After such a meeting, both agents switch to mode , however this change might not happen immediately at the meeting. If the bases of the -th team and the -th team are at a distance exactly one, then both neighbors from these teams switch to mode at their meeting and then switch to mode in round . If the distance between their bases is exactly two, then both neighbors maintain their slow modes until round and switch to mode in this round. (Note that, in both above cases, the earliest round when both neighbors meet could be earlier than round ).
Otherwise, when the distance between bases is more than two, then both neighbors switch to mode immediately after the meeting. After changing to a fast mode, an agent swings (possibly switching from mode to or vice versa) between agent and agent both of which are still in slow modes. Therefore, it is crucial to identify these agents. To this end, each agent in a slow mode keeps a bag to which it adds labels of fast agents that have caught it. We will show that only bags of and can have size and that, in some round, they will have this size. This is how the pair of agents and is identified. At this time these agents switch mode to .
However, an agent in mode does not know whether it is or . We will distinguish from indirectly, using fast agents. The fast agents swing from one agent in mode to the other, gather their labels, compare them, go to the agent with the smaller label and change state to . Without loss of generality, suppose that the label of agent is smaller than that of . As a result, all fast agents meet and stay with it in mode ; in other words, agents gather at the same node in some round. When this happens, each of these agents switches to a fast mode and progresses in the direction opposite to their last move. Hence they will meet agent which stays put in mode . In the end, all agents gather at the same node where stays, and transit to state STOP. The detailed description of Algorithm Small Teams Unoriented is deferred to the full version of this paper.
The complexity of the algorithm is stated as Theorem 11.
Theorem 11.
Suppose that agents have distinct labels drawn from the set , that teams are of size , and that the distance between the bases of the most distant teams is . Algorithm Small Teams Unoriented gathers all agents at the same node of an unoriented line in time .
Due to space limitation, we present a sketch proof for Theorem 11. Without loss of generality, assume that the label of is smaller than the label of . First, we prove that agent meets its neighbor , for each . After the meeting, and become fast agents and swing between and . Then, we show that only and will change (possibly in different rounds) to mode . As agents swing between and , and is in mode , agents will meet and stay with it in mode . Next, we prove that by the earliest round when all fast agents gather at the same node where stays, agent has already changed to mode . As a result, all agents, apart from , become fast agents, progress towards and eventually meet , while stays put in mode . Then gathering is achieved and all agents transit to state STOP. To establish the complexity of the algorithm, let denote the earliest round in which agent becomes a fast agent after meeting its neighbor, for all . Let denote the earliest round in which both and switched to mode . Let denote the earliest round in which all agents, apart from , have gathered at the same node. Let denote the earliest round in which all agents gather at the same node. Our goal is to prove that all rounds exist; furthermore, we will show that .
5.2 Teams of size larger than 2
It remains to consider the gathering problem in any unoriented line for teams of size larger than . Using more than two agents in each team, we design Algorithm Large Teams Unoriented, faster than that for teams of size 2: our gathering algorithm for larger teams works in optimal rounds. In this section, we only present the high-level idea of the algorithm, while the omitted details are deferred to the full version of this paper.
Algorithm Large Teams Unoriented uses procedure Proceed . The procedure has two parameters: is a port number drawn from , and is a Boolean value. Like procedure Dance, Proceed is an infinite procedure, divided into phases. Assume that an agent starts performing Proceed at node . If is false, then each phase has one round. In the first phase, the agent moves to the neighbor of corresponding to port at . Let denote the node that the agent reached in the -th phase, for . In the -th phase, the agent moves to the neighbor of such that is . Intuitively, the agent moves away from with speed one in the direction of port at node .
If is true, each phase consists of two consecutive rounds. In the first phase, the agent moves to the neighbor of corresponding to port at , and stays at for one round. For any phase , let denote the node that the agent reached in the -th phase. In the -th phase, the agent moves to the neighbor of such that is and stays at for one round. Intuitively, the agent moves away from with speed one-half in the direction of port at . The pseudo-code of the procedure is deferred to the full version of this paper.
Modes.
Similarly to the previous two algorithms, during the execution of Algorithm Large Teams Unoriented, each agent is in one of five modes, encoded in the states of the automaton. Each mode corresponds to a different action, as shown in Table 3. Hence, there are five different actions an agent can choose to take. Four of them are to call procedure Proceed (with different parameters), and the fifth is to stay put, waiting for future events.
Mode | Action |
---|---|
Proceed | |
Proceed | |
Proceed | |
Proceed | |
Stay put |
We call agents in modes and fast agents, agents in modes and slow agents, and agents in mode sentinel agents.
The high-level idea of the algorithm.
After wake-up, in each team, the agent with the smallest label assigns itself mode , the agent with the second smallest label assigns itself mode , and all the other agents assign themselves mode . Notice that, in each team, the agents with the two smallest labels proceed in different directions, and the agent with the largest label assigns itself mode .
Slow agents move along the line with speed one-half. For an agent, we call any base other than its own a foreign base. Each time a slow agent meets agents in mode , it reaches a foreign base. A slow agent can tell how many foreign bases it has reached, by counting the total number of sentinel agents it has seen so far. During the execution of the algorithm, only two of the slow agents can reach foreign bases. These two slow agents are from the two most distant teams. Let denote the -th foreign base that a slow agent reaches. By the round when agent reaches , it has met agents in mode . Agent switches to mode . The largest label among agents from the team of is compared to the largest label among agents based at . (These labels are coded in the states of agents currently collocated at ). If , then the agent with label becomes a fast agent. This agent, called , has the largest label among all agents in the two most distant teams. is the first agent to become fast. When this happens, all the agents are distributed on the line as follows: there are sentinel agents at node , along with the fast agent ; there are only slow agents, on one side of , progressing away from ; there are sentinel agents and slow agents on the other side of , and these slow agents are progressing away from as well. Agent progresses in the direction (with respect to ) where only slow agents are located.
As a fast agent, agent moves with speed one. The fast speed allows agent to meet all the slow agents that it follows. Each time agent meets a slow agent, it increments the total number of slow agents it has seen since becoming fast, and the slow agent switches to the same mode as that of and moves together with agent from now on. Let denote the node where agent meets the -th slow agent. In the round when agent reaches node , there are agents at this node, including agent itself. In this round, all these agents become fast agents and move in the direction that agent comes from. At this point, all the agents are distributed on the line as follows: there are fast agent at node ; there are no agents at all on one side of ; there are agents in mode and slow agents on the other side of , and these slow agents move away from . Hence, all fast agents follow these slow agents. Since then, each time a meeting happens at some node , all the non-fast agents at node (i.e., slow agents and sentinel agents) switch to the mode shared by all fast agents at node . In this way, all the agents at node move together, after the meeting. When a meeting happens at a node where agents gather, all the agents transit to state STOP. These agents know when gathering occurs by counting the number of agents collocated at each meeting. The detailed description of the algorithm is deferred to the full version of this paper. Theorem 12 states the correctness and complexity of the algorithm.
Theorem 12.
Algorithm Large Teams Unoriented gathers teams of agents each, on an unoriented line in rounds, where denotes the maximum distance between bases.
6 Conclusion
We gave a complete solution of the feasibility and complexity problem of gathering teams of agents modeled as deterministic finite automata on oriented and unoriented lines, showing differences that arise from the orientation feature. To the best of our knowledge, this is the first time gathering of deterministic finite automata that cannot communicate remotely is considered in an infinite environment. It is impossible to design a finite automaton that explores infinite lines, and hence we had to invent new gathering techniques. A natural generalization of our results would be to study gathering of teams of automata in arbitrary (connected) infinite graphs. In this paper we assumed that all teams of agents are of equal size. Generalizing our results to teams of possibly different sizes is another open problem.
References
- [1] Steve Alpern and Shmuel Gal. The Theory of Search Games and Rendezvous, volume 55 of International series in operations research and management science. Springer New York, NY, 2003. doi:10.1007/b100809.
- [2] Evangelos Bampas, Jurek Czyzowicz, Leszek Gąsieniec, David Ilcinkas, and Arnaud Labourel. Almost optimal asynchronous rendezvous in infinite multidimensional grids. In Proc. 24th International Symposium on Distributed Computing (DISC 2010), volume 6343, pages 297–311. Springer Berlin Heidelberg, 2010. doi:10.1007/978-3-642-15763-9_28.
- [3] Subhash Bhagat and Andrzej Pelc. Deterministic rendezvous in infinite trees. CoRR, abs/2203.05160, 2022. doi:10.48550/arXiv.2203.05160.
- [4] Subhash Bhagat and Andrzej Pelc. How to meet at a node of any connected graph. In Proc. 36th International Symposium on Distributed Computing (DISC 2022), volume 246 of LIPIcs, pages 11:1–11:16. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2022. doi:10.4230/LIPIcs.DISC.2022.11.
- [5] Sébastien Bouchard, Marjorie Bournat, Yoann Dieudonné, Swan Dubois, and Franck Petit. Asynchronous approach in the plane: a deterministic polynomial algorithm. Distributed Comput., 32(4):317–337, 2019. doi:10.1007/S00446-018-0338-2.
- [6] Sébastien Bouchard, Yoann Dieudonné, and Anissa Lamani. Byzantine gathering in polynomial time. Distributed Comput., 35(3):235–263, 2022. doi:10.1007/S00446-022-00419-9.
- [7] Mark Cieliebak, Paola Flocchini, Giuseppe Prencipe, and Nicola Santoro. Distributed computing by mobile robots: Gathering. SIAM J. Comput., 41(4):829–879, 2012. doi:10.1137/100796534.
- [8] Andrew Collins, Jurek Czyzowicz, Leszek Gasieniec, Adrian Kosowski, and Russell A. Martin. Synchronous rendezvous for location-aware agents. In Proc. 25th International Symposium on Distributed Computing (DISC 2011), volume 6950 of Lecture Notes in Computer Science, pages 447–459. Springer, 2011. doi:10.1007/978-3-642-24100-0_42.
- [9] Jurek Czyzowicz, Adrian Kosowski, and Andrzej Pelc. How to meet when you forget: log-space rendezvous in arbitrary graphs. Distributed Comput., 25(2):165–178, 2012. doi:10.1007/S00446-011-0141-9.
- [10] Anders Dessmark, Pierre Fraigniaud, Dariusz R. Kowalski, and Andrzej Pelc. Deterministic rendezvous in graphs. Algorithmica, 46(1):69–96, 2006. doi:10.1007/S00453-006-0074-2.
- [11] Yoann Dieudonné, Andrzej Pelc, and Vincent Villain. How to meet asynchronously at polynomial cost. SIAM J. Comput., 44(3):844–867, 2015. doi:10.1137/130931990.
- [12] Paola Flocchini, Giuseppe Prencipe, Nicola Santoro, and Peter Widmayer. Gathering of asynchronous robots with limited visibility. Theor. Comput. Sci., 337(1-3):147–168, 2005. doi:10.1016/J.TCS.2005.01.001.
- [13] Pierre Fraigniaud and Andrzej Pelc. Delays induce an exponential memory gap for rendezvous in trees. ACM Trans. Algorithms, 9(2):17:1–17:24, 2013. doi:10.1145/2438645.2438649.
- [14] Evangelos Kranakis, Nicola Santoro, Cindy Sawchuk, and Danny Krizanc. Mobile agent rendezvous in a ring. In Proc. 23rd International Conference on Distributed Computing Systems (ICDCS 2003), Lecture Notes in Computer Science, pages 592–599. IEEE Computer Society, 2003. doi:10.1109/ICDCS.2003.1203510.
- [15] Avery Miller and Andrzej Pelc. Fast deterministic rendezvous in labeled lines. In Proc. 37th International Symposium on Distributed Computing (DISC 2023), volume 281 of LIPIcs, pages 29:1–29:22. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2022. doi:10.4230/LIPICS.DISC.2023.29.
- [16] Debasish Pattanayak and Andrzej Pelc. Deterministic treasure hunt and rendezvous in arbitrary connected graphs. CoRR, abs/2310.01136, 2023. doi:10.48550/arXiv.2310.01136.
- [17] Debasish Pattanayak and Andrzej Pelc. Computing functions by teams of deterministic finite automata. arXiv preprint, 2023. doi:10.48550/arXiv.2310.01151.
- [18] Andrzej Pelc. Deterministic rendezvous algorithms. In Paola Flocchini, Giuseppe Prencipe, and Nicola Santoro, editors, Distributed Computing by Mobile Entities, Current Research in Moving and Computing, volume 11340 of Lecture Notes in Computer Science, pages 423–454. Springer, 2019. doi:10.1007/978-3-030-11072-7_17.
- [19] Amnon Ta-Shma and Uri Zwick. How to meet asynchronously at polynomial cost. ACM Trans. Algorithms, 10(3):12:1–12:15, 2014. doi:10.1145/2601068.