8
Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks Fukuhito Ooshita, Member, IEEE, Shinji Kawai, Hirotsugu Kakugawa, Member, IEEE, and Toshimitsu Masuzawa, Member, IEEE Abstract—We consider the gathering problem of multiple (mobile) agents in anonymous unidirectional ring networks under the constraint that each agent knows neither the number of nodes nor the number of agents. For this problem, we fully characterize the relation between probabilistic solvability and termination detection. First, we prove for any (small) constant p ð0 G p 1Þ that no randomized algorithm exists that solves, with probability p, the gathering problem with (termination) detection. For this reason, we consider the relaxed gathering problem, called the gathering problem without detection, which does not require termination detection. We propose a randomized algorithm that solves, with any given constant probability p ð0 G p G 1Þ, the gathering problem without detection. Finally, we prove that no randomized algorithm exists that solves, with probability 1, the gathering problem without detection. Index Terms—Mobile agents, gathering problem, randomized algorithm, ring networks Ç 1 INTRODUCTION 1.1 Background and Motivation A distributed system consists of multiple autonomous computers (nodes) that can communicate with each other. As a design paradigm for distributed systems, mobile agents have received much attention [1], [2], [3]. A (mobile) agent is an autonomous piece of software that moves in the network carrying its state information. There are many reasons for using agents [3]. For example, if remote hosts store a large amount of data for processing, agents can reduce the network traffic by moving to the remote hosts and processing the data locally. A distributed system with mobile agents is called a mobile agent system. In mobile agent systems, the gathering problem is well known as one of the fundamental problems [1], [4], [5]. In the gathering (rendezvous) problem, multiple agents dispersed across the network are required to meet at a single node (see Fig. 1), for example, to share information among all agents or to synchronize the behavior of the agents. In the gathering problem, agents initially have no knowledge of the network topology or other agents. This requires that the agents move around the network and determine the gathering node based on the collected information. The gathering problem can easily be solved if each node in a network has a unique identifier or ID; each agent then explores the network and terminates at the node with the smallest ID. However, such a unique ID may not be available to the agents in some cases; for example, making the node ID known to agents may be prohibited for security reasons. Hence, it is important to design algo- rithms that work in anonymous networks, i.e., networks in which nodes do not have unique IDs. 1.2 Related Works In anonymous networks, agents using the same determin- istic algorithm cannot solve the gathering problem because of the impossibility of breaking symmetry. For this reason, many researchers have considered the gathering problem with some additional assumptions, such as that agents can leave marks on nodes [6], [7], [8], can use randomness [9], [10], [11], [12], know the upper bound on the size of the network [13], and have distinct IDs [14], or that the edge labeling [8], [15] or network topology [16], [17], [18], [19], [20] is restricted. Dieudonne ´ and Pelc [13] considered deterministic algorithms for gathering multiple agents in arbitrary synchronous networks. They characterized solv- able initial configurations (i.e., graphs and locations of agents), from which there exists an algorithm that solves the gathering problem. In the case that agents know the upper bound on the size of the network, they proposed an algorithm that solves the gathering problem with (termina- tion) detection from any solvable initial configuration. In the case that no upper bound is known to the agents, they also proposed an algorithm that solves the gathering problem without detection from any solvable initial config- uration. They relaxed the problem to a gathering problem without detection, in which all agents eventually gather and stop at the same node but without detecting the completion of gathering, and proposed an algorithm for the relaxed problem. In contrast, in this paper, we focus on randomized algorithms that solve, with some probability, the gathering problem from any initial configuration in asynchronous rings. For asynchronous networks, various researchers have proposed deterministic algorithms for gathering two agents . The authors are with the Graduate School of Information Science and Technology, Osaka University, Suita, Osaka 565-0871, Japan. Email: {f-oosita, s-kawai, kakugawa, masuzawa}@ist.osaka-u.ac.jp. Manuscript received 15 Jan. 2013; revised 16 Aug. 2013; accepted 30 Sept. 2013. Date of publication 9 Oct. 2013; date of current version 21 Mar. 2014. Recommended for acceptance by A. Kshemkalyani. For information on obtaining reprints of this article, please send e-mail to: [email protected], and reference the Digital Object Identifier below. Digital Object Identifier no. 10.1109/TPDS.2013.259 1045-9219 Ó 2013 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission. See http://www.ieee.org/publications_standards/publications/rights/index.html for more information. IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 25, NO. 5, MAY 2014 1289

Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

Embed Size (px)

Citation preview

Page 1: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

Randomized Gathering of Mobile Agents inAnonymous Unidirectional Ring NetworksFukuhito Ooshita, Member, IEEE, Shinji Kawai, Hirotsugu Kakugawa, Member, IEEE, and

Toshimitsu Masuzawa, Member, IEEE

Abstract—We consider the gathering problem of multiple (mobile) agents in anonymous unidirectional ring networks under theconstraint that each agent knows neither the number of nodes nor the number of agents. For this problem, we fully characterize therelation between probabilistic solvability and termination detection. First, we prove for any (small) constant p ð0 G p � 1Þ that norandomized algorithm exists that solves, with probability p, the gathering problem with (termination) detection. For this reason, weconsider the relaxed gathering problem, called the gathering problem without detection, which does not require termination detection.We propose a randomized algorithm that solves, with any given constant probability p ð0 G p G 1Þ, the gathering problem withoutdetection. Finally, we prove that no randomized algorithm exists that solves, with probability 1, the gathering problem without detection.

Index Terms—Mobile agents, gathering problem, randomized algorithm, ring networks

Ç

1 INTRODUCTION

1.1 Background and Motivation

A distributed system consists of multiple autonomouscomputers (nodes) that can communicate with each

other. As a design paradigm for distributed systems, mobileagents have received much attention [1], [2], [3]. A (mobile)agent is an autonomous piece of software that moves in thenetwork carrying its state information. There are manyreasons for using agents [3]. For example, if remote hostsstore a large amount of data for processing, agents canreduce the network traffic by moving to the remote hostsand processing the data locally.

