1 Introduction

Motion planning for sets of objects is a theoretical and practical problem of great importance. A typical task arises from relocating a large collection of agents from a given start into a desired target configuration, while avoiding collisions between objects or with obstacles. Previous work has largely focused on achieving reconfiguration via sequential schedules, where one agent moves at a time; however, reconfiguring efficiently requires reaching the target configuration in a timely or energy-efficient manner, with a natural objective of minimizing the time until completion, called makespan. Problems of labeled reconfiguration play an important role whenever the involved agents need to be distinguished, such as in automated warehouses and autonomous vehicles; see Stern et al. [46] for an overview, and the classic works with further applications by Švestka and Overmars [47] (multi-robot motion planning), Casal and Yim [8] (modular robotics), and Kornhauser et al. [32] (memory management). The algorithmic difficulty of optimal labeled reconfiguration was established as early as 1979 by Reif [37], who gave a proof of PSPACE-completeness. Achieving minimum makespan for reconfiguring a swarm of labeled robots was the subject of the 2021 Computational Geometry Challenge [25]; see [13, 34, 50] for successful contributions.

Exploiting parallelism in a robot swarm to achieve an efficient schedule was studied in recent seminal work by Demaine et al. [17]: Under certain conditions, a labeled set of robots can be reconfigured with bounded stretch, i.e., there is a collision-free motion plan such that the makespan of the schedule remains within a constant of the lower bound that arises from the maximum distance between origin and destination of individual agents; see also the video by Becker et al. [5] that illustrates these results.

A second important aspect for many applications is connectivity of the swarm throughout the reconfiguration, because disconnected pieces may not be able to regain connectivity, and also because of small-scale swarm robots (such as catoms in claytronics [28]), which need connectivity for local motion, electric power and communication; see the video by Bourgeois et al. [6]. Connectivity is not necessarily preserved in the schedules by Demaine et al. [17]. In more recent work, Fekete et al. [24] presented an approach that does achieve constant stretch for unlabeled swarms of robots for the class of scaled arrangements; such arrangements arise by increasing all dimensions of a given object by the same multiplicative factor and have been considered in previous seminal work on self-assembly, often with unbounded or logarithmic scale factors (along the lines of what has been considered in self-assembly [42]). The method by Fekete et al. [24] relies strongly on the exchangeability of indistinguishable agents, which allows a high flexibility in allocating agents to target positions. However, the labeled setting cannot exploit this flexibility, making it significantly more complex.

These results have left two major open problems.

  1. 1.

    Can efficient reconfiguration be achieved in a connected manner for a swarm of labeled robots in a not necessarily scaled arrangement?

  2. 2.

    Is it possible to achieve constant stretch for connected reconfiguration of scaled arrangements of labeled objects?

1.1 Our contributions

We resolve both of these open problems.

  1. 1.

    We show that connected reconfiguration of a swarm of n labeled robots may require a stretch factor of at least \(\Omega (\sqrt{n})\).

  2. 2.

    On the positive side, we present an approach to constant stretch for connected reconfiguration of scaled arrangements of labeled objects.

  3. 3.

    In addition, we prove NP-completeness of deciding whether a makespan of 2 for labeled connected reconfiguration can be achieved.

1.2 Related work

Research for multi-agent coordination dates back to the early years of algorithmic research, such as the seminal works by Reif [37] with his proof of PSPACE-completeness of optimal labeled reconfiguration, and Schwartz and Sharir [41] with their results on motion planning for multiple geometric objects. Efficiently coordinating the motion of many agents arises in a large spectrum of applications, such as air traffic control [15], vehicular traffic networks [23, 40], ground swarm robotics [38, 39], or aerial swarm robotics [12, 49]. In both discrete and geometric variants of the problem, the objects can be labeled, colored or unlabeled. In the labeled case, the objects are all distinguishable and each object has its own, uniquely defined target position. In the colored case, the objects are partitioned into k groups and each target position can only be covered by an object with the right color; see Solovey and Halperin [43]. In the unlabeled case, objects are indistinguishable and target positions can be covered by any object; see Kloder and Hutchinson [31], Turpin et al. [48], Adler et al. [1], and Solovey et al. [45]. On the negative side, Solovey and Halperin [44] prove that the unlabeled multiple-object motion planning problem is PSPACE-hard. Calinescu, Dumitrescu, and Pach [7] consider the sequential reconfiguration of objects lying on vertices of a graph. They give NP-hardness and inapproximability results for several variants, a 3-approximation algorithm for the unlabeled variant, as well as upper and lower bounds on the number of sequential moves needed. Geft and Halperin [27] show that distance-optimal multi-agent path finding remains NP-hard on 2-dimensional grids and multiple empty vertices. They obtain their result by a linear reduction from 3Sat, which allows them to exploit the Exponential Time Hypothesis [29] and therefore to obtain an exponential lower bound on the running time of the problem.

We already mentioned the work by Demaine et al. [17] for achieving constant stretch for coordinated motion planning, as well as the recent practical 2021 Computational Geometry Challenge [13, 25, 34, 50]. None of these approaches satisfy the crucial connectivity constraint, which has previously been investigated in terms of decidability and feasibility by Dumitrescu and Pach [20] and Dumitrescu, Suzuki, and Yamashita [22]. Furthermore, these authors have also proposed efficient patterns for fast swarm locomotion in the plane using sequential moves that allow preservation of connectivity [21]. A closely related body of research concerns itself with sequential pivoting moves that require additional space around moving agents, limiting feasibility and reachability of target states, see publications by Akitaya et al. [3, 4].

Very recently, Fekete et al. [24] presented a number of new results for connected, but unlabeled reconfiguration. In addion to complexity results for small makespan, they showed that there is a constant \(c^*\) such that for any pair of start and target configurations with a (generalized) scale of at least \(c^*\), a schedule with constant stretch can be computed in polynomial time. The involved concept of scale has received considerable attention in self-assembly; achieving constant scale has required special cases or operations. Soloveichik and Winfree [42] showed that the minimal number of distinct tile types necessary to self-assemble a shape, at some scale, can be bounded both above and below in terms of the shape’s Kolmogorov complexity, leading to unbounded scale in general. Demaine et al. [19] showed that allowing to destroy tiles can be exploited to achieve a scale that is only bounded by a logarithmic factor, beating the linear bound without such operations. In a setting of recursive, multi-level staged assembly with a logarithmic number of stages (i.e., “hands” for handling subassemblies), Demaine et al. [16] achieved logarithmic scale, and constant scale for more constrained classes of polyomino shapes; this was later improved by Demaine et al. [18] to constant scale for a logarithmic number of stages. More recently, Luchsinger et al. [35] employed repulsive forces between tiles to achieve constant scale in two-handed self-assembly.

For an extensive overview of multi-agent path finding we refer to [46]. Agarwal et al. [2] consider the motion planning problem for unit discs agents in polygonal domains, with each agent having a revolving area around their start and target positions. They study weakly-monotone motion plans, i.e., the agents are ordered and move iteratively with respect to this ordering from their start to their respective target. To avoid collisions, all other agents are allowed to move only within their revolving area. They show APX-hardness for minimizing the total distance traveled, and complementary provide a constant-factor approximation. Yu and LaValle [51] discuss the relationship of multi-agent path planning and flow problems in collision-free unit-distance graphs. Charrier et al. [9,10,11] study reachability and coverage planning problems for connected agents. Queffelec, Sankur, and Schwarzentruber [36] study the connected multi-agent path finding problem in partially known environments in which the graph is not known entirely in advance. Despite the fact that all of this is related to our work, a crucial difference is that we consider the stretch factor as the main performance measure.

1.3 Preliminaries

We consider agents at nodes of the integer infinite grid \(G=(V,E)\), where two nodes are connected if and only if they are in unit distance, where distances are measured in the \(L_1\) metric. A configuration is a mapping \(C: V\rightarrow \{1,\dots , n,\bot \}\), i.e., each node is mapped injectively to one of the n labeled agents, or to \(\bot\) if the node is empty. The configuration C is connected if the grid graph H that is induced by occupied nodes in C is connected. The silhouette of a configuration C is the respective unlabeled configuration, i.e., C without labeling. Unless stated otherwise, we consider labeled connected configurations.

Two agents are adjacent if their positions \(v_1,v_2\) are adjacent, i.e., \(\{v_1,v_2\} \in E(H)\). An agent can move in discrete time steps by changing its location from a grid position v to an adjacent grid position w, denoted by \(v \rightarrow w\). Two moves \(v_1 \rightarrow w_1\) and \(v_2 \rightarrow w_2\) are collision-free if \(v_1 \ne v_2\) and \(w_1 \ne w_2\). We assume that a swap operation, i.e., two moves \(v_1\rightarrow v_2\) and \(v_2\rightarrow v_1\), causes a collision and is therefore not allowed in our model. Note that an agent is allowed to hold its position. A transformation between two configurations \(C_1\) and \(C_2\) is a set of collision-free moves \(\{ v \rightarrow w \mid C_1(v) = C_2(w)\ne \bot \}\). For \(M \in \mathbb {N}\), a schedule with a makespan of M is a sequence \(C_1 \rightarrow \cdots \rightarrow C_{M+1}\) (abbreviated as \(C_1 \rightrightarrows C_{M+1}\)) of transformations. A stable schedule \(C_1 \rightrightarrows _{\chi } C_{M+1}\) uses only connected configurations. In the context of this paper, we use these notations equivalently.

Let \(C_{s}\) and \(C_{t}\) be two connected configurations with equally many agents called start and target configuration, respectively. The diameter d of the pair \((C_s,C_t)\) is the maximal Manhattan distance between an agent’s start and target position. The stretch factor (or simply stretch) of a schedule \(C_1 \rightrightarrows _{\chi } C_{M+1}\) is the ratio between its makespan M and the diameter d of \((C_s,C_t)\).

With these definitions we can state our problem, called the Labeled Connected Coordinated Motion Planning Problem, as follows. Given a pair \((C_s, C_t)\) of labeled connected configurations with equally many agents, and an integer k, we are asked to decide whether there is a stable schedule with a makespan of at most k transforming \(C_s\) into \(C_t\).

2 Fixed makespan