A distributed system with mobile agents is called amobile agent system. In mobile agent systems, the gatheringproblem is well known as one of the fundamental problems[1], [4], [5]. In the gathering (rendezvous) problem, multipleagents dispersed across the network are required to meet ata single node (see Fig. 1), for example, to share informationamong all agents or to synchronize the behavior of theagents.

In the gathering problem, agents initially have noknowledge of the network topology or other agents. Thisrequires that the agents move around the network anddetermine the gathering node based on the collectedinformation. The gathering problem can easily be solvedif each node in a network has a unique identifier or ID; eachagent then explores the network and terminates at the nodewith the smallest ID. However, such a unique ID may not

be available to the agents in some cases; for example,making the node ID known to agents may be prohibited forsecurity reasons. Hence, it is important to design algo-rithms that work in anonymous networks, i.e., networks inwhich nodes do not have unique IDs.

1.2 Related WorksIn anonymous networks, agents using the same determin-istic algorithm cannot solve the gathering problem becauseof the impossibility of breaking symmetry. For this reason,many researchers have considered the gathering problemwith some additional assumptions, such as that agents canleave marks on nodes [6], [7], [8], can use randomness [9],[10], [11], [12], know the upper bound on the size of thenetwork [13], and have distinct IDs [14], or that the edgelabeling [8], [15] or network topology [16], [17], [18], [19],[20] is restricted. Dieudonne and Pelc [13] considereddeterministic algorithms for gathering multiple agents inarbitrary synchronous networks. They characterized solv-able initial configurations (i.e., graphs and locations ofagents), from which there exists an algorithm that solvesthe gathering problem. In the case that agents know theupper bound on the size of the network, they proposed analgorithm that solves the gathering problem with (termina-tion) detection from any solvable initial configuration. Inthe case that no upper bound is known to the agents, theyalso proposed an algorithm that solves the gatheringproblem without detection from any solvable initial config-uration. They relaxed the problem to a gathering problemwithout detection, in which all agents eventually gatherand stop at the same node but without detecting thecompletion of gathering, and proposed an algorithm forthe relaxed problem. In contrast, in this paper, we focus onrandomized algorithms that solve, with some probability,the gathering problem from any initial configuration inasynchronous rings.

For asynchronous networks, various researchers haveproposed deterministic algorithms for gathering two agents

. The authors are with the Graduate School of Information Science andTechnology, Osaka University, Suita, Osaka 565-0871, Japan. Email:{f-oosita, s-kawai, kakugawa, masuzawa}@ist.osaka-u.ac.jp.

Manuscript received 15 Jan. 2013; revised 16 Aug. 2013; accepted 30 Sept.2013. Date of publication 9 Oct. 2013; date of current version 21 Mar. 2014.Recommended for acceptance by A. Kshemkalyani.For information on obtaining reprints of this article, please send e-mail to:[email protected], and reference the Digital Object Identifier below.Digital Object Identifier no. 10.1109/TPDS.2013.259

1045-9219 � 2013 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission.See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.

IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 25, NO. 5, MAY 2014 1289

Page 2: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

with distinct IDs. De Marco et al. [17] proposed adeterministic algorithm in an infinite line and a ring, aswell as an algorithm for an arbitrary graph assuming thatthe upper bound on the size of the graph is known. Theassumption for the arbitrary graph was removed byCzyzowicz et al. [14]. Note that, since this paper focuseson the solvability of gathering, the total number of moves isexponential on the size of the graph. Bampas et al. [19]proposed a polynomial-cost algorithm for infinite multidi-mensional grids given the assumption that each agentknows the coordinates of its own initial position.

Randomized algorithms for the gathering problem havebeen studied in [9], [10], [11], [12]. Kranakis and Krizanc[10] proposed a randomized algorithm based on a randomwalk for gathering two agents in a unidirectional ringnetwork. This algorithm requires no knowledge of thenumber of nodes and completes the gathering in Oðn2Þexpected steps. Alpern et al. [9] proposed a randomizedalgorithm for two agents, which is based on the Coin HalfTour. This algorithm requires knowledge of the number ofnodes and completes the gathering in OðnÞ expected steps.Guilbault and Pelc [12] proposed a randomized algorithmfor gathering two asynchronous agents in arbitrary finite or(countably) infinite graphs. However, for the problem withmore than two agents in anonymous unidirectional rings,no randomized algorithm is known.

The gathering problem in asynchronous rings has alsobeen considered in the context of robot networks [21], [22],[23], [24]. In these studies, agents (called robots) areoblivious (i.e., they have no memory), but they can observea global snapshot of the network and the locations of robotsand move based on the snapshot.

1.3 Our ContributionsWe consider the gathering problem of k ðk � 2Þ agents in aunidirectional n-node ring network. Note that, althoughunidirectional rings are simple, the algorithms givesolutions for essential difficulties of mobile agent systemssuch as symmetry breaking. We assume that each node hasa whiteboard and each agent knows neither the number ofnodes nor the number of agents. Under these conditions,we fully characterize the relation between probabilisticsolvability of the gathering problem and terminationdetection.1 To be precise, we present the following results,which are summarized in Table 1. Note that impossibilityresults hold even in a synchronous model and possibilityresults hold even in an asynchronous model.

First, we prove for any (small) constant p ð0 G p � 1Þthat no randomized algorithm exists that solves, withprobability p, the gathering problem with (termination)detection. This means we cannot design a randomizedalgorithm even if we require successful gathering with onlya small probability. This result seems counterintuitivebecause randomization can easily break symmetry. Actu-ally, if agents correctly distinguish each node of the ring byrandomly assigning distinct IDs, they can select a singlegathering node and gathering can be achieved. However, ifthe agents know neither the number of nodes nor thenumber of agents, they cannot ensure that they havedistinguished each node of the ring. If the ring size is fairlylarge, we show that, with high probability, two segmentsexist, which agents cannot distinguish. As a result, agentsin different segments select different gathering nodes.When termination detection is required, they may termi-nate at different nodes and gathering cannot be achieved.

Owing to the first impossibility result, we consider thegathering problem without detection, and propose a ran-domized algorithm that solves, with any given constantprobability p ð0 G p G 1Þ, the gathering problem withoutdetection. In Table 2, we compare our proposed algorithmwith the existing ones. Our algorithm requires at most OðnÞmoves for each agent, which means that our algorithm isasymptotically optimal in terms of the number of moves foreach agent. Intuitively, the above impossibility for thegathering problem with detection is overcome as follows.As in the gathering problem with detection, agents cannotensure that they have distinguished each node of the ringand thus, it is possible that some agents may stop atdifferent nodes. However, if termination detection is notrequired, other agents can wake up such suspended agents.This implies that, if at least one agent correctly distin-guishes each node of the ring, the agent can wake up otheragents and they can continue executing the algorithm. Ouralgorithm guarantees that, with high probability, at leastone agent correctly distinguishes each node of the ring.Through this mechanism, gathering of agents can beachieved with any given probability less than 1. Note thatin our algorithm gathering is achieved unless all agentsstop at incorrect nodes. This differs from the gatheringproblem with detection, where gathering cannot beachieved if two agents stop at incorrect nodes. The otherimportant feature of our algorithm is that agents cancorrectly compute n with high probability. If agents knowthe value of n, they can easily obtain k. Since knowledge ofk and n is important, our algorithm can be used as asubroutine of other algorithms.

Finally, we prove the impossibility for the remainingcase. That is, we prove that no randomized algorithm existsthat solves, with probability 1, the gathering problemwithout detection. In the proof, we show that, with apositive probability, all agents incorrectly guess that they

Fig. 1. Gathering problem in unidirectional rings.

1. If each agent knows the number of nodes or the number ofagents, the gathering problem with termination detection is easilysolved with probability 1.

TABLE 1Solvability of Gathering in Anonymous Unidirectional Rings

IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 25, NO. 5, MAY 20141290

Page 3: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

have distinguished each node of the ring. As a result, allagents stop without achieving gathering, and consequentlyno agent can wake up the suspended agents.

The underlying techniques of the impossibility proofsand algorithms are general and not limited to the gatheringproblem. Hence, these techniques can be applied to otherproblems of cooperation of mobile agents.

1.4 OrganizationIn Section 2, we present the system model and define theproblems dealt with. In Section 3, we show the impossibil-ity of the gathering problem with detection. In Section 4, wepresent a randomized algorithm for the gathering problemwithout detection, while in Section 5, we show theimpossibility of the gathering problem without detection.We conclude the paper in Section 6. Because of spacelimitations, the proofs of most theorems and lemmas areomitted, but are included in the supplementary materialwhich is available in the Computer Society Digital Libraryat http://doi.ieeecomputersociety.org/10.1109/259.

2 PRELIMINARIES

2.1 Network ModelA unidirectional ring network R is defined as the 2-tupleR ¼ ðV; EÞ, where V is a set of nodes and E is a set of uni-directional links. The number of nodes is denoted by nð¼jV jÞ. In this case, ring R is defined by V ¼ fv0; v1; . . . ; vn�1gand E ¼ fðvi; vðiþ1Þmod nÞj0 � i � n� 1g.

Every node vi has a whiteboard and any agent visitingnode vi can read from or write to the whiteboard. Ring R isanonymous, that is, nodes do not have unique IDs. Thismeans that an agent cannot distinguish two nodes if theyhave the same whiteboard contents.

2.2 Agent ModelThe number of agents is denoted by k. Let A ¼ fa0; a1; . . . ;ak�1g be a set of agents. We model the agents as identicalprobabilistic automata ðS;W; �; sinitialÞ. The first element S isthe set of states of the agents, which includes an initial statesinitial. Because all agents are identical, each agent initiallystarts with the same state sinitial. The second elementW is theset of states (or contents) of the whiteboard, which can bewritten or read by the agents. The third element � is the statetransition function � : S �W �RN ! S �W �M, whereRN represents a set of random values and M ¼ fmove;staygdenotes whether the agent moves in the step. The valuemove denotes movement to the next node, while stay meansthat the agent remains at the current node. We assume thatagents move instantaneously; that is, agents always exist at

nodes (and not at links). This assumption is introduced forsimplicity and does not cause any loss of generality even inthe asynchronous model.2 All agents have the same statetransition function � since they are identical.

2.3 System Configuration and ExecutionIn an agent system, (global) configuration c is defined asðS;W;LÞ, where S 2 Sk represents the states of agents,W 2Wn represents the states of nodes (whiteboards), andL 2 f0; 1; . . . ; n� 1gk represents the locations of agents. Thelocations of agents L ¼ ðl0; l1; . . . ; lk�1Þ implies that eachagent ai is located at node vli . We define C as the set of allconfigurations in an agent system. In initial configurationc0 2 C, each agent is in the same initial state sinitial and thewhiteboard of each node is empty. This means that theinitial configuration depends only on the locations ofagents. In the initial configuration, multiple agents may belocated at the same node.

Let Ai be an arbitrary non-empty set of agents. Whenconfiguration ci changes to ciþ1 by the actions of all agents

in Ai, we denote the transition by ci �!Ai

ciþ1. When aj 2 Ai

moves to the next node or changes some states (of its ownor the whiteboard), we say agent aj takes one step. Ifmultiple agents at the same node are included in Ai and cantake steps, they atomically take steps in an arbitrary order.If the sequence of configurations E ¼ c0; c1; . . . satisfies

ci �!Ai

ciþ1ði � 0Þ for a sequence of non-empty agent setsA0; A1; . . . ; E is called an execution starting from c0.Execution E is either infinite or ends in a final configura-tion cfinal where no agent can take a step. IfAi ¼ A holds forany i, all agents perform simultaneously. This model iscalled the synchronous model. Otherwise, i.e., if Ai ¼ A isnot always true, the model is called the asynchronous model.

2.4 Gathering ProblemIn this section, we formally define the gathering problem.First, we present a definition of the gathering problem with(termination) detection. A halt state is defined as the state inwhich the agent never takes another step. That is, if anagent enters a halt state, it can detect its termination. Thetraditional gathering problem requires agents to stop withsuch termination detection in the final configuration. Wecall this traditional gathering problem the gatheringproblem with detection. We assume without loss ofgenerality that agents have a unique halt state.