Given two labeled configurations, it is easy to see that it can be determined in linear time whether there is a schedule with a makespan of 1 that transforms one into the other: For every robot, check whether its target position is in distance at most 1; furthermore, check that no two robots want to swap their positions. This involves \(\mathcal {O}(1)\) checks for every robot, thus \(\mathcal {O}(n)\) checks in total. We obtain the following.

Theorem 1

It can be decided in \(\mathcal {O}(n)\) time whether there is a schedule \(C_s \rightrightarrows _\chi C_t\) with makespan 1 for any pair \((C_s, C_t)\) of labeled connected configurations with n robots.

Proof

Without loss of generality, we assume that the matching between positions from \(C_s\) and \(C_t\) is perfect. Otherwise, a position is occupied multiple times so no feasible reconfiguration is possible. We can confirm that \(C_s\) and \(C_t\) are connected by comparing n to the size of an arbitrary connected component of each. The latter can be computed using a graph exploration algorithm such as breadth-first-search in \(\mathcal {O}(n)\) time, as the respective dual graph is sparse.

To check whether there is a schedule with a makespan of 1, we check for every position \(p\in C_s\) whether its matched position \(p'\in C_t\) is in distance at most 1; this can be done in \(\mathcal {O}(1)\) time for each position. Swaps are forbidden, so we also check if any pair of robots need to swap their positions. Because we want to decide whether a schedule with a makespan of 1 exists, this only affects pairs of robots that share their neighborhoods. Thus, this can be done in \(\mathcal {O}(1)\) time for each position. Because a configuration has n vertices, this takes a total of \(\mathcal {O}(n)\) time. \(\square\)

As a direct consequence of Theorem 1, we observe the following.

Corollary 1

Solutions for the Labeled Connected Coordinated Motion Planning Problem can be verified in polynomial time, thus, the problem is in NP.

On the other hand, Fekete et al. [24] showed that it is already NP-complete to decide whether a schedule with a makespan of 2 can be achieved, if the robot swarm is unlabeled. Their proof is based on a reduction from the NP-complete problem Planar Monotone 3Sat [14], which asks to the decide the satisfiability of a Boolean 3-CNF formula for which the literals in each clause are either all unnegated or all negated, and the corresponding variable-clause incidence graph is planar. Furthermore, this graph has a planar embedding such that the variables are embedded on a line, and all unnegated clauses are above, while the negated ones are below that variable line.

A brief overview of the used gadgets, alongside a complete construction, is depicted in Fig. 1. The high-level idea of their reduction is as follows: All gadgets are, in both the start and the target configuration, connected via the separation gadgets (and the auxiliary gadget). Because the robots within each separation gadgets have to move to reach their target position, they cannot maintain connectivity of the whole arrangement on their own, see Fig. 2. Therefore, robots located in the variable gadgets will have to perform this task in the single intermediate configuration. These gadgets are designed so that they can expand to the top or bottom, but not both at the same time, as illustrated in Fig. 3. As the unnegated clauses are at the top, and the negated ones at the bottom, the movement of the variable robots corresponds to an assignment of 1 or 0 to the respective variable.

Fig. 1
figure 1

Overview of the structure used for the reduction

Fig. 2
figure 2

The separation gadget

Fig. 3
figure 3

A variable gadget and schedules corresponding to assignments of 0 and 1

To show NP-hardness of the Labeled Connected Motion Planning Problem, we will provide a suitable labeling of the configurations and argue that the same construction works for the variant of labeled robot swarms.

Theorem 2

It is NP-complete to decide whether there is a schedule \(C_s \rightrightarrows _\chi C_t\) with makespan 2 for any pair \((C_s, C_t)\) of labeled connected configurations, with n robots.

Proof

We are given an instance \(\Pi = (C_s, C_t)\) of the Unlabeled Connected Motion Planning Problem that arises via the polynomial-time reduction from an instance of Planar Monotone 3Sat. We construct an instance \(\Pi _\ell = (C_s^\ell , C_t^\ell )\) of Labeled Connected Motion Planning by labeling the positions of the start and the target configuration, such that a schedule with makespan 2 for \(\Pi _\ell\) is also a schedule for \(\Pi\).

We create the labeling as follows, using three different colors to indicate occupied positions in the start configuration (red), in the target configuration (dark cyan), and in both configurations (gray). First, the labeling for every gray position is identical in both configurations, \(C_s^\ell\) and \(C_t^\ell\). A makespan of 2 confines each robot’s movement to an area of small radius. Projecting this radius onto any red position in the clause/auxiliary gadgets, the bridges and the variable gadgets of \(\Pi\), leaves only a single dark cyan position in range. These red-cyan pairs get the same labeling in \(C_s^\ell\) and \(C_t^\ell\), respectively. In the separation gadget there is a red position with two possible dark cyan positions in range, see Fig. 4. However, only one of these admits a feasible matching of all positions, i.e., the labeling is also unique in these separation gadgets. Due to the unique labeling within each gadget, it is straightforward to observe that there is a schedule with a makespan of 2 (implying that there are two different schedules for the variable gadget due to the two possible assignments) realizing the reconfiguration given by the labeling. Because the labeling is unique, the schedule for \(\Pi _\ell\) yields a schedule for \(\Pi\). Hence, we conclude that the labeled variant is as least as hard as the unlabeled one.

Fig. 4
figure 4

For the separation gadget, there is only one feasible matching. The dotted lines indicate the range of motion for the central red robot (Color Figure online)

Together with Corollary 1, this completes the proof. \(\square\)

As a consequence, even approximating the makespan is NP-hard: If no schedule of makespan 2 is found, then the makespan is at least 3.

Corollary 2

It is NP-hard to compute for a pair of labeled connected configurations \(C_s\) and \(C_t\) with n robots, a stable schedule that transforms \(C_s\) into \(C_t\) within a constant of \((\nicefrac {3}{2}-\varepsilon )\) (for any \(\varepsilon >0\)) of the minimum makespan.

3 Lower bound on stretch factor

We show a lower bound of \(\Omega (\sqrt{n})\) on the stretch factor. For this, we consider the pair of labeled connected configurations \((C_s,C_t)\) shown in Fig. 5a, both consisting of n robots. The difference between both configurations is that adjacent robots need to swap their positions. Thus, the diameter of \((C_s,C_t)\) is \(d = 1\). Because swaps are not allowed within the underlying model, some robots have to move orthogonally. It is easy to see that a single transformation allows for at most two robots to move orthogonally without disconnecting the configuration. A crucial insight is that each of these robots can realize at most one swap in parallel.

Fig. 5
figure 5

Pairs of robots must swap their positions (a), which can only be realized by schedules using moves that involve all robots (b)

Theorem 3

There are pairs of labeled connected configurations \(C_s\) and \(C_t\) with n robots, so that every schedule \(C_s \rightrightarrows _\chi C_t\) has a stretch factor of at least \(\Omega (\sqrt{n})\).

Proof

Consider a start configuration consisting of n robots arranged in a straight line, and a target configuration that arises by swapping each adjacent pair of robots. This pair of configurations has a diameter of \(d=1\), with a total of \(\nicefrac {n}{2}\) swaps. A minimum makespan may be achieved by rearranging adjacent robots in parallel. This parallelism is limited by the rate at which robots can move orthogonally to the linear arrangement, see Fig. 5b.

For some \(\lambda \in \{0,\dots ,\lceil \nicefrac {n}{2}\rceil \}\), the process of freeing \(2\lambda\) robots out of the line such that they can navigate along the configuration freely would take a total of \(\lambda\) transformation steps. With each free robot we can reduce the number of swaps of the remaining line by 1 in a constant number of steps. Therefore, realizing all swaps takes at least \(\Omega (\nicefrac {n}{\lambda })\) transformation steps, resulting in a total makespan of \(\Omega (\lambda + \nicefrac {n}{\lambda })\). This is asymptotically minimal for \(\lambda =\sqrt{n}\), resulting in a makespan of at least \(\Omega (\sqrt{n})\). Because of the diameter \(d=1\), this implies that any schedule has stretch at least \(\Omega (\sqrt{n})\). \(\square\)

4 Preparing global movement locally

In this section we introduce a preliminary result that hinges on exploiting a global support structure that provides us with powerful local reconfiguration routines.

Our problem setting of Labeled Connected Coordinated Motion Planning naturally permits efficient parallelization by decomposition of the underlying grid into disjoint regions of comparable size, enabling us to perform operations in all of them simultaneously.

As an important constraint, we observe that these regions should be strongly connected – in most scenarios, a robot must be able to move efficiently from one region to another in order to reach their target position. Therefore, we seek to find a partition that allows for both high parallelization and high interconnectivity between these disjoint regions. This concept was previously exploited for in-place reconfiguration of rectangular arrangements of robots by Demaine et al. [17], who combined a grid-based partition and the so-called RotateSort algorithm for efficient reconfiguration. To this end, they define a grid that scales with the diameter d of the input configuration to partition the configuration into disjoint tiles, each of which is an \(\mathcal {O}(d)\times \mathcal {O}(d)\) square of robots. The resulting partition of the grid space is what we call an \(\mathcal {O}(d)\)-tiling, as shown in Fig. 6a.

Fig. 6
figure 6

Tilings and tiled configurations. In (a), we see a configuration, a 7-tiling, and its boundary regions. A valid tiled configuration can be seen in (b), alongside an invalid one in (c) with a missing tile boundary highlighted in orange

Fig. 7
figure 7

We exploit two preliminary results: RotateSort, i.e., Lemma 1 can be applied to sort rectangular regions such as in (a). For unlabeled tiled configurations, Lemma 2 allows us to modify the interior regions, as shown in (b)

We note their use of RotateSort within these tiles, as we will later apply it to a similar effect. See Fig. 7a for an illustration of its capabilities.

Lemma 1

(RotateSort) Let \(C_s\) and \(C_t\) be two labeled configurations of an \(n_1 \times n_2\) rectangle with \(n_1 > n_2 \ge 2\). We can compute in polynomial time a schedule \(C_s\rightrightarrows _\chi C_t\) with makespan \(\mathcal {O}(n_1+n_2)\).

Prior research on unlabeled robots under connectivity constraints employs a support structure along tile-based subdivisions of the plane to maintain connectivity. As our work involves a similar support structure, we define the following terms. The boundary of a tile is composed of the grid positions directly adjacent to the outer edge. Analogously, the interior positions are the remaining positions within the tile region. The scaffold of a tiling is the union of all boundaries of its non-empty tiles. As these are the positions that we want our support structure to occupy, we say that a tiled configuration is a connected configuration whose silhouette is a subset of the given tiling and a superset of its scaffold. This concept is visualized in Fig. 6b, c.

Fekete et al. [24] obtained the following result for unlabeled reconfiguration under connectivity constraints.

Lemma 2

Let \(C_s\) and \(C_t\) be two unlabeled \(\mathcal {O}(d)\)-tiled configurations such that \(C_s\) and \(C_t\) contain the same number of robots in the interior of each tile T. We can compute in polynomial time a schedule \(C_s\rightrightarrows _\chi C_t\) with makespan \(\mathcal {O}(d)\).

This result employs the reachability of a canonical intermediate structure within tiles i.e, an intermediate configuration derived only from the number of robots within each tile. We will briefly reference this in the following section. Intuitively, this intermediate configuration is obtained by a monotone, triangle-based compaction of the interior robots into one of the tile’s corners, as illustrated in Fig. 7b.

Building on these two preliminary results, we now construct a subroutine that can be used to transform all tiles of a tiled configuration within a makespan of \(\mathcal {O}(d)\).

Theorem 4

For any two labeled tiled configurations \(C_s\) and \(C_t\) for which each tile consists of the same robots, we can compute in polynomial time a stable schedule of makespan \(\mathcal {O}(d)\) that transforms one into the other.

In the remainder of this subsection we provide three results which, in combination, yield a proof of Theorem 4. To this end, we first show that the interior of a tile can be reconfigured arbitrarily, followed by a description of how this can be adapted to include the reconfiguration of the boundary, as well as arbitrary exchanges of robots between a tile’s interior and its boundary.

4.1 Reconfiguring the interior

We start by showing how the interior of a tile can be transformed arbitrarily. As moves are reversible, proving that a canonical configuration is reachable is sufficient. In our case, this configuration will be a compact subset of a square. In order to obtain such a configuration, we first apply a direct result of Lemma 2, which is that we can modify the silhouette of a tile’s interior configuration arbitrarily in \(\mathcal {O}(d)\). Rather than stopping at the previously described canonical configuration based on triangular shapes, we deterministically create a configuration with a square-like silhouette. We arrive at the following corollary for k interior robots.

Corollary 3

For any two connected configurations consisting of an immobile \(m \times m\) boundary for \(m\in \mathcal {O}(d)\) and \(k\le (m-2)^2\) interior robots, there is a stable schedule of makespan \(\mathcal {O}(d)\) that moves all interior robots into a subset of \(\big \lceil \sqrt{k}\big \rceil \times \big \lceil \sqrt{k}\big \rceil\) positions.

This process is visualized in Fig. 8. Using the structural results from Lemma 2, we transform an initial interior configuration \(C_s\) into a square-like silhouette \(C_\Box\). Due to the relationship of any two sequential square numbers, i.e., \(x^2-(x-1)^2=2x-1\), at most \(2\big \lceil \sqrt{k}\big \rceil - 1\) nodes within the \(\big \lceil \sqrt{k}\big \rceil \times \big \lceil \sqrt{k}\big \rceil\) square may end up unoccupied. We form the silhouette in a manner such that these robots are missing within the top two rows, from an arbitrary but fixed end. In a final step concerning the interior, we now argue that we can efficiently exchange the interior robot’s positions in the silhouette, as indicated in Fig. 8.

Fig. 8
figure 8

We obtain the canonical square-like silhouette \(C_\Box\) in a tile’s interior using the canonical triangle structure from Lemma 2, which we can then reorder arbitrarily

Lemma 3

The interiors of all tiles in a labeled tiled configuration that consists of \(m\times m\)-tiles with \(m\in \mathcal {O}(d)\) may be locally rearranged by a schedule of makespan \(\mathcal {O}(d)\).

Proof

We prove this by means of a process that can be applied to all tiles in parallel. Consider an arbitrary tile that has \(k\in [6,(m-2)^2]\) interior robots. We first employ Corollary 3 to create the square-like interior silhouette \(C_\Box\). For k robots, this is a subset of a \(\big \lceil \sqrt{k}\big \rceil \times \big \lceil \sqrt{k}\big \rceil\) square. There now exist two cases as follows.

If the interior silhouette is a fully occupied rectangle, we can apply Lemma 1 to this rectangle to rearrange the robots in \(\mathcal {O}(d)\).

Otherwise, we cover the occupied area by two rectangles, one of maximal width in the “lower” portion, and one of maximal height in the “taller” segment, as indicated by the cuts through \(C_\Box\) in Fig. 8. We can then reorder the robots by applying Lemma 1 multiple times as follows. First, we ensure that the robots for the incomplete top row are located in the base of the taller rectangle, by reordering the lower rectangle. Then, a second application to the enclosing section ensures that the incomplete row is correctly configured. For the case of a 1-wide rectangle, the empty position next to the robot may be considered a “pseudo-robot” and the operation may be applied to the corresponding 2-wide area instead. Finally, a third repetition ensures that the lower rectangle is also correctly ordered. Overall, this yields a makespan of \(\mathcal {O}(d)\).

By appropriately reordering the robots in the silhouette of \(C_\Box\) as above, before applying Corollary 3 in reverse, we have the means to create an arbitrary target configuration of the given tile’s interior. Note that the necessary ordering of robots can be computed by a simple matching of positions in the silhouette of \(C_\Box\) with respect to the start- and target arrangements. This concludes our proof of Lemma 3. \(\square\)

Note that the case of \(k \in [1,5]\) is excluded from the proof, but trivial schedules utilizing the existence of the boundary may be determined, allowing for arbitrary rearrangement of the interior.

4.2 Reconfiguring the boundary

We now show that the scaffolding structure can be locally modified in-place, i.e., without changing its silhouette at any point of the process.

Lemma 4

The boundaries of all tiles in a labeled tiled configuration that consists of \({m\times m}\)-tiles with \(m\in \mathcal {O}(d)\) may be locally reordered by a schedule of makespan \(\mathcal {O}(d)\).

Proof

We must allow adjacent tiles to take turns in utilizing the shared portion of the boundary as a processing area for themselves. As the dual graph of the tiling is bipartite, the tiles can be partitioned into two disjoint sets, each of which can be reconfigured in parallel. On a high level, we achieve this by repeatedly gathering and sorting \(m-2\) robots at a time in this shared section of the boundary, incrementally arranging the scaffold into its target state.

Consider now a single tile that is permitted to employ part of one neighbor’s boundary. We can pick an arbitrary continuous sequence of \(m-2\) robots from the target configuration and start gathering the corresponding robots in the “borrowed” section of the neighbor tile’s scaffold. To this end, we repeatedly shift the robots along the boundary by \(m-2\) units, before applying Lemma 1 to switch desired robots to their target position in the sorted sequence in \(\mathcal {O}(m)\) transformations. After at most five iterations of this process, we have obtained the desired sorted sequence, which we can then reinsert to the boundary of our tile at an appropriate location.

This process must be repeated up to four more times to obtain an arbitrarily reodered boundary configuration and restore the neighbor’s boundary to its original state. For an illustration of a single iteration, see Fig. 9. \(\square\)

Fig. 9
figure 9

An illustration of the first iteration of the boundary reconfiguration approach: We repeatedly apply RotateSort to the top boundary and then rotate by \(m-2\) units to gather and sort a sequence of robots (red), ignoring the rest (here: uniform green) (Color Figure online)

4.3 Exchange between interior and boundary

Having proven that we can freely rearrange both the interior and the boundary individually, we now prove that we can locally exchange agents between the interior and boundary of a tile.

Lemma 5

The interiors and boundaries of all tiles in a labeled tiled configuration that consists of \(m\times m\)-tiles with \(m\in \mathcal {O}(d)\) can locally exchange any number of agents by a schedule of makespan \(\mathcal {O}(d)\).

Proof

We place at most \(4m-16\) agents that need to be swapped into the boundary adjacent to the respective boundary agents that need to swap into the interior using Lemma 3. Subsequently, we apply Lemma 1 to the relevant areas. As the boundary consists of \(4m-4\) agents, at most two repetitions of this process can replace every agent on the boundary. This approach may be applied to all tiles simultaneously. \(\square\)

5 Schedules of constant stretch

In this section, we describe an approach to determine stable schedules with constant stretch for labeled configurations of sufficient scale, which we define as follows. A configuration C is c-scaled, if its silhouette is the union of \(c \times c\) squares of robots that are aligned edge-to-edge, i.e., aligned with a \(c\times c\) grid. The scale of a configuration C is the maximal c such that C is c-scaled.

In the previous section, we introduced tilings and demonstrated the powerful effect of a tiling-based scaffold on local reconfiguration capabilities. While we know how to exploit these tilings for local movement, we so far lack the tools to build a scaffold and therefore obtain a tiled configuration. We now investigate a class of configurations based on scale, for which we can efficiently build and make use of a scaffold structure for coordinated motion planning. In particular, we show the following result.

Theorem 5

There is a constant \(c^*\) such that for any pair \((C_s,C_t)\) of labeled connected configurations with n robots each and scale of at least \(c^*\), there exists a constant stretch schedule \(C_s\rightrightarrows _{\chi } C_t\).

Note that we do not focus on minimizing the constant \(c^*\) but rather argue its existence. An intuitive motivation of this goal is given by Theorem 3, which demonstrates that for instances of scale \(c=1\), constant stretch schedules may not exist.

Our approach works in different phases. Rather than proving Theorem 5 directly, we prove that each of the phases can be realized by a schedule of constant stretch.

5.1 Overview of the algorithm

We now give a high-level outline of the purpose of the different phases; an overview is depicted in Fig. 10. Based on preprocessing steps (Sect. 5.2) in which we determine the scale c and the diameter d of the configurations, we build a tile-based scaffolding structure (Sect. 5.3) to support connectivity during the reconfiguration. The actual reconfiguration consists of shifting robots between adjacent tiles based on flow computations (Sects. 5.45.5), and reconfiguring tiles in parallel (Sect. 5.6). Then, deconstructing the scaffold yields the target configuration.

Fig. 10
figure 10

Overview of our algorithm, consisting of the phases (1) Preprocessing, (2) Scaffold construction, (3) Interior flow computation and realization, (4) Boundary flow computation and realization, (5) Local tile reconfiguration, followed by (6) Scaffold deconstruction (not shown here)

On a technical level, the phases can be summarized as follows.

  • Phase 1—Preprocessing: Compute scale c, diameter d, a tiling \(\mathcal {T}_1\) of the grid into squares of size \(cd\times cd\), and a larger tiling \(\mathcal {T}_5\) covering all non-empty tiles of \(\mathcal {T}_1\).

  • Phase 2—Scaffold construction: Construct a scaffold along the edges of \(\mathcal {T}_5\), resulting in a tiled configuration, guaranteeing connectivity during reconfiguration.

  • Phase 3—Interior flow: Create a flow graph \(G_{\mathcal {T}_5}\) to model the movement of interior (non-scaffold) robots between adjacent tiles of \(\mathcal {T}_5\). Convert the flow into a series of moves, placing all interior robots in their target tiles.

  • Phase 4—Boundary flow: Analogously to Phase 3, create a flow for the robots that were used to construct a scaffold in Phase 2. Subsequently, move all of those robots into the boundary of their target tiles.

  • Phase 5—Local tile reconfiguration: Locally reconfigure all tiles of the resulting tiled configuration.

  • Phase 6—Scaffold deconstruction: Reverse of Phase 2.

In the remainder of this section we provide details of the different phases.

5.2 Phase 1: Preprocessing

Consider the start and target configurations \(C_s\) and \(C_t\). Let c refer to the minimum of the two configurations’ scales and the as-of-now undetermined constant \(c^*\), and let d be the diameter of the pair \((C_s, C_t)\). Note that, since we assume \(c\ge c^*\), this allows us to treat c as a constant from this point onwards. We say that two configurations overlap, if they have at least one occupied position in common. For the remainder of the paper, without loss of generality, assume that the configurations overlap in at least one position. Otherwise, we simply move the target configuration, such that it overlaps with the start configuration. This can be done in \(\mathcal {O}(d)\) steps, and results in a new diameter \(d' \le 2d\).

We then define a cd-tiling of the underlying grid, which we call \(\mathcal {T}_1\). Let \(\mathcal {T}_1(C_s)\) and \(\mathcal {T}_1(C_t)\) refer to the set of tiles in \(\mathcal {T}_1\) that contain robots in \(C_s\) and \(C_t\), respectively. The tiling and respective non-empty tiles can be seen in Fig. 11b, c. Before constructing our scaffold structure, we we introduce a basic tiling, using a finite set of tiles. As we know that each robot is initially within d units of its target position, we have a particular interest in the tiles of \(\mathcal {T}_1(C_s)\) and \(\mathcal {T}_1(C_t)\), as well as directly adjacent tiles. To describe this relationship, let the k-neighborhood \(N_k[\mathcal {T}']\) of a set of tiles refer to all tiles of the same tiling that have \(L_\infty\) distance at most k to any member of \(\mathcal {T}'\). An example of a 1-neighborhood can be seen in Fig. 11c, where the set \(N_1[\mathcal {T}_1(C_s)\cup \mathcal {T}_1(C_t)]\) is marked in gray. We observe that this is a subset of both \(N_2[\mathcal {T}_1(C_s)]\) and \(N_2[\mathcal {T}_1(C_t)]\), because \(\mathcal {T}_1(C_s)\) and \(\mathcal {T}_1(C_t)\) are fully contained in each other’s 1-neighborhoods. This relationship is also depicted in Fig. 11c.

Fig. 11
figure 11

Using the scale c and diameter of the instance (a), we define the tiling \(\mathcal {T}_1\) (b). This tiling is further partitioned into \(5\times 5\) squares, c forming \(\mathcal {T}_5\) based on \(T_1,\dots ,T_\kappa\) (the small squares). Those tiles of \(\mathcal {T}_5\) which contain the neighbors (in gray) of non-empty start and target tiles (hatched red and green, respectively) of \(\mathcal {T}_1\) will now form the basis of our scaffold (Color Figure online)

In Sect. 4, we discussed previous work that employs a scaffold based on \(\mathcal {O}(d)\)-tilings to allow for efficient connected reconfiguration of unlabeled robots. We take a similar approach, effectively drawing robots from either the interior or the 2-neighborhood of any given tile, in order to construct its boundary. However, labeled robots have individual target positions that we must take into account when constructing a scaffold. As a result, we consider an additional, higher-resolution tiling that allows us to ensure that the diameter of the instance does not increase beyond a constant factor due to scaffold construction. A detailed description of, and argument for this relationship will be provided in the next section.

Based on the non-empty tiles in \(\mathcal {T}_1\), we compute a higher-resolution tiling of the relevant area by a grid of \(5\times 5\) squares of cd-tiles. Let \(T_1, \dots , T_\kappa\) be a minimal set of tiles from \(\mathcal {T}_1\), such that the distance between any two of them is a multiple of 5 on both the x- and y-axis, and \(N_1[\mathcal {T}_1(C_s)\cup \mathcal {T}_1(C_t)]\subseteq N_2[T_1, \dots , T_\kappa ]\).

This directly provides us with the relevant tiles \(\mathcal {T}_5:= \{N_2[T_1], \dots , N_2[T_\kappa ]\}\), upon which we will base our scaffold and robot motion. Both \(\mathcal {T}_5\) and \(T_1, \dots , T_\kappa\) can be seen in Fig. 11c. We conclude our preprocessing and move on to the construction of an applicable tiled configuration from \(C_s\).

5.3 Phase 2: scaffold construction

Having determined a cover of \(C_s\) and \(C_t\) in shape of the 5cd-tiling \(\mathcal {T}_5\), a scaffold spanning this cover is to be constructed. For this purpose, a robot is to be placed at every boundary position in \(\mathcal {T}_5\), which requires \((5\cdot 4cd-4)\) robots per tile. We show that there are sufficiently many robots to build the scaffold. We refer to the locally available material for a given tile \(T\in \mathcal {T}_5\) as the set of robots contained within T itself and its immediate neighborhood \(N_1[T]\) over \(\mathcal {T}_5\). As \(\mathcal {T}_5\) is a cover of \(N_1[\mathcal {T}_1(C_s)\cup \mathcal {T}_1(C_t)]\), we can assume that every tile \(T\in \mathcal {T}_5\) contains at least one \(T'\in N_2[\mathcal {T}_1(C_s)]\). We can thus guarantee sufficient locally available material for the boundary of T if we can show that it exists in the 4-neighborhood of any such \(T'\).

In the context of the scaffold construction, we therefore distinguish donor and recipient tiles. A donor tile contains sufficiently many robots to construct a boundary around itself and all eight immediate neighbors; any other tile is a recipient. The following lemma shows that every tile of \(\mathcal {T}_5\) is either a donor, or an immediate neighbor of an appropriate donor. These terms will not be used in later sections of the paper, as their concepts are only relevant to this phase of the algorithm.

Lemma 6

There is a constant c, such that for all \(C_s\) and \(C_t\) with scale at least c, there is sufficient locally available material to construct a scaffold of \(\mathcal {T}_5\).

Proof

Unless \(cd \in \Omega (\sqrt{n})\), we can assume that both the start and target configurations consist of more than a single tile in \(\mathcal {T}_1\); otherwise, the reconfiguration problem is trivial. Without loss of generality, we assume that for any given non-empty tile \(T\in \mathcal {T}_1\), there exist robots outside of its 1-neighborhood in \(C_s\). This implies the existence of a path of length at least cd that connects a position of T to those robots. Such a path has to be contained in a union of fully occupied pixels of size \(c\times c\) due to the scale of both configurations. We can employ a proof by Fekete et al. [24] to derive that at least one neighbor of T must contain no less than \(\nicefrac {(c^2 d)}{4}\) robots for \(c\ge 4\).

Because \(\mathcal {T}_5\) is a cover of the 2-neighborhood of non-empty tiles over \(\mathcal {T}_1\), we extend the above finding to conclude that every tile in \(\mathcal {T}_5\), or one of its neighbors, contains at least \(\nicefrac {(c^2 d)}{4}\) robots. We additionally note that the respective robots are located within the 4-neighborhood of each recipient tile over \(\mathcal {T}_1\). This is of particular relevance, as these robots will remain within the 1-neighborhood over \(\mathcal {T}_5\) for any target configuration.

A worst-case scenario has a tile donating to all eight of its neighbors, so it must contain at least \(9(5\cdot 4cd-4)\) robots. We can guarantee sufficient material based on the above relationship, starting from a lower bound of \(\nicefrac {(c^2 d)}{4} \ge 9(20cd-4) \Leftrightarrow c \ge 720\). As this proof is the only portion of our algorithm that hinges on scale, the constant \(c^*\) from Theorem 5 is no greater than 720.\(\square\)

The scaffold construction now takes place in the following three subphases.

  • Phase 2.1: Parallel construction of all donor boundaries.

  • Phase 2.2: Mapping recipients to donors appropriately.

  • Phase 2.3: Construction of recipient boundaries.

Lemma 7

Constructing the scaffold (i.e., Phase 2 of our approach) takes no more than \(\mathcal {O}(d)\) transformations.

Proof

We show this by providing an overview of each subphase, and arguing that no subphase takes more than \(\mathcal {O}(d)\) transformations.

For Phase 2.1, consider a donor tile \(T\in \mathcal {T}_5\). As each donor’s interior contains sufficiently many robots to build its own boundary, we can employ a very simple strategy to construct their boundaries. Within any such tile, we assign every robot a priority based on the length of the shortest path in \(C_s\) that connects the robot to another robot that is adjacent to an empty position on the boundary. Until T’s boundary is fully occupied, we repeatedly push along the respective shortest path of a robot with maximal priority in T, adding one robot to the scaffold structure, as depicted in Fig. 12a.

Fig. 12
figure 12

The first and final subphases of the scaffold construction visualized. Tiles with ongoing scaffold construction are highlighted in blue, while dashed boundaries indicate the state of the scaffold after each phase’s termination (Color Figure online)

This approach does not cause disconnections in the configuration, as it already has been shown for the unlabeled problem variant. Because the scaffold consists of \(20cd-4\) robots per tile, Phase 2.1 completes after \(\mathcal {O}(d)\) steps.

By Lemma 6, we already know that an applicable donor exists for each recipient tile. Therefore, Phase 2.2 simply focuses on determining an exact mapping between donors and recipients, while ensuring that the correct robots are distributed in the final subphase. We achieve this by solving a flow problem in an extended version of the dual graph of \(\mathcal {T}_5\), i.e., a graph in which each vertex corresponds to a tile, and two vertices share an edge if the corresponding tiles are horizontally, vertically, or diagonally adjacent, as indicated in Fig. 13b. We model the necessary assignment of robots from donors to recipients as a flow network with source vertex \(v_{s}\) and sink vertex \(v_{t}\). A maximal flow in this network can be decomposed into a set of (augmenting) paths that connect one robot from a donor tile to one adjacent recipient tile. This means that each path has the form \((v_s, r, R, v_t)\), with r being a robot currently located in a donor tile \(D\in \mathcal {T}_5\) and a recipient tile \(R\in \mathcal {T}_5\). All edges of type \((v_s, r)\) or (rR) have capacity one. Conversely, every edge \((R, v_t)\) has capacity \(20cd-4\), see Fig. 13.

Fig. 13
figure 13

For the scaffold construction, we may have to move robots to some \(T\in \mathcal {T}_1\) that is empty, but in \(N_2[\mathcal {T}_1(C_s)]\), see the marked grey tile in (a). Sufficient robots exist in \(N_2[T']\) (red) for \(T'\in N_2[T]\), i.e., in \(N_4[T]\) (green). As robots only need to travel between adjacent tiles of \(\mathcal {T}_1\) (b), we can select them by solving a flow problem (c) (Color Figure online)

Because there is a sufficient number of robots in each recipient tile’s vicinity, a maximal flow fully utilizes all edges that connect recipients to the sink vertex \(v_t\). The selection of edges between robots and recipients thus determines an applicable assignment. Note that, due to Lemma 7, we use robots to build a scaffold for a recipient tile from its 4-neighborhood over \(\mathcal {T}_1\) of an applicable donor. As shown in Fig. 13a, b, this implies that robots from the donor’s “far side” (consisting of the \(\mathcal {T}_1\) tiles where robots may seek to leave into the opposite direction) are not used; otherwise, they would move too far away from their target location.

As the construction scheme relies solely on the silhouette of a donating tile, we can easily determine to which adjacent recipient a robot at any given position in a donor tile will be sent. This includes scaffold locations near the boundary between two tiles that may have been occupied by robots with target neighbors opposite to the recipient tile. We make use of the concepts of Theorem 4 to gather specific robots from a donor for each recipient, again taking \(\mathcal {O}(d)\) transformations. Note that, while Theorem 4 may not be applicable directly, since Lemma 4 requires a valid tiled configuration, we can employ robots from the donors’ interior as substitute filling for the necessary sorting area. In practice, this corresponds to building a second, immediately adjacent boundary inside each donor tile.

Phase 2.3 can then safely proceed to push robots from a donor tile into the boundary of adjacent recipients, using a variant of the method from Phase 2.1. We consider \(3\cdot 3\) classes of tiles in \(\mathcal {T}_5\), based on each tile’s anchor position modulo 15cd and construct the boundaries of all recipient tiles in a class in parallel, see Fig. 12b. For the movement of each robot, we map robots from the interior of a donor tile to a vertex on the respective recipient’s boundary. Based on the previously discussed priority, robots are now pushed along their boundary and onto boundary positions of the adjacent recipient. Once this process terminates, we have constructed a scaffold structure around all tiles of the cover \(\mathcal {T}_5\). This takes \(20cd-4\) transformations per tile class, so we conclude that Lemma 7 holds. \(\square\)

With the help of this global support structure, connectivity is ensured during the actual reconfiguration. It remains to show how we shift robots between tiles, and reconfigure robot arrangements within the constructed scaffold. The latter has already been described in Sect. 4, so we only need to describe how to relocate robots between tiles.

5.4 Phase 3: interior flow

This is modeled as a supply–demand flow for interior robots in three subphases:

  • Phase 3.1: Interior flow computation.

  • Phase 3.2: Interior flow partition.

  • Phase 3.3: Interior flow realization.

Note that we focus on the transfer of interior robots in this section. A similar approach is used to model the flow for boundary robots, see Sect. 5.5. We proceed by introducing some fundamental terminology relating to the supply–demand flow in question.

We know that, after the scaffold construction completes, any robot is located within the 1-neighborhood of the tile containing its target position. The desired exchange of robots between tiles is represented as a supply–demand flow \(G_{\mathcal {T}_5}:=~(\mathcal {T}_5, E_{\mathcal {T}_5}, f _{\mathcal {T}_5})\) over \(\mathcal {T}_5\), in which every tile is adjacent to those in its 1-neighborhood. The flow value of an edge \(f _{\mathcal {T}_5}(e)\) corresponds to the cardinality of the set of robots that need to move from one tile into another. For simplicity, we consider the number of robots in the flow model, rather than the specific robots themselves. Clearly, the flow on any given edge is bounded from above by the interior space of the tiles, i.e., \((5cd-2)^2\) robots.

A tile \(T\in \mathcal {T}_5\) is a source (sink) if and only if the sum of flow values of incoming edges is smaller (larger) than the sum of flow values of outgoing edges. Otherwise, we call T flow-conserving. The difference of these sums is called the supply and demand at sources and sinks, respectively.

If the flow value of every edge within a given flow graph is bounded from above by some value \(\sigma\), we refer to it as a \(\sigma\)-flow, e.g., \(G_{\mathcal {T}_5}\) is a \(\mathcal {O}(d^2)\)-flow. Additionally, we define an (ab)-partition of a flow graph as a set that contains b many a-flows that sum up to the original flow.

We say that a schedule realizes a flow graph \(G_{\mathcal {T}_5} = (\mathcal {T}_5, E_{\mathcal {T}_5}, f _{\mathcal {T}_5})\) if the number of robots moved along any directed edge \(e\in E_{\mathcal {T}_5}\) is exactly \(f _{\mathcal {T}_5}(e)\). By construction, the realization of \(G_{\mathcal {T}_5}\) never requires us to fill a tile over capacity, or to remove robots from an empty tile, as this would imply an invalid start or target configuration.

Lemma 8

It is possible to efficiently compute a stable schedule of makespan \(\mathcal {O}(d)\) that realizes \(G_{\mathcal {T}_5}\).

Having computed the flow graph \(G_{\mathcal {T}_5}\) as above, we perform additional preprocessing steps before handling the remaining two subphases, as outlined in the following sections, culminating in a proof of Lemma 8.

5.4.1 Phase 3.1: interior flow preprocessing

Our partition methods require a planar, unidirectional flow network. We can obtain both properties by eliminating bidirectional and crossing edges in the flow graph \(G_{\mathcal {T}_5}\), see Fig. 14 for the underlying idea. Note that this process may triple the maximum flow value over every edge, resulting in a \(3(5cd-2)^2\)-flow.

Fig. 14
figure 14

Preprocessing steps remove both crossing and bidirectional edge (a + b), by applying RotateSort locally to swap robots through the boundary (c)

Removing crossing diagonal edges Crossing edges can only occur between two diagonal edges of adjacent source tiles \(u,v\in G_{\mathcal {T}_5}\). To remove such a crossing, it suffices to eliminate one of the two edges by exchanging robots between u and v. We refer to Fig. 14a for an illustration. Let w be a common neighbor of u and v, and consider without loss of generality that there is a diagonal edge (uw) that has to be eliminated. To this end, we simply exchange robots between the source tiles uv in such a way that the flow \(f _{\mathcal {T}_5}((u,w))\) is rerouted through v. For this, we exchange the robots in the interior of u that want to end up in w with robots of v that either want to stay in v or has their target location in w, too.

This increases the flow on the edges (uv) and (vw) by at most \((5cd-2)^2\). Because there are only two possible tiles that are diagonal adjacent to v and adjacent to w, this can occur only two times. Note that by removing diagonal edges, no new diagonal edge can occur. After the removal of all crossing edges, \(G_{\mathcal {T}_5}\) is a \(3(5cd-2)^2\)-flow.

Removing bidirectional edges A bidirectional edge between two adjacent tiles \(u,v\in G_{\mathcal {T}_5}\) can be removed by exchanging robots between u and v that want to switch to the other tile until one of the edges disappears. See Fig. 14b for an illustration.

5.4.2 Phase 3.2: interior flow partition

Having obtained a planar flow graph, we observe the existence of two types of movement; tiles may exchange robots in a circular motion to move “misplaced” robots into their target tiles, without changing the number of robots in the tiles involved, or the number of robots in a tile may need to change, as the target configuration requires increased density in its vicinity.

We employ two existing results for flow partitioning that deal with the two cases disjointly. To this end, we split \(G_{\mathcal {T}_5}\) into two distinct subproblems, by partitioning it into two flows \(G_\rightarrow\) and \(G_\bigcirc\), one being acyclic and the other totally cyclic, see Fig. 15.

Fig. 15
figure 15

A decomposition of a flow graph into its acyclic and cyclic components

Lemma 9

It is possible to efficiently compute a partition of \(G_{\mathcal {T}_5}\) into an acyclic component \(G_\rightarrow\) and a totally cyclic component \(G_\bigcirc\).

This is a standard result from the theory of network flows; e.g., see the books by Korte and Vygen [33] or by Ford and Fulkerson [26].

Partitioning the cyclic flow For the case of configurations that do not have to be connected, Demaine et al. [17] considered tiles of side length 24d. Thus, they obtained a totally cyclic flow graph \(G_\bigcirc\) with an upper bound of \(24 d \cdot 24d = 576d^2\) for the flow value of each edge. Furthermore, they showed that it is possible to compute a \((d,\mathcal {O}(d))\)-partition of \(G_\bigcirc\). In our case, we have to keep configurations connected, resulting in tiles of side length cd. We extend their peeling algorithm to a broader, parameterized version.

Lemma 10

A \((d,\mathcal {O}(d))\)-partition of the totally cyclic \((k\cdot d^2)\)-flow \(G_\bigcirc\) for \(k\in \mathbb {N}\) into totally cyclic flows can be computed efficiently.

Proof

Consider a tiled configuration \(C'\) of scale c and let n denote the total number of robots. The following method yield a \((d,\mathcal {O}(d))\)-partition of \(G_\bigcirc\).

We start with computing a (1, h)-partition \(\mathbb {P}_\bigcirc\) of \(G_\bigcirc\). The number of flows h is bounded from above by the total number of robots n, as each robot may only contribute to a single cycle. If any cycle intersects itself, it is subdivided into smaller, non-intersecting cycles. Subsequently, \(\mathbb {P}_\bigcirc\) can be divided into two classes of cycles based on cycle orientation. Let \(\mathbb {P}_\circlearrowright\) refer to the clockwise cycles, and \(\mathbb {P}_\circlearrowleft\) to the counterclockwise cycles of \(\mathbb {P}_\bigcirc\).

Subsequently, we compute a (1, h)-partition using the sets \(\mathbb {P}_\circlearrowright\) and \(\mathbb {P}_\circlearrowleft\). The resulting subsets \(\mathbb {P}_\circlearrowright ^1 \cup \mathbb {P}_\circlearrowright ^2 \cup \mathbb {P}_\circlearrowleft ^1 \cup \mathbb {P}_\circlearrowleft ^2\) are constructed in a fashion such that two cycles u and v from the same subset share the same orientation and are either edge-disjoint or nested within another, where we write \(u \sqsubseteq v\) if v contains u.

Such a partition may be constructed using the geometric peeling algorithm, depicted in Fig. 16. Their approach handles each \(\mathbb {P}_X\in \{\mathbb {P}_\circlearrowright , \mathbb {P}_\circlearrowleft \}\) separately. Considering the union of inner-bound areas A of all cycles in \(\mathbb {P}_X\), a 1-circulation around the outer edges of each component of A is identified, removed from \(\mathbb {P}_X\), and added to the set \(\mathbb {P}_X^1\). Simultaneously, inversely oriented 1-circulations around any holes within A are removed from \(\mathbb {P}_X\), and added to the set \(\mathbb {P}_X^2\), see Fig. 16a. This process is repeated until \(\mathbb {P}_X\) is fully decomposed into the two sets \(\mathbb {P}_X^1\) and \(\mathbb {P}_X^2\).

Fig. 16
figure 16

Iterations of the peeling algorithm. The outer loops that go into a set \(\mathbb {P}_X^1\) are marked red and the inner boundary loops of set \(\mathbb {P}_X^2\) are marked in blue (Color Figure online)

Finally, each \(\mathbb {P}_X^j\in \{\mathbb {P}_\circlearrowright ^1, \mathbb {P}_\circlearrowright ^2, \mathbb {P}_\circlearrowleft ^1, \mathbb {P}_\circlearrowleft ^2\}\) is now partitioned into \(\mathcal {O}(d)\) sets that form one d-subflow of \(G_\bigcirc\) each.

As previously noted, any pair of cycles in \(\mathbb {P}_X^j\) is either edge-disjoint, or one of the cycles lies within the other. This property induces a forest \(F = (\mathbb {P}_X^j, E_F)\), as depicted in Fig. 16b, in which one cycle u is a child of another cycle v exactly if \(u\sqsubseteq v\) and there is no other cycle w such that \(u\sqsubseteq w\sqsubseteq v\).

Given such a forest, every vertex is labeled by its depth in \(F \bmod kd\). These labels are then used to construct \(\mathcal {O}(d)\) subflows \(\{G_{\bigcirc _1},G_{\bigcirc _2}, \dots \}\), each \(G_{\bigcirc _i}\) being the union of cycles with label i.

It only remains to be shown that every flow \(G_{\bigcirc _i}\), constructed by this algorithm, is a d-subflow of \(G_\bigcirc\). For this, consider any \(u,v\in \mathbb {P}_X^j\) such that the two cycles share a common edge e. By construction, one of the two cycles must lie within the other, so without loss of generality, assume that \(u\sqsubseteq v\). This implies that there exists a path from u to its root via v in F, with all cycles on the path between u and v sharing the edge e as well. As \(G_\bigcirc\) has all edges bounded from above by \(k\cdot d^2\), the cycles containing e lie on a path of length no more than \(k\cdot d^2\) in F. Thus, e has a weight of at most \(\nicefrac {(k\cdot d^2)}{(k\cdot d)} = d\) in every \(G_{\bigcirc _i}\), meaning \(G_{\bigcirc _i}\) is a d-flow. \(\square\)

Applying this algorithm to \(G_\bigcirc\) yields a \((d, \ell )\)-partition for \(\ell < 75c^2\cdot d = \mathcal {O}(d)\). As the elements of such a partition of \(G_\bigcirc\) add up to \(G_\bigcirc\) itself, its realization may now be reduced to the realization of all d-subflows.

Partitioning the acyclic flow We already computed a \((d,\mathcal {O}(d))\)-partition of \(G_\bigcirc\). As \(G_{\mathcal {T}_5} = G_\bigcirc + G_\rightarrow\), we still need to compute a \((d,\mathcal {O}(d))\)-partition of \(G_\rightarrow\) to obtain a \((d,\mathcal {O}(d))\)-partition of the entire flow \(G_{\mathcal {T}_5}\). In the context of unlabeled robots, Fekete et al. [24] proposed an algorithm for computing a \((\mathcal {O}(d^2), 28)\)-partition of \(G_\rightarrow\). Due to the much more complex situation of labeled robots, the underlying ideas need to be refined to provide an algorithm that guarantees the following.

Lemma 11

A \((d,\mathcal {O}(d))\)-partition of the acyclic \((k\cdot d^2)\)-flow \(G_\rightarrow\) for \(k\in \mathbb {N}\) into acyclic flows can be computed efficiently.

Proof

It is possible to compute a partition of \(G_\rightarrow = ( \mathcal {T}_5, E, f _{\mathcal {T}}^{\rightarrow })\) into 1-subflows, each being a path that connects a supply vertex to a demand vertex, simply by performing a decomposition of the flow. As \(G_\rightarrow\) is both planar and unidirectional, this means it may be viewed as a directed forest, with each component A containing a subset of the paths. The following process is then applied to each tree \(A\subseteq G_\rightarrow\) separately.

First, choose an arbitrary vertex of A as the root of the component. For any path \(P_i\) in A, its link distance refers to the minimal length of any path connecting a vertex of \(P_i\) to the root of A. Consider \((P_1, P_2, \dots )\) as sorted by link distance. Every path \(P_i\) is now greedily assigned to a set \(S_j\), such that the first edge \(e_1\) of \(P_i\) is not part of any other path in \(S_j\). These sets are shared over the components of \(G_\rightarrow\), and if no matching set exists for a path \(P_i\), a new set \(S_j:= \{P_i\}\) is created. As the maximum incoming degree of the head vertex of a directed edge is three in the setting of a grid graph, each edge of the graph may be contained in at most three paths of each set.

Once these sets are fully constructed, they are greedily partitioned into groups of \(\nicefrac {d}{3}\) sets \(\{G_{\rightarrow _1}, G_{\rightarrow _2}, \dots \}\). For each group \(G_{\rightarrow _i}\), a subflow \(f _{i}\) is created that maps an edge to the number of paths in \(G_{\rightarrow _i}\) that contain it. Because every edge can appear no more than three times within a set of paths \(S_j\) and each group contains \(\nicefrac {d}{3}\) sets, each \(f_i\) is a \((\nicefrac {d}{3}\cdot 3) = d\)-subflow of \(G_\rightarrow\).

It only remains to show that the constructed partition \(( G_{\rightarrow _1}, G_{\rightarrow _2}, \dots )\) contains at most \(75c^2 d = \mathcal {O}(d)\) subflows. As \(G_{\mathcal {T}_5}\) is initially bounded from above by the interior space of a tile, the substitution of diagonal edges leaves \(G_\rightarrow\) bounded from below by \(3(5cd-2)^2\). Suppose the described approach constructs \(75c^2 d\) many flows. This implies that the algorithm encountered a state with \(\lambda = 75c^2 d \cdot \nicefrac {d}{3} - 1\) existing sets \(S_1,\dots , S_\lambda\) and the current path \(P_i\) had to be assigned to a new set \(S_{\lambda +1}\). We conclude that each set \(S_1, \dots , S_\lambda\) contained a path \(P_j\) that included the first edge \(e_1\) of \(P_i\), meaning that there were at least \(75c^2 d\cdot d = 3(5cd)^2 > 3(5cd -2)^2\) many paths that contained \(e_1\), which contradicts our premise. \(\square\)

5.4.3 Phase 3.3: interior flow realization

In order to exchange robots between tile interiors as modeled by the flow \(G_{\mathcal {T}_5}\), we have to determine a collision-free protocol that allows robots to pass through the scaffold and into adjacent tiles. To this end, we describe a set of movement patterns for the robots of a single tile; these realize a single d-subflow in a stable manner within \(\mathcal {O}(d)\) steps. We then derive a compact concatenation of schedules that realize a d-subflow each, finally realizing up to d such flows by a schedule of makespan \(\mathcal {O}(d)\).

An invariant interior configuration For the definition of invariant configurations, we consider a decomposition of T into layers, where the ith layer is the boundary of T after iteratively deleting the layers \(1,\ldots ,i-1\). Thus, the first layer is directly adjacent to the scaffold.

We say that the configuration of \(T\in \mathcal {T}_5\) is push-stable (with respect to a flow \(G_{\mathcal {T}_5}\)), if the following criteria are met for every robot r on an ith layer of the interior of T; see Fig. 17.

  • \(i \le d\): r is connected to the closest boundary robot by a straight line of robots.

  • \(i > d\): r is connected to a robot \(r'\) on layer d by a path of robots in higher-order layers than d, such that the closest side to \(r'\) of the boundary of T rests on an edge without outgoing flow.

A total sink (total source) is a tile T that has four incoming (outgoing) edges of non-zero value over \(G_{\mathcal {T}_5}\). Conversely, a partial sink (partial source) is a tile T that is not flow-conserving over \(G_{\mathcal {T}_5}\), but has no more than three incoming (outgoing) edges of non-zero value. Note that by definition, total sources can never be configured in a push-stable manner. As this creates the need to handle total sinks separately, we provide a separate approach in Sect. 5.4.3. Note that, although this constraint does not apply to total sources, we can apply the outlined methods for total sinks in reverse, and therefore refer to the same section.

Fig. 17
figure 17

a An example of a push-stable configuration of a tile with two incoming and two outgoing edges. b Highlighted are a robot on layer d and c on a higher-order layer, with paths that ensure their connectivity

Realizing a single subflow We now provide the detailed description of our approach to realize a single subflow. The approach consists of the following three subphases.

  • Phase 3.3.1: Interior preprocessing.

  • Phase 3.3.2: Matching incoming and outgoing robots.

  • Phase 3.3.3: Pushing robots into their target tiles.

Lemma 12

Consider a d-subflow \(H_{\mathcal {T}_5}\subseteq G_{\mathcal {T}_5}\) and a tile \(T\in \mathcal {T}_5\) that is flow-conserving with respect to \(H_{\mathcal {T}_5}\). There is a stable schedule of makespan \(\mathcal {O}(d)\) that realizes the flow at its location.

Using Theorem 4, Phase 3.3.1 constructs a push-stable initial configuration that places \(0<d'\le d\) outgoing robots adjacent to their respective target tile’s shared boundary in the interior of T.

Subsequently, a local application of Lemma 1 is used to embed those outgoing robots into the boundary between their current and target tile, allowing them to be pushed into the interior of a neighboring tile in a single step, see Fig. 18c.

For simplified notation, parts of the scaffold are temporarily “reassigned” to neighboring tiles for this purpose. For instance, a tile T may temporarily surrender ownership of its half of the scaffold separating it from a neighboring tile \(T'\), see Fig. 18b, assuming \(f '((T', T)) > 0\). The \(2\times 2\) corner areas are never reassigned.

In Phase 3.3.2, we perform a pairwise matching of incoming and outgoing robots, so that each pair can be connected by a crossing-free path. Each such path passes through a unique layer \(d+i\) for some \(i\in \mathbb {N}\), depending on the matching, meaning that some paths might pass through incomplete or missing layers (see Fig. 18c). Note that any such path begins adjacent to a robot that enters T, travels inwards to the \((d+i)\)th layer, at which point follows said layer until it travels outwards again to the boundary of T, reaching the vertex at which the matched robot leaves T. This approach closely follows the methods described by Demaine et al. [17] in their paper on a related reconfiguration problem.

Fig. 18
figure 18

A tile \(T\in \mathcal {T}_5\) during the realization of a single d-subflow. The dashed portions of paths indicate that no motion actually occurs in this segment due to the described pushing behavior

The actual realization of \(H_{\mathcal {T}_5}\) at tile T can now be performed in a single, simultaneous pushing motion along each of the constructed paths in Phase 3.3.3, see Fig. 18d.

Lemma 13

The realization of a d-subflow can be performed in a way that results in another push-stable configuration of T.

Proof

The crucial steps for this occur in Phase 3.3.3. Consider a path that connects an incoming and an outgoing robot. If the path is fully occupied, the described pushing motion does not have any effect on the silhouette of the tile it passes through, so this motion by itself yields a push-stable configuration.

Now consider a path through an incomplete layer that has an incoming robot entering it at the first position. We continue the resulting pushing motion until the first empty position on the path, which then becomes occupied.

The tail end of the path is handled differently. The last d positions on the path may be occupied by robots that are then always connected directly to the scaffold through one another. We push only these (at most) d robots towards the boundary, potentially leaving a hole at the dth layer of the tile, see Fig. 18d. Note that the positions immediately before the last d may be occupied by robots as well. However, any robot above layer d must be connected to an incoming side of the boundary via a path through its own layer. This ensures that any robot above the dth layer remains connected regardless of the outgoing robots moving away from it.

We conclude that Phase 3.3.3 always results in a push-stable configuration. \(\square\)

We slightly modify the approach described before, in order to apply it to non-flow-conserving tiles.

Lemma 14

Consider a d-subflow \(H_{\mathcal {T}_5}\subseteq G_{\mathcal {T}_5}\) and a tile \(T\in \mathcal {T}_5\) that is not a total sink or total source with respect to \(G_{\mathcal {T}_5}\). There is a stable schedule of makespan \(\mathcal {O}(d)\) that realizes the flow at its location and yields another push-stable configuration.

Proof

Consider a tile T that is not flow-conserving with respect to a d-subflow \(H_{\mathcal {T}_5}\) and for which there are \(\lambda \le d\) robots either entering or leaving the tile that cannot be matched to a robot doing the opposite. See Fig. 19 for an illustration.

If T is a partial source, a push-stable initial configuration may be created by the previously outlined method. As the pulling motion at the outgoing end of a path always results in another push-stable configuration, the lack of incoming robots does not cause any disconnections.

If T is a partial sink, a slight adjustment to the initial push-stable configuration must be made. As \(\lambda \le d\), it is possible to leave \(\lambda\) empty positions in the dth layer, behind outgoing robots. The result is a push-stable configuration that allows the incoming paths to push into the empty space behind the outgoing robots, reaching another push-stable configuration. \(\square\)

Fig. 19
figure 19

a + b A partial source tile and c + d a partial sink tile during the realization of a single d-subflow

Realizing multiple subflows The previously described movement patterns may be compactly combined into a single schedule of makespan \(\mathcal {O}(d)\) that realizes up to d many d-subflows at once.

Lemma 15

Consider a tile \(T\in \mathcal {T}_5\) that is not a total sink or total source with respect to \(G_{\mathcal {T}_5}\) and a sequence \(S_{\mathcal {T}_5}:= (H^1_{\mathcal {T}_5}, \dots , H^\ell _{\mathcal {T}_5} )\) of d-subflows of \(G_{\mathcal {T}_5}\) with \(\ell \le d\). There exists a stable schedule of makespan \(\mathcal {O}(d)\) that realizes all \(\ell\) many d-subflows.

Proof

The first portion of this schedule consists of an application of Theorem 4 that prepares for the final \(\ell\) transformation steps that realize one subflow each, see Fig. 20. This is achieved by stacking the agents against the target tile’s boundary in successive layers, for which the order of agents is based on the order of subflows in \(S_{\mathcal {T}_5}\), with later subflows occupying locations on higher-order layers. As \(\ell \le d\), no queue may be more than d agents long. The result is a push-stable configuration of T, which takes into account the special cases discussed in Lemma 14.

Next, we apply Theorem 4 to embed the queues of agents in the wall between their current and their target tile, placing corresponding scaffold agents at the very back of each queue, see Fig. 20a. This leaves only the actual realization steps to be determined.

These consist of \(\ell\) successive pushing operations based on matchings between incoming and outgoing agents, ensuring that each intermittent configuration of the schedule is stable. \(\square\)

Fig. 20
figure 20

A tile \(T\in \mathcal {T}_5\) during the realization of \(\ell\) d-subflows

Total sinks and sources As noted before, total sinks and sources form a special case that we handle separately from the described push-stable patterns.

Lemma 16

Consider a tile \(T\in \mathcal {T}_5\) that is a total sink or total source with respect to \(G_{\mathcal {T}_5}\) and a sequence \(S_{\mathcal {T}_5}:= (H^1_{\mathcal {T}_5}, \dots , H^\ell _{\mathcal {T}_5} )\) of d-subflows of \(G_{\mathcal {T}_5}\) with \(\ell \le d\). There exists a stable schedule of makespan \(\mathcal {O}(d)\) that realizes all \(\ell\) many d-subflows.

Proof

We divide the interior space of T into four disjoint triangles along the diagonals of the tile, see Fig. 21. Without loss of generality, assume that T is a total sink. No more than \(d^2\) robots can enter at any given edge as a result of \(S_{\mathcal {T}_5}\), and the resulting number of robots in the tile’s interior cannot be larger than \((5cd-2)^2\). This means that it is sufficient to leave the corresponding number of positions at the innermost section of each triangle unoccupied. The motion of entering robots cannot cause any issues with stability and takes no more than \(\ell\) transformations. This implies a total makespan of \(\mathcal {O}(d) + \ell\).

As every schedule is invertible, the opposite movement pattern may be applied to total sources; pushing outwards from the very center of the tile while only moving robots within a single triangle region does not cause any disconnections of the configuration. \(\square\)

Fig. 21
figure 21

A total sink \(T\in \mathcal {T}_5\) during the realization of \(\ell\) many d-subflows. As indicated by the triangular marks, each side has a unique space into which robots may push

Realizing all subflows By applying Lemmas 15 and 16, up to d many d-subflows of \(G_{\mathcal {T}_5}\) may be realized in \(\mathcal {O}(d)\) transformations. As we created \(\mathcal {O}(d)\) such subflows in Sect. 5.4.2, all of them may be realized through \(\nicefrac {\mathcal {O}(d)}{d} = \mathcal {O}(1)\) repetitions. These repetitions require a total of \(\mathcal {O}(d)\) transformations.

5.5 Phase 4: boundary flow

The next phase of our algorithm deals with the movement of robots that are part of the scaffold. As described in Sect. 5.3, the robots forming the scaffold in a tiled configuration must remain in the 1-neighborhood of their target tile over \(\mathcal {T}_5\). The intermediate mapping step in the construction process guarantees that this remains the case even after that phase concludes. However, the scaffold does not necessarily consist of the same robots in the tiled configurations \(C_s'\) and \(C_t'\). For any given tile \(T\in \mathcal {T}_5\), up to \(20cd-4\) robots exist in its neighborhood \(N_1[T]\) that need to become part of its boundary structure.

This observation allows us to model the necessary exchange as a \((20cd-4)\)-flow. Using the techniques discussed in Sect. 5.4.2 with some minor modifications, we obtain and realize a \((d,\mathcal {O}(1))\)-partition of this new flow graph \(G_{\mathcal {T}_5}^s\) as follows.

Creating a planar and unidirectional flow Just as with the prior flow \(G_{\mathcal {T}_5}\), bidirectional and crossing edges need to be removed from the flow before the partitioning process. This can be achieved in the same manner as before. By applying Theorem 4, we place the robots that need to be exchanged in the wall between adjacent tiles, and subsequently exchange them by means of local rotations. As at most \(20cd-4\) robots need to be swapped between any two adjacent tiles, this process takes \(\mathcal {O}(d)\) steps in total. Once this process has been applied to all tiles, \(G_{\mathcal {T}_5}^s\) is bounded from above by \(3(20cd-4)\).

Partitioning the flow We again seek to decompose the flow into smaller components that can be realized separately. A \((d,\mathcal {O}(1))\)-partition can be computed by the following method. By applying Lemma 9, we compute a \((3(20cd-4), 2)\)-partition of \(G_{\mathcal {T}_5}^s\), decomposing the flow into acyclic and cyclic components \(G_\rightarrow ^s\) and \(G_\bigcirc ^s\). Using modified versions of the partitioning algorithms from Sect. 5.4.2, we then compute a \((d,\mathcal {O}(1))\)-partition of each of them.

By simply modifying the final step of the algorithm used to obtain Lemma 10, we can compute a \((d,\mathcal {O}(1))\)-partition of \(G_\bigcirc ^s\). Thus, we obtain the following.

Lemma 17

We can compute a \((d,\mathcal {O}(1))\)-partition of a circulation \(G_\bigcirc ^s\) which is a \((k\cdot d)\)-flow for some constant \(k\in \mathbb {N}\) in polynomial time.

Proof

We refer to Lemma 10 for the first two steps of the algorithm. Then, let \(\mathbb {P}_X^j\in \{\mathbb {P}_\circlearrowright ^1, \mathbb {P}_\circlearrowright ^2, \mathbb {P}_\circlearrowleft ^1, \mathbb {P}_\circlearrowleft ^2\}\) refer to a partition constructed in the second step. Additionally, let \(F = (\mathbb {P}^j_X, E_F)\) refer to the forest induced by the nesting properties of cycles within the partitions.

By labeling the vertices of this forest by their depth in \(F \bmod k\), it is possible to construct \(\mathcal {O}(1)\) flows \(\{G_{\bigcirc _1}^s, G_{\bigcirc _2}^s, \dots \}\), each being the union of cycles sharing a label.

It remains to show that each flow \(G_{\bigcirc _i}^s\) with \(i\in [1,k]\) is a d-subflow. For this, consider any two cycles \(u,v\in \mathbb {P}_X^j\) that share a common edge e. By construction, one of the two cycles must lie within the other. Without loss of generality, assume that v lies in u. This implies that there exists a path from v to its root via u in F, with all cycles on the path between v and u sharing the edge e as well. As all edges in \(G_\bigcirc ^s\) are bounded from above by \(k\cdot d\), the cycles containing e lie on a path of length no more than \(k\cdot d\) in F. Thus, e has a weight of at most \(\nicefrac {k\cdot d}{k} = d\) in every \(G_{\bigcirc _i}^s\). We conclude that each flow \(G_{\bigcirc _i}^s\) is a d-subflow of \(G_\bigcirc ^s\). \(\square\)

We now adjust Lemma 11 to compute a \((d,\mathcal {O}(1))\)-partition of \(G_\rightarrow ^s\).

Lemma 18

We can compute a \((d,\mathcal {O}(1))\)-partition of an acyclic flow \(G_\rightarrow ^s\) which is a \((k\cdot d)\)-flow for some constant \(k\in \mathbb {N}\) in polynomial time.

Proof

See the proof of Lemma 11 for the algorithm itself. We know that \(G_\rightarrow ^s\) is bounded from above by \(k\cdot d\). Suppose that the algorithm constructs \(k+1\) flows, implying that the algorithm encountered a configuration in which a path \(P_i\) could not be assigned to the existing \(\lambda = 3k \cdot \nicefrac {d}{3}\) sets \(S_1, \dots , S_\lambda\), spawning a new set \(S_{\lambda +1}\). This implies that each set \(S_1, \dots , S_\lambda\) contained a path \(P_j\) that shares the first edge \(e_1\) of \(P_i\), meaning that there were at least \(k\cdot d +1 > k\cdot d\) paths containing \(e_1\), implying a flow value of more than \(k\cdot d\). \(\square\)

Realizing a single subflow We now argue that the computed subflows can be realized in \(\mathcal {O}(d)\) transformations, and begin with the realization of a single subflow.

Lemma 19

Let \(H_s = (\mathcal {T}_5, E_{\mathcal {T}_5}, f _s')\) be a d-subflow of \(G_{\mathcal {T}_5}^s\). We can efficiently compute a stable schedule of makespan \(\mathcal {O}(d)\) that realizes \(H_s\).

Proof

The exact movement comes down to the number of robots within each tile the flow passes through.

Consider any tile \(T\in \mathcal {T}_5\) that has non-zero flow in \(H_s\) and let \(\eta \le (5cd)^2\) be the initial number of robots within the tile (including the scaffold). Additionally, let \(\eta _\text {out}\le d\) denote the exact number of robots that need to leave T to realize \(H_s\) at its location. Each tile always contains at least its boundary robots, so \(\eta \ge 20cd-4\). The existing movement patterns from Sect. 5.4.3 may be utilized to realize the flow at T’s location if \(\eta -\eta _\text {out}\ge 20cd-4\).

On the other hand, if \(\eta -\eta _\text {out} < 20cd-4\), there are not sufficiently many robots within the tile’s interior to close up the holes in the scaffold through which the \(\eta _\text {out}\) robots leave it as part of the pushing motion. Note that this can only occur at flow-conserving tiles, because source tiles cannot end up with less robots than \(20cd-4\). This means that there are \(\eta _\text {in} = \eta _\text {out}\) robots entering T as part of the same flow.

As every outgoing side of T is adjacent to an incoming side of another tile \(T'\), no part of the scaffold can become disconnected through the pushing motion. Subsequently, there are at most \(\eta _\text {in}\) unoccupied positions in the boundary of T. By pushing along and into the boundary from the middle of the line of \(\eta _\text {in}\) robots that were pushed into T, those robots may patch all holes in \(\mathcal {O}(\eta _\text {in}) =~\mathcal {O}(d)\) transformations, as depicted in Fig. 22. Overall, this realizes a single d-subflow of \(G_{\mathcal {T}_5}^s\) in \(\mathcal {O}(d)\) steps. \(\square\)

Fig. 22
figure 22

We can employ the displayed movement patterns to exchange boundary robots between adjacent tiles

Realizing all subflows It is now easy to see that all subflows can be realized in a total of \(\mathcal {O}(d)\) transformations; thus, we obtain the following.

Lemma 20

For any pair \((C_s,C_t)\) with diameter d, we can compute a stable schedule with makespan \(\mathcal {O}(d)\) that realizes \(G_{s}\), transforming a labeled tiled configuration \(C_s'\) into another labeled tiled configuration \(C_t'\), in polynomial time.

Proof

The entirety of \(G_{\mathcal {T}_5}^s\) may be realized by applying the previous approach to each of the d-subflows, bringing all scaffold robots into their correct target tiles. As there are \(\mathcal {O}(1)\) such d-subflows, the total makespan of this is \(\mathcal {O}(d)\). \(\square\)

5.6 Phases 5 and 6: scaffold deconstruction

Once Phase 4 concludes, we have reached a tiled configuration in which every tile contains precisely the robots that it would in a tiled configuration \(C_t'\) of the target configuration. This means that we can reconfigure into \(C_t'\) by a single application of Theorem 4, which forms the entirety of Phase 5.

As Phase 6 is a reverse of Phase 2, this concludes the description of the algorithm. Because each phase takes \(\mathcal {O}(d)\) transformation steps, this proves Theorem 5.

6 Conclusions and further considerations

We have provided new results for efficient coordinated motion planning for a labeled swarm of robots. In particular, we resolved two major open problems for connected reconfiguration: in the labeled case, a stretch factor of \(\Omega (\sqrt{n})\) may be inevitable for n robots, and constant stretch can be achieved for scaled arrangements of labeled robots; previously, the former was unknown for any kind of connected reconfiguration, while the latter was only known for the (considerably easier) unlabeled case.

These results pose a number of relevant follow-up questions and provide insights into related problems. In the following, we briefly discuss both direct implications and further research questiona.

6.1 Colored reconfiguration

This paper focuses on labeled robots, so each robot has a known start and end position; on the other hand, Fekete et al. [24] considered the unlabeled version of the problem, in which robots can freely be exchanged to achieve a desired final shape. A natural generalization of both is colored reconfiguration, in which we have \(\ell \in \mathbb {N}\) different classes of objects that are exchangeable within each class. In this setting, the unlabeled case corresponds to \(\ell =1\), while the labeled case amounts to \(\ell =N\).

By employing a minimum bottleneck matching between objects in the respective color classes to assign final positions from the initial configuration, before applying our labeled reconfiguration, it is straightforward to see that all our results also hold for the colored version of the problem.

6.2 Achievable makespans

An interesting open problem arises from considering lower bounds on stretch factors. Although we provided a lower bound of \(\Omega (\sqrt{n})\) on the achievable stretch factor in some scenarios, we believe that constant stretch schedules exist in most instances. More specifically, we conjecture that the constant \(c^*\) introduced in Theorem 5 is as low as 2, i.e., constant stretch is achievable for any pair of configurations of scale 2. The thin counterexample with scale 1 in Theorem 3 is heavily restricted by the global implications of local movement, which appear to lose relevance quickly with growing scale. Moreover, it is unknown whether \(\mathcal {O}(\sqrt{n})\) stretch can always be achieved, in particular for thin configurations.

6.3 Decentralized methods

Another important set of questions arises from running the ensuing protocols in a largely decentralized fashion. This involves two aspects of parallelization, distinguishing between distributed methods for (1) carrying out the computations and (2) performing the actual motion control.

We are confident that both issues can be addressed to some extent by making use of the hierarchical structure of our approach, which operates on (I) the macroscopic tile graph, as well as on (II) the set of robots within tiles. Making use of the canonical algorithmic structures and reconfigurations within tiles, it should be relatively straightforward to do this at the individual tile levels (II) based on local operations (for computation) and protocols (for motion control). It is plausible that the macrocscopic aspects (I) can be addressed by making use of distributed methods for computing network flows, such as [30]; using these in our context would require embedding the high-level flow graph into the scaffold framework and implementing the corresponding distributed algorithms as protocols into our lower-level scaffold structures.

However, many of the involved details appear to be quite intricate and go beyond the main purpose of this paper. Consequently, these and other aspects are left for future work.