Definition 1. Execution E solves the gathering problem withdetection if the following conditions hold: 1) executionE is finite,and 2) in the final configuration, all agents meet at a single nodeand are in the halt state.

We also define the gathering problem without detection. Asuspended state is defined as a state in which the agent nevertakes another step unless the whiteboard of the currentnode is updated by another agent. The gathering problemwithout detection allows agents to stop in suspended

TABLE 2Gathering Algorithms in Anonymous Unidirectional Rings

2. This is because agents are asynchronously activated at nodes andare unaware of other agents at the same node. For example, considerthe case where a1 and a2 are at node v. At that time, if a1 is activatedbefore a2, a1 is unaware of a2 and consequently the state transition of a1

is not affected by a2. This can be considered as the situation where a2 isin transit to v.

OOSHITA ET AL.: GATHERING OF MOBILE AGENTS IN ANONYMOUS UNIDIRECTIONAL RING NETWORKS 1291

Page 4: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

states. An agent in a suspended state cannot detect itstermination because other agents may wake it up byupdating the whiteboard state of the node.

Definition 2. Execution E solves the gathering problemwithout detection if the following conditions hold: 1) executionE is finite, and 2) in the final configuration, all agents meet at asingle node and are in suspended states.

Randomized algorithms for the gathering problem aredefined as follows.

Definition 3. A randomized algorithm solves, with probabilityp, the gathering problem with detection (resp., without detection)if the following condition holds: From any initial configurationc0, executions that solve the gathering problem with detection(resp., without detection) occur with probability at least p.

3 IMPOSSIBILITY OF GATHERING WITH DETECTION

In this section, we consider the gathering problem withdetection and prove that no randomized algorithm existsthat solves the problem for the synchronous model with agiven positive probability. Note that, since synchronousexecution can occur in the asynchronous model, theimpossibility holds even for the asynchronous model.

An overview of the impossibility proof follows. Con-sider a ring R and an execution E such that an agent stopsin the halt state in R. First we show that we can construct afragment of the large ring R0 such that agents in thefragment move similarly to E with a positive probability.This fragment can be constructed by repeating the initialpositions of agents in R. Note that, if agents move similarlyto E, an agent stops in the halt state in the fragment. Ifagents in two disjoint fragments in R0 stop in the halt state,the algorithm fails to solve the gathering problem withdetection. However, we can arbitrarily increase the prob-ability of such an execution happening because we candeploy arbitrarily many fragments in R0.

Theorem 1. For any p ð0 G p � 1Þ, no randomized algorithmexists that solves, with probability p, the gathering problem withdetection in the synchronous model.

Proof:. We prove Theorem 1 by contradiction. Weassume that an algorithm exists that solves, with probabil-ity p, the gathering problem with detection.

We consider ring R that consists of n nodes, V ¼fv0; v1; . . . ; vn�1g, and k agents, A ¼ fa0; a1; . . . ; ak�1g. Fromthe hypothesis, there exists an execution E that solves thegathering problem with detection. We define T ðEÞ as thelength of E and denote E ¼ c0; c1; . . . ; cT ðEÞ. Note that everyagent enters the halt state in the final configuration cT ðEÞ.

Next, we consider a larger ring R0. Let q be the minimuminteger that satisfies qn � T ðEÞ. We consider a fragment ofR0 consisting of n0 ¼ 2qn þ n consecutive nodes, and call itsegment S. We denote nodes in segment S by v00; v

01; . . . ; v0n0�1.

We consider k0 ¼ kq þ k agents in segment S. These agentsare represented by AS ¼ fa00; a01; . . . ; a0k0�1g. The initiallocation ð‘00; ‘01; . . . ; ‘0k0�1Þ for the k0 agents in segment S isdefined from the initial location ð‘0; ‘1; . . . ; ‘k�1Þ for k agentsin ring R as follows:

‘0i ¼ ‘i mod k þ n � bi=kc:

That is, the initial positions for R are repeated from v00 tov0qnþn�1, and there are no agents from v0qnþn to v02qnþn�1 (seeFig. 2). For each node v0j in R0, we define Cvðv0jÞ ¼ vj mod n asthe corresponding node of v0j in R.

In the following, we first show that, with a probabilitydepending on n0 and k0, some agents in segment S enter thehalt state without moving out of S. Thereafter, we showthat the algorithm fails to achieve gathering with proba-bility 1� p or more if ring R0 contains sufficiently manyfragments with the same configuration as S. This contra-dicts our assumption.

First, we prove the following lemma, that is, we showthat some agents in segment S perform in the same way asagents in R with non-zero probability. (The proof is givenin the supplementary material available online.) We definethe local configuration of node v as the 2-tuple that consistsof the state of v and the states of all agents at v.

Lemma 1. Let us consider executionE0 ¼ c00; c01; . . . ; c0T ðEÞ; . . . forring R0. We define V 0t ¼ fv0t; v0tþ1; . . . ; v0qnþn�1g. In this case, forany t � T ðEÞ, configuration c0t satisfies the following conditionwith non-zero probability: for each node v0j 2 V 0t , the localconfiguration of v0j in c0t is the same as that of Cvðv0jÞ in ct.

From Lemma 1, in segment S for R0, configuration c0T ðEÞsatisfies the condition of Lemma 1 with some non-zeroprobability p0 9 0. If c0T ðEÞ satisfies the condition, in c0T ðEÞ thelocal configuration of each node in V � ¼ fv0qn; v0qnþ1; . . . ;v0qnþn�1g � V 0T ðEÞ is the same as that of the correspondingnode in cT ðEÞ. Note that the set of nodes corresponding tonodes in V � is equal to V , and every agent stops in the haltstate in configuration cT ðEÞ. Hence, there exist k agents in V �

in configuration c0T ðEÞ and the agents in V � also stop in thehalt state in configuration c0T ðEÞ. Another important point isthat the probability p0 in the above depends only on n0 andk0 (and not on the size of R0 or the total number of agents inR0). This obviously holds since the proof of Lemma 1considers the execution of segment S only.

In ring R0 of length xn0 or greater, we consider the initialconfiguration such that there exist x disjoint segments eachof which has the same configuration as that describedabove for segment S. In segment S, since there are initiallyno agents from v0qnþn to v02qnþn�1, no agent moves out ofsegment S before configuration c0T ðEÞ. So, none of the xsegments influences another before c0T ðEÞ, and the aboveexecution in segment S occurs independently. Therefore,the probability P that agents stop in the halt state in at least

Fig. 2. Initial configurations of R and R0.

IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 25, NO. 5, MAY 20141292

Page 5: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

two segments is P ¼ 1� ð1� p0Þx � xð1� p0Þx�1p0. If agentsstop in the halt state in two segments, they cannot meet at asingle node. Hence, this execution does not solve thegathering problem with detection. In other words, theprobability that this algorithm solves the gathering prob-lem with detection is at most 1� P . With sufficiently largesizes of ring R0 and x, 1� P G p holds. This contradicts theclaim that, for ring R0, this algorithm solves, withprobability p, the gathering problem with detection.Therefore, we have Theorem 1. g

Note that the proof holds even if we consider executionE such that at least one agent stops in the halt state. Thismeans that even if we require at least one agent only to stopin the halt state, no randomized algorithm solves thegathering problem with constant probability.

4 A RANDOMIZED ALGORITHM FOR GATHERINGWITHOUT DETECTION

4.1 Proposed AlgorithmIn this section, we propose a randomized algorithm thatsolves, with any given probability p ð0 G p G 1Þ, the gatheringproblem without detection. The idea behind the algorithmis to assign a random ID to each node so that agents candetermine a unique gathering node based on the IDs.

In the following, we present the algorithm. The proba-bility p with which the gathering problem is solved is givenas an input to the algorithm. Throughout the section, whenan agent writes a random bit to a variable, it selects one orzero uniform randomly.

First, we give an overview of the algorithm, whichconsists of three phases. In phase 1, each agent moves in thering and allocates random IDs of length dlogð1=ð1� pÞÞe tonodes. Based on the random ID assigned to each node, theagent distinguishes each node and guesses the number ofnodes, say n0. In phase 1, the agent moves 3n0 times, andconsequently a random ID is assigned to every node if n0 iscorrectly guessed and is equal to n. In phase 2, the agentmoves to n0 nodes and writes the value n0 on the nodes’whiteboards. Then, the agent determines the gatheringnode and moves to it. If n0 is correctly guessed by an agentin phase 1, every node knows the number of nodes afterphase 2. At the end of phase 2, the agent enters a suspendedstate at the gathering node. However, if n0 has not beencorrectly guessed and differs from n, the agent mayprematurely stop moving and enters a suspended state.Even in this case, if another agent guesses the correctnumber n, it writes the value n on the whiteboard of everynode in phase 2. Consequently the agent in the suspendedstate realizes its incorrect guess of the number of nodes andresumes its behavior. This is phase 3, in which the agentmoves throughout the ring, memorizing IDs, and deter-minning the gathering node, to which it eventually moves.Note that, if at least one agent succeeds in guessing thecorrect number of nodes, every agent will eventually knowthe correct number of nodes and the IDs of all the nodes.This is very useful to guarantee that all the agents can meetat a single node with probability p or greater.

In the remainder of this section, we present the details ofeach phase. The pseudocode is given in Algorithms 1 and 2.

In the pseudocode, we denote by node vj the node at whichthe agent currently resides. To explain the details, wedefine some terms of sequences. For sequence X, we defineX2 as the concatenation X �X and X‘þ1 ¼ X‘ �X. We saysequence X is periodic if and only if X ¼ Y ‘ holds for somesequence Y and integer ‘ � 2.

4.1.1 Phase 1The goal of phase 1 is for each agent to guess the number ofnodes. The fundamental idea of estimating the number ofnodes is to assign a random ID to each node and to considerthat the agent moves around the ring twice when it finds arepeated sequence of IDs. Agent ai uses variablesmem, t, n0

for agent ai, and wbj for node vj. Variable wbj stores therandom ID of node vj, while mem is used to store thesequence of node IDs the agent has visited. Variable t storesthe number of moves in phase 1. Variable n0 stores theguessed value of the number of nodes in the ring. We call n0

the temporal number of nodes.Agent ai executes the following procedure in each step.

Assume that ai is located at node vj.

. Agent ai generates a random ID of lengthdlogð1=ð1� pÞÞe and writes the ID to wbj unless wbjalready stores an ID.

. Agent ai assigns wbj (the random ID) to mem½t,where t is the number of moves the agent has made.

. Agent ai guesses the number of nodes from mem(see the details below) and assigns it to n0.

. Agent ai moves to the next node.

This step is repeated until ai guesses some temporalnumber of nodes n0 and the number of moves is at least 3n0.As shown later, this number of moves guarantees thefollowing: 1) agent ai guesses the correct number of nodeswith probability p, and 2) if the guess is incorrect, n0 G n=2holds.

Here we explain the way an agent guesses the numberof nodes from mem (function Guess() in Algorithm 2).Because agent ai moves repeatedly, it eventually movesaround the ring twice. At that time, each ID in the first halfof mem is equal to one in the latter half of mem. For thisreason, the agent guesses the number of nodes when eachID in the first half of mem appears in the latter half of mem.To be precise, the agent guesses that the number of nodes isd where d ð1 � d � bt=2cÞ is the minimum value satisfying,for any x ð0 � x G t� dÞ, mem½x ¼ mem½xþ d (see Fig. 3).If no such d exists, the agent continues in phase 1 to guessthe number of nodes and assigns zero to n0.

Fig. 3. Way an agent guesses the number of nodes.

OOSHITA ET AL.: GATHERING OF MOBILE AGENTS IN ANONYMOUS UNIDIRECTIONAL RING NETWORKS 1293

Page 6: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

Algorithm 1 Proposed Algorithm

input

float p 2 ð0; 1ÞVariables for Agent aiint t ¼ 0 // number of moves in each phaseboolean[ ][ ] mem

int hmin ¼ 0

int n0 ¼ 0 // guessed value of the number of nodes

Variables for Node vjboolean[ ] wbjint sizej ¼ 0

Main Routine of Agent aiPhase 1

1: while (n0 ¼ 0 or t G 3n0) do

2: ai generates a random ID of length dlogð1=ð1� pÞÞeand writes the ID to wbj unless wbj already stores an ID.

3: ai assigns wbj to mem½t4: t ¼ tþ 1

5: n0 ¼ GuessðÞ6: ai moves to the next node

7: end while

Phase 2

8: for t ¼ 0 to n0 � 1 do

9: if sizej G n0 then

10: sizej ¼ n011: end if

12: ai moves to the next node

13: end for

14: hmin ¼ GatheringNodeðÞ15: for ‘ ¼ 0 to hmin � 1 do

16: ai moves to the next node17: end for

18: ai stops in the suspended state

Phase 3

19: while 1 do

20: if n0 � sizej=2 then

21: n0 ¼ sizej22: for t ¼ 0 to n0 � 1 do

23: ai assigns wbj to mem½t24: ai moves to the next node25: end for

26: hmin ¼ GatheringNodeðÞ27: for t ¼ 0 to hmin � 1 do

28: ai moves to the next node

29: end for

30: ai stops in the suspended state

31: end if

32: end while

Algorithm 2 Proposed Algorithm

int Guess()

1: D¼the set of d ð1�d �bt=2cÞ such that 8x ð0 � x G t�dÞ mem½x ¼ mem½xþ d.

2: If D 6¼ ;, return minðDÞ. If D ¼ ;, return 0.

int GatheringNode()

3: Let seqx ð0 � x G n0Þ be the cyclically shifted sequencemem ½x; . . . ; mem ½n0 � 1; mem ½0; . . . ; mem ½x � 1 ofsequence mem½0; . . . ; mem½n0 � 1.

4: Let x� be x such that seqx is the lexicographically mini-mum among seq0 to seqn0�1.

5: Return the distance from the current node to node vjsuch that wbðjþyÞmod n0 ¼mem½ðx�þ yÞmod n0 for any yð0 � y G n0Þ. Note that the agent computes the distancebased on its temporal number of nodes.

4.1.2 Phase 2In phase 2, agent ai writes the temporal number of nodesn0 to sizej of each node vj and then moves to a commonnode where all agents should meet. The process is easilyrealized by moving n0 times and assigning n0 to sizej ofeach node vj. If sizej has already been assigned a valuegreater than n0, agent ai does not overwrite sizej becausen0 is not equal to n. If n0 ¼ n holds, all nodes can obtain thecorrect number of nodes. As we explain in phase 3, thisprocess is used to wake up agents that are in suspendedstates as a result of retaining incorrect (or smaller)numbers of nodes.

Next we show how all the agents can select a commonnode. Agent ai chooses the node based on mem½0 tomem½n0 � 1. In more detail, ai chooses it in the followingway (function Gatheringnode() in Algorithm 2):

. Let seqx ð0 � x G n0Þ be the cyclically shifted sequencemem½x; . . . ;mem½n0 � 1;mem½0; . . . ;mem½x� 1 ofsequence mem½0; . . . ;mem½n0 � 1.

. Let x� be x such that seqx is the lexicographicalminimum of seq0 to seqn0�1.

. Node vj corresponding to seqx� (or vj such thatwbðjþyÞmod n0 ¼ mem½ðx� þ yÞmod n0 for y ð0 � y G n0Þ)is the common node where all agents meet.

Note that, if n0 ¼ n holds, sequencemem½0; . . . ; mem½n0 � 1is not periodic, because otherwise ai would guess asmaller number as n0. Thus, in this case, all the agents canselect the common node and successfully gather at thatnode. After ai has reached the node, it enters a suspendedstate.

4.1.3 Phase 3Phase 3 specifies the behavior after ai stops in thesuspended state. If ai is in the suspended state, itrepeatedly checks sizej for its current node vj. As shownlater, if ai fails to estimate n correctly, n0 � n=2 holds.Consequently, if another agent estimates the correct valueof n, it updates sizej to 2n0 or more. Thus, when sizej isupdated to a value 2n0 or more, agent ai wakes up andmoves to the node to meet the other agents.

The behavior of ai is as follows:

. Agent ai assigns sizej to n0.

. Agent ai moves n0 times, and memorizes wbj for eachnode vj from mem½0 to mem½n0 � 1.

IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 25, NO. 5, MAY 20141294

Page 7: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

. The agent selects the node at which to meet the otheragents in the same way as in phase 2, and thenmoves to the node.

. Agent ai stops in the suspended state.

Note that, if an agent guesses the correct number ofnodes in phase 1, it writes the correct number of nodes ontothe whiteboards of all nodes. Thereafter, in phase 3, theother agents can ascertain the correct number of nodes andcompute the common node.

4.2 Complexity and Correctness of the AlgorithmIn this section, we prove the correctness of the algorithm.Because of space limitations, we only give an outline of theproof; the complete proof is given in the supplementarymaterial available online.

First, we can easily prove the complexity from thealgorithm.

Lemma 2. Each agent moves OðnÞ times in the algorithm. Eachnode requires OðlognÞ memory space and each agent requiresOðnÞ memory space.

In the following, we show that the algorithm solves,with probability p, the gathering problem without detec-tion. The important fact is that, if agent ai guesses theincorrect number of nodes n0 (i.e., n0 6¼ n holds), n0 � n=2holds (Lemma 4). Lemma 3 is used to prove Lemma 4.

Lemma 3. Consider an n-length sequence A¼a0 . . . an�1 and ann0-length sequence B ¼ b0 . . . bn0�1 such that n0 G n holds. If B3 isthe prefix of A3, either n0 � n=2 holds or B is periodic.

Lemma 4. At the end of phase 1, if agent ai guesses the incorrectnumber of nodes n0 (i.e., n0 6¼ n holds), n0 � n=2 holds.

If agent ai guesses n0 ðn0 G nÞ as the temporal number ofnodes, mem½0; . . . ; mem½n0�1 ¼ mem½n0; . . . ; mem½2n0�1holds. Since n0 � n=2 holds from Lemma 4, each element ofmem½0; . . . ; mem½2n0 � 1 corresponds to whiteboard wbj ofa different node. Therefore, we can easily compute theprobability that agent ai guesses the incorrect number ofnodes, and we have the following lemma.

Lemma 5. In phase 1, for each agent ai, ai guesses the correctnumber of nodes (i.e., n0 ¼ n holds) with probability p.

From Lemma 5, some agent ai guesses the correctnumber of nodes n0 ¼ n in phase 1 with probability p. Inthis case, ai makes n known to every node in phase 2. Theremay be an agent that guesses the incorrect number n00 as thenumber of nodes and stops in the suspended state.However, from Lemma 4, n00 � n=2 holds and consequentlythe agent knows n in phase 3. This means all agents canobtain the correct number of nodes n. This implies they canobtain all random IDs on the whiteboards and determinea single node at which to meet, and thus we have thefollowing lemma.

Lemma 6. The algorithm solves, with probability p, thegathering problem without detection.

From Lemmas 2 and 6, we have the following theorem.

Theorem 2. For any given input p ð0 G p G 1Þ, the algorithmgiven by Algorithms 1 and 2 solves, with probability p, thegathering problem without detection. In the algorithm, eachagent moves OðnÞ times and requires OðnÞ memory space, whileeach node requires OðlognÞ memory space.

5 IMPOSSIBILITY OF GATHERINGWITHOUT DETECTION

In this section, we consider the impossibility of thegathering problem without detection. In the previoussection, we proved that, for any constant p ð0 G p G 1Þ, thegathering problem without detection can be solved withprobability p. For the remaining cases, we prove theimpossibility thereof. That is, we show that no randomizedalgorithm exists that solves, with probability 1, the gatheringproblem without detection. We prove the theorem for thesynchronous model, and consequently the theorem holdsin the asynchronous model.

Theorem 3. No randomized algorithm exists that solves, withprobability 1, the gathering problem without detection in thesynchronous model.

The proof of Theorem 3 is similar to that for the im-possibility of gathering with detection in Section 3. Consideran n-node ring R with k agents. Any algorithm guaranteesthat all agents meet at a single node and stop in the sus-pended states in R. Next, consider a 2n-node ring R0 with 2kagents. The initial positions of agents inR are repeated twicein R0. In this case, all the agents in R0 can behave in the sameway as those in R. Consequently, half of the agents meet atone node while the other half meet at another node. Allagents stop in the suspended states and thus the algorithmcannot solve the gathering problem without detection.

6 CONCLUSION

In this paper, we considered randomized gathering ofmobile agents in anonymous unidirectional ring networksunder the assumption that each mobile agent knowsneither the number of nodes nor the number of mobileagents. We showed the impossibility result for the problemwith detection, and possibility and impossibility results(depending on the success probability) for the problemwithout detection. The underlying technique used to obtainthe results is general, and consequently can be applied tomany problems of cooperation of mobile agents.

As future work, we intend developing an algorithm forother topologies using the approach that each agentconstructs a labeled network from an anonymous network.This would be possible by combining our proposedtechnique, a ring embedding algorithm (e.g., [25]), and aring orientation algorithm (e.g., [26]). However, additionalresearch would be needed to optimize the cost includingmemory space and the total number of moves.

ACKNOWLEDGMENT

This work was supported in part by Grants-in-Aid forScientific Research ((B)2030012, (B)22300009, (B)23700056,and (C)24500039) of the JSPS. The conference version of this

OOSHITA ET AL.: GATHERING OF MOBILE AGENTS IN ANONYMOUS UNIDIRECTIONAL RING NETWORKS 1295

Page 8: Randomized Gathering of Mobile Agents in Anonymous Unidirectional Ring Networks

paper is published in the Proceedings of the 19th Interna-tional Colloquium on Structural Information and Commu-nication Complexity (SIROCCO 2012).

REFERENCES

[1] E. Kranakis, D. Krizanc, and E. Markou, The Mobile AgentRendezvous Problem in the Ring, San Rafael, CA, USA: Morgan &Claypool Publishers, 2010.

[2] J. Cao and S.K. Das, Mobile Agents in Networking and DistributedComputing. Hoboken, NJ, USA: Wiley, 2012.

[3] D.B. Lange and M. Oshima, ‘‘Seven Good Reasons for MobileAgents,’’ Comm. ACM, vol. 42, no. 3, pp. 88-89, Mar. 1999.

[4] A. Pelc, ‘‘Disc 2011 Invited Lecture: Deterministic Rendezvous inNetworks: Survey of Models and Results,’’ in Proc. 25th Int’lSymp. Distributed Computing, 2011, pp. 1-15.

[5] A. Pelc, ‘‘Deterministic Rendezvous in Networks: A Compre-hensive Survey,’’ Networks, vol. 59, no. 3, pp. 331-347, May 2012.

[6] J. Chalopin, S. Das, and P. Widmayer, ‘‘Rendezvous of MobileAgents in Directed Graphs,’’ in Proc. 24th Int’l Symp. DistributedComputing, 2010, pp. 282-296.

[7] S. Das, M. Mihalak, R. Sramek, E. Vicari, and P. Widmayer,‘‘Rendezvous of Mobile Agents When Tokens Fail Anytime,’’in Proc. 12th Int’l Conf. Principles Distributed Systems, 2008,pp. 463-480.

[8] E. Kranakis, D. Krizanc, and E. Markou, ‘‘Mobile AgentRendezvous in a Synchronous Torus,’’ in Proc. Latin Am. TheoreticalInformatics Symp., 2006, pp. 653-664.

[9] S. Alpern, V. Baston, and S. Essegaier, ‘‘Rendezvous Searchon a Graph,’’ J. Applied Probability, vol. 36, no. 1, pp. 223-231,Mar. 1999.

[10] E. Kranakis and D. Krizanc, ‘‘An Algorithmic Theory of MobileAgents,’’ in Proc. 2nd Int’l Conf. Trustworthy Global Computing,2006, pp. 86-97.

[11] E. Kranakis, D. Krizanc, and P. Morin, ‘‘Randomized Rendez-Vouswith Limited Memory,’’ in Proc. 8th Latin Am. Theoretical.Informatics Symp., 2008, pp. 605-616.

[12] S. Guilbault and A. Pelc, ‘‘Asynchronous Rendezvous ofAnonymous Agents in Arbitrary Graphs,’’ in Proc. 15th Int’lConf. Principles Distributed Systems, 2011, pp. 421-434.

[13] Y. Dieudonne and A. Pelc, ‘‘Anonymous Meeting in Networks,’’in Proc. 24th Ann. ACM-SIAM Symp. on Discrete Algorithms, 2013,pp. 737-747.

[14] J. Czyzowicz, A. Labourel, and A. Pelc, ‘‘How to MeetAsynchronously (Almost) Everywhere,’’ in Proc. 21st Ann.ACM-SIAM Symp. on Discrete Algorithms, 2010, pp. 22-30.

[15] L. Barriere, P. Flocchini, P. Fraigniaud, and N. Santoro,‘‘Rendezvous and Election of Mobile Agents: Impact of Senseof Direction,’’ Theory of Computing Systems, vol. 40, no. 2,pp. 143-162, 2007.

[16] D. Baba, T. Izumi, F. Ooshita, H. Kakugawa, and T. Masuzawa,‘‘Linear Time and Space Gathering of Anonymous MobileAgents in Asynchronous Trees,’’ Theoretical Computer Science,vol. 478, pp. 118-126, Mar. 2013.

[17] G.D. Marco, L. Gargano, E. Kranakis, D. Krizanc, A. Pelc, andU. Vaccaro, ‘‘Asynchronous Deterministic Rendezvous inGraphs,’’ Theoretical Computer Science, vol. 355, no. 3, pp. 315-326,Apr. 2006.

[18] P. Fraigniaud and A. Pelc, ‘‘Deterministic Rendezvous in Treeswith Little Memory,’’ in Proc. 22nd Int’l Symp. DistributedComputing, 2008, pp. 242-256.

[19] E. Bampas, J. Czyzowicz, L. Gasieniec, D. Ilcinkas, and A. Labourel,‘‘Almost Optimal Asynchronous Rendezvous in Infinite Multi-dimensional Grids,’’ in Proc. 24th Int’l Symp. Distributed Computing,2010, pp. 297-311.

[20] A. Collins, J. Czyzowicz, L. Gasieniec, A. Kosowski, and R. Martin,‘‘Synchronous Rendezvous for Location-Aware Agents,’’ in Proc.25th Int’l Symp. Distributed Computing, 2011, pp. 447-459.

[21] R. Klasing, E. Markou, and A. Pelc, ‘‘Gathering AsynchronousOblivious Mobile Robots in a Ring,’’ Theoretical Computer Science,vol. 390, no. 1, pp. 27-39, Jan. 2008.

[22] R. Klasing, A. Kosowski, and A. Navarra, ‘‘Taking Advantage ofSymmetries: Gathering of Many Asynchronous Oblivious Robotson a Ring,’’ Theoretical Computer Science, vol. 411, no. 34–36,pp. 3235-3246, Jul. 2010.

[23] G. D’Angelo, G.D. Stefano, and A. Navarra, ‘‘How to GatherAsynchronous Oblivious Robots on Anonymous Rings,’’ in Proc.26th Int’l Symp. Distributed Computing, 2012, pp. 326-340.

[24] S. Kamei, A. Lamani, F. Ooshita, and S. Tixeuil, ‘‘Gathering anEven Number of Robots in an Odd Ring without GlobalMultiplicity Detection,’’ in Proc. 37th Int’l Symp. Math. Founda-tions of Computer Science, 2012, pp. 542-553.

[25] Y. Yamauchi, D. Bein, T. Masuzawa, L. Morales, andI.H. Sudborough, ‘‘Calibrating Embedded Protocols on Asyn-chronous Systems,’’ Information Sciences, vol. 180, no. 10, pp. 1793-1801, May 2010.

[26] A. Israeli and M. Jalfon, ‘‘Uniform Self-Stabilizing Ring Orien-tation,’’ Information and Computation, vol. 104, no. 2, pp. 175-196,Jun. 1993.

Fukuhito Ooshita received ME and DI degreesin Computer Science from Osaka University, in2002 and 2006, respectively. Since 2003, he hasbeen an Assistant Professor in the GraduateSchool of Information Science and Technologyat Osaka University. His research interestsinclude parallel algorithms and distributed algo-rithms. He is a member of ACM, IEEE, IEICE,and IPSJ.

Shinji Kawai received BE and MI degrees inComputer Science from Osaka University, in2010 and 2012, respectively. His researchinterests include distributed algorithms.

Hirotsugu Kakugawa received a BE degree inEngineering from Yamaguchi University, in1990, and ME and DE degrees in InformationEngineering from Hiroshima University, in 1992and 1995, respectively. He is currently anAssociate Professor in Osaka University. He isa member of IEEE and IPSJ.

Toshimitsu Masuzawa received BE, ME, andDE degrees in Computer Science from OsakaUniversity, in 1982, 1984, and 1987, respective-ly. Between 1987 and 1994, he worked at OsakaUniversity, and was an Associate Professor inthe Graduate School of Information Science,Nara Institute of Science and Technology (NA-IST) between 1994 and 2000. He is now aProfessor in the Graduate School of InformationScience and Technology, Osaka University. Hewas also a visiting Associate Professor in the

Department of Computer Science, Cornell University, USA between1993 and 1994. His research interests include distributed algorithms,parallel algorithms, and graph theory. He is a member of ACM, IEEE,IEICE, and IPSJ.

. For more information on this or any other computing topic,please visit our Digital Library at www.computer.org/publications/dlib.

IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 25, NO. 5, MAY 20141296