On the Shape Containment Problem Within the Amoebot Model with Reconfigurable Circuits
Abstract
In programmable matter, we consider a large number of tiny, primitive computational entities called particles that run distributed algorithms to control global properties of the particle structure. Shape formation problems, where the particles have to reorganize themselves into a desired shape using basic movement abilities, are particularly interesting. In the related shape containment problem, the particles are given the description of a shape and have to find maximally scaled representations of within the initial configuration, without movements. For example, if is a triangle, they have to identify the largest subsets of particles that already form a triangle. While the shape formation problem is being studied extensively, no attention has been given to the shape containment problem, which may have additional uses besides shape formation, such as detecting structural flaws.
In this paper, we consider the shape containment problem within the geometric amoebot model for programmable matter, using its reconfigurable circuit extension to enable the instantaneous transmission of primitive signals on connected subsets of particles. We first prove a lower runtime bound of synchronous rounds for the general problem, where is the number of particles. Then, we present simple and efficient primitives for identifying subsets that form the desired shape. Using these primitives, we construct a large class of shapes which we call snowflakes. This class contains, among others, all shapes composed of parallelograms and hexagons, and the class of star convex shapes. Let be the maximum scale of the considered shape in a given amoebot structure. If the shape is star convex, we solve it within rounds. If it is a snowflake but not star convex, we solve it within rounds.
Keywords and phrases:
Programmable matter, amoebot model, reconfigurable circuits, shape containmentCopyright and License:
2012 ACM Subject Classification:
Theory of computation Distributed computing models ; Theory of computation Self-organization ; Theory of computation Computational geometryAcknowledgements:
We thank Daniel Warner for his guidance and helpful discussions.Funding:
This work was supported by the DFG Project SCHE 1592/10-1.Editor:
Dariusz R. KowalskiSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Programmable matter envisions a material that can change its physical properties in a programmable fashion [25] and react to external stimuli. It is typically viewed as a system of many identical micro-scale computational entities called particles. Potential application areas include minimally invasive surgery, maintenance, exploration, and manufacturing. While significant progress is being made in the field of micro-scale robotics [26, 5], the fundamental capabilities and limitations of such systems are studied in theory using various models [24].
In the amoebot model of programmable matter, the particles are called amoebots and are placed on the nodes of a graph. We assume that the occupied nodes form a connected subgraph. Since information can only travel through the edges of the graph, there is a natural lower bound of for many problems, where is the diameter of this subgraph.
Motivated by this, we consider the reconfigurable circuit extension of the model, which allows better results with reasonable modifications. In this extension, the amoebots can construct simple communication networks called circuits on connected subgraphs of the structure and broadcast primitive signals on these circuits instantaneously. This allows polylogarithmic solutions to many problems, e.g., leader election, consensus, shape recognition, and shortest path forest construction [12, 21, 20].
The shape formation problem, where the amoebot structure has to reconfigure itself into a given shape, is a standard problem of particular interest [24]. In this paper, we study the related shape containment problem: Given a shape , the amoebots must find the maximum scale at which can be placed within their structure and identify all valid placements at this scale. This can be useful for shape formation by self-disassembly, i.e., disconnecting all amoebots that are not part of a selected placement of the shape from the structure [14, 13]. The problem can also be interpreted as a discrete variant of the polygon containment problem in classical computational geometry, which has been studied extensively [6, 23]. To our knowledge, there are no distributed solutions that apply to the amoebot model.
1.1 Geometric Amoebot Model
We use the geometric amoebot model for programmable matter, as proposed in [9]. Using the terminology from the recent canonical model description [8], we assume common direction and chirality, constant-size memory, and a fully synchronous scheduler, making it strongly fair. We describe the model in sufficient detail here and refer to [9, 8] for more information.
The geometric amoebot model places particles called amoebots on the infinite regular triangular grid graph (see Fig. 1(a)). This is the typical graph used in the amoebot literature [9, 12, 21, 20, 19]. Each amoebot occupies one node, and each node is occupied by at most one amoebot. We identify each amoebot with the grid node it occupies to simplify the notation. Thereby, we define the amoebot structure as the set of occupied nodes. We assume that is finite and its induced subgraph of is connected.
Each amoebot has a local compass identifying one of its incident grid edges as the East direction, and a chirality defining its local sense of clockwise rotation. We assume that all amoebots share both. This is not a restrictive assumption because a common compass and chirality can be established efficiently using circuits [12]. The amoebots are controlled in a distributed fashion by identical and anonymous finite state machines. In particular, the amount of memory per amoebot is constant, i.e., fixed by the algorithm/state machine running on each amoebot and independent of the number of amoebots in the structure. This means that, for example, unique identifiers for all amoebots cannot be stored. A computation proceeds in fully synchronous rounds. In each round, all amoebots act and change their states simultaneously based on their current state and their received signals (see Section 1.2). We measure the time complexity of an algorithm by the number of rounds it requires until all amoebots reach a terminal state. Although the model allows amoebots to perform movements, we only consider static amoebot structures in this paper.
1.2 Reconfigurable Circuit Extension
The reconfigurable circuit extension [12] places external links on every edge connecting two adjacent amoebots . The endpoints of an external link are called pins. For each link, one pin is owned by and one is owned by . The constant is an algorithm design parameter and is the same for all amoebots. In this paper, we use , which is the least number of pins required by the PASC algorithm [12], a central primitive for our results.
Let be the set of pins owned by amoebot . Each amoebot computes a partitioning of into a set of non-empty, pairwise disjoint subsets such that . The subsets are called partition sets and is called the pin configuration of . The amoebot’s algorithm defines how the pin configuration is computed in every round. Let be the set of all partition sets in the amoebot structure. Two partition sets and of neighboring amoebots and are connected if there is an external link with one pin in and one pin in . Let be the set of these connections. We call each connected component of the undirected graph a circuit (see Figs. 1(c), 1(d)). An amoebot is part of a circuit if contains at least one partition set of . Note that multiple partition sets of an amoebot may be contained in the same circuit without being aware of this due to its lack of global information.
During its activation, each amoebot can establish an arbitrary new pin configuration and send primitive signals called beeps on any selection of its partition sets. A beep is broadcast to the circuit containing the partition set it was sent on. All partition sets in that circuit receive the beep at the beginning of the next round. An amoebot can tell which of its partition sets have received a beep, but it has no information on the identity, location, or number of beeping amoebots. We model all communication between amoebots with circuits.
1.3 Problem Statement and Our Contribution
Consider the embedding of into such that the grid’s faces form unit triangles and one grid node is placed at the plane’s origin (see Fig. 1(b)). We obtain three coordinate axes, , and six cardinal directions . Let denote the unit vector in direction .
A shape is a finite union of nodes, edges, and faces of the embedded grid graph (see Fig. 2, c.f. [10, 12]). Edges contain their endpoints and faces contain their enclosing edges. A shape must be connected, but it may contain holes, i.e., might not be connected. This shape definition matches the one used in [10] for shape formation and extends the definition used in [12] for shape recognition.
We define translation, rotation, and scaling operations on a shape as follows. For , we denote translated by by . This is a valid shape if and only if is the position of a grid node, i.e., a linear combination of unit vectors in the cardinal directions with integer coefficients. We can therefore write , identifying the position with the unique grid node occupying it. For , let denote after counter-clockwise rotations by around the origin of . Note that is sufficient to represent all distinct rotations of a shape in the grid. Let be a scale factor, then we define to be the shape scaled by . We only consider positive integer scale factors to ensure that the resulting set is a valid shape. If is minimal, i.e., there is no scale factor such that is a valid shape, then the integer scale factors cover all possible scales of that produce valid shapes (see Lemma 1 in [10]). Two shapes are equivalent if one can be obtained from the other by a rigid motion, i.e., a composition of a translation and a rotation.
Let denote the set of grid nodes contained in . For convenience, we assume for any given shape and call this node the origin of . This property is invariant under rotation and scaling as defined above. A valid placement of a shape in an amoebot structure is an amoebot with (identifying with the grid node it occupies). Let denote the set of all valid placements of in . The maximum scale of in is the largest scale such that there is a valid placement of in for some :
is well-defined because is at most a single node for every shape , which fits into any non-empty amoebot structure . We obtain if and only if does not contain any edges. If and are clear from the context, we will write . See Fig. 3 for illustration.
We define the shape containment problem as follows: Let be a shape (containing the origin). An algorithm solves the shape containment problem instance for an amoebot structure if it terminates eventually and at the end,
-
1.
all amoebots know whether (meaning that all or none of the amoebots are valid placements), and
-
2.
if , then for every , each amoebot knows whether it is contained in .
The algorithm solves the shape containment problem for if it solves the shape containment instances for all finite connected amoebot structures . Note that the shape is fixed for an algorithm, i.e., it is encoded in the state machine in some way, and its size is constant. The algorithm may use an equivalent shape instead of itself.
There are two key challenges in solving the shape containment problem. First, the amoebots have to find the maximum scale . We approach this problem by testing individual scale factors for valid placements until is fixed. We call this part of an algorithm the scale factor search. Second, for a given scale and a rotation , the valid placements of have to be identified. This means that every amoebot must collect information on all amoebots in . then has to mark itself as a valid placement if and only if all of these amoebots exist. In some cases, we initially view all amoebots as placement candidates and then eliminate candidates that can be ruled out as valid placements. We call this part the valid placement search procedure. Since the information about missing amoebots naturally comes from the boundaries of the structure, the main difficulty here is distributing this information efficiently to all affected amoebots and not ruling out any valid placements.
In this paper, we present sublinear time solutions for the shape containment problem using circuits. As a motivation, we first prove a lower bound for the general case that holds even if the maximum scale is known, by creating a communication bottleneck for an example shape. Next, we present scale factor search approaches using distributed memory, applying a binary search where it is possible. We then introduce simple and efficient primitives for placement search algorithms based on combining and transforming valid placements of lines, thereby constructing increasingly complex shapes. Using earlier results for reconfigurable circuits, these primitives run in at most logarithmic time. By combining our primitives, we obtain the class of snowflake shapes, which contains a variety of complex and practically relevant shapes. For example, it contains all convex shapes, all shapes that are composed of parallelograms of the same orientation, all shapes composed of hexagons, and combinations (e.g., unions) of these and other shapes. The definition of this class allows more types of shapes to be combined and integrated when a valid placement search procedure is given for them. Our shape containment solution for snowflakes takes a sublinear number of rounds. Further, we show that for the set of star convex shapes, which is contained in the snowflake class, a binary search for the scale factor even leads to a polylogarithmic solution. Surprisingly, the binary search approach is only directly applicable to star convex shapes. We only give high-level explanations of our primitives and defer the technical details and proofs to the full version of the paper [4]. Selected proofs can also be found in the appendix.
1.4 Related Work
The authors of [12] demonstrated the potential of their reconfigurable circuit extension with algorithms solving the leader election, compass alignment, and chirality agreement problems within rounds, w.h.p.111An event holds with high probability (w.h.p.) if it holds with probability at least , where the constant can be made arbitrarily large. They also presented efficient solutions for some exact shape recognition problems: Given common chirality, an amoebot structure can determine whether it matches a scaled version of a given shape composed of edge-connected faces in rounds. Without common chirality, convex shapes can be detected in rounds and parallelograms with linear or polynomial side ratios can be detected in rounds, w.h.p.
The PASC algorithm was introduced in [12] and refined in [21], and it allows amoebots to compute distances along chains. It has become a central primitive in the reconfigurable circuit extension, as it was used to construct spanning trees, detect symmetry, and identify centers and axes of symmetry in polylogarithmic time, w.h.p. [21]. The authors in [20] used it to solve the single- and multi-source shortest path problems, requiring rounds for a single source and destinations and rounds for sources and any number of destinations. The PASC algorithm also plays a crucial role in this paper (see Sec. 2.2.2).
The authors in [11] studied the capabilities of a generalized circuit communication model that directly extends the reconfigurable circuit model to general graphs. They provided polylogarithmic time algorithms for various common graph construction (minimum spanning tree, spanner) and verification problems (minimum spanning tree, cut, Hamiltonian cycle etc.). Additionally, they presented a generic framework for translating a type of lower bound proof from the widely used CONGEST model into the circuit model, demonstrating that some problems are hard in both models, while others can be solved much faster with circuits. For example, checking whether a graph contains a -cycle takes rounds in general graphs, even with circuits, while the verification of a connected spanning subgraph can be done with circuits in rounds w.h.p., which is below the lower bound shown in [22].
In the context of computational geometry, the basic polygon containment problem was studied in [6], focusing on the case where only translation and rotation are allowed. The problem of finding the largest copy of a convex polygon inside some other polygon was discussed in [23] and [1], for example. An example for the problem of placing multiple polygons inside another without any polygons intersecting each other is given by [17]. More recently, the authors in [16] showed lower bounds for several polygon placement cases under the SUM conjecture. For example, assuming the SUM conjecture, there is no -time algorithm for any that finds a largest copy of a simple polygon with vertices that fits into a simple polygon with vertices under translation and rotation. Perhaps more closely related to our setting (albeit centralized) is an algorithm that solves the problem of finding the largest area parallelogram inside of an object in the triangular grid, where the object is a set of edge-connected faces [2].
2 Preliminaries
This section introduces elementary algorithms for the circuit extension from previous work.
2.1 Coordination and Synchronization
As mentioned before, we assume that all amoebots share a common compass direction and chirality. This is a reasonable assumption because the authors of [12] have presented randomized algorithms establishing both in rounds, w.h.p.
We often want to synchronize amoebots, for example, when different parts of the structure run independent instances of an algorithm simultaneously. For this, we can use a global circuit: Each amoebot connects all of its pins into a single partition set. The resulting circuit spans the whole structure and allows the amoebots which are not yet finished with their procedure to inform all other amoebots by sending a beep. When no beep is sent, all amoebots know that all instances of the procedure are finished. Due to the fully synchronous scheduler, we can establish the global circuit periodically at predetermined intervals.
2.2 Chains and Chain Primitives
A chain of amoebots with length is a sequence of amoebots where all subsequent pairs , , are neighbors, each amoebot except knows its predecessor, and each amoebot except knows its successor. In this paper, we only consider simple chains without multiple occurrences of the same amoebot. By letting each amoebot decide whether it connects a pin toward its predecessor with a pin toward its successor, we can easily establish circuits along such chains.
2.2.1 Binary Operations
The constant memory limitation of amoebots makes it difficult to deal with non-constant data, particularly numbers that can increase with . However, we can use amoebot chains to implement a distributed memory by letting each amoebot on the chain store one bit of a binary number, as demonstrated in [7, 21]. Using circuits, we can implement efficient comparisons and arithmetic operations between two operands stored on the same chain.
Lemma 1.
Let be an amoebot chain such that each amoebot stores two bits and of the integers and , where and . Within rounds, the amoebots on can compare to and compute the first bits of , (if ), , and and store them on the chain. Within rounds, the amoebots on can compute the first bits of , , and and store them on the chain.
Lemma 1 is a minor improvement over the algorithms presented in [21]. Additionally, individual amoebots can execute simple binary operations online on streams of bits:
Lemma 2.
Let be an amoebot that receives two numbers as bit streams, i.e., it receives the bits and in the -th iteration of some procedure, for . Then, can compute bit of or (if ) in the -th iteration and determine the comparison result between and by iteration , with only constant overhead per iteration.
2.2.2 The PASC Algorithm
A particularly useful algorithm in the reconfigurable circuit extension is the Primary-And-Secondary-Circuit (PASC) algorithm, first introduced in [12]. We omit the details of the algorithm and only outline its relevant properties. Please refer to [21] for details.
Lemma 3 ([12, 21]).
Let be a chain of amoebots. The PASC algorithm, executed on with start point , performs iterations within rounds. In iteration , each amoebot computes the -th bit of its distance to the start of the chain, i.e., computes as a bit stream.
The PASC algorithm is especially useful with binary counters. It allows us to compute the length of a chain, which is received by the last amoebot in the chain and can be stored in binary on the chain itself (letting the last amoebot send the received bits as beeps on a circuit spanning the chain). Furthermore, given some binary counter storing a distance and some amoebot chain , each amoebot can compare to by receiving the bits of on a global circuit in sync with the iterations of the PASC algorithm on .
Lemma 4.
Let be a chain in an amoebot structure and let a value be stored in some binary counter of . Within rounds, every amoebot can compare to . The procedure can run simultaneously on any set of edge-disjoint chains with length .
3 A Lower Bound for Finding Valid Placements
We first show a lower bound that demonstrates a central difficulty arising in the shape containment problem. For a simple example shape (see Fig. 4), we show that even if the maximum scale is known, identifying all valid placements of can require rounds due to communication bottlenecks.
Theorem 5.
There exists a shape such that for any choice of origin and every amoebot algorithm that terminates after rounds, there exists an amoebot structure for which the algorithm does not compute , even if is known.
The proof idea is as follows (see Appendix A for details): Consider an amoebot structure consisting of two parts, and , which are only connected by a single edge. In one round, one of at most different signals can be sent via the external links on that edge. Suppose that for , all valid placements of lie in , and each placement’s required node set reaches into . By adding and removing amoebots from , we can control which amoebots in are valid placements. The idea for our lower bound proof is to construct distinct patterns of valid placements by only altering . To identify the valid placements correctly, the amoebots in must distinguish between all of these patterns using information that must cross the edge between and . Since is a constant, this takes rounds. We show such a construction for any , with , and for any choice of origin in . In the remainder of this paper, we explore for which shapes these arbitrary patterns of valid placements do not occur, and present efficient procedures exploiting this property.
This lower bound holds for the problem of finding valid placements. Since every algorithm solving the shape containment problem must compute all valid placements for the maximum scale, the bound also holds for the general shape containment problem. Further, note that the lower bound of in the amoebot model without circuits, where is the diameter of , is caused by the distance information can travel per time step. In contrast, this lower bound is caused by the limited bandwidth of the circuits in some amoebot structures.
4 Scale Factor Search
As outlined before, our shape containment algorithms consist of two search procedures. The first is a scale factor search that determines which scales have to be checked to find the maximum scale. The second procedure is a valid placement search that identifies all valid placements of for all , given the scale in a binary counter.
Consider some shape and an amoebot structure with a binary counter storing an upper bound . The simple linear search procedure runs valid placement checks for the scales and accepts when the first valid placement is found. If no placement is found in any iteration, we have .
Lemma 6.
Let be a shape and an amoebot structure with a binary counter storing an upper bound . Given a valid placement search procedure for , the amoebots compute in at most iterations, running the placement search for scales and with constant overhead per iteration.
When using the linear search method, finding a small upper bound is essential for reducing the runtime. One way of obtaining for is to use a simpler shape with for which can be computed efficiently. Since every valid placement of is also a valid placement of , we have . Moving on, some shapes permit a faster search method based on an inclusion relation between different scales.
Definition 7.
We call a shape self-contained if for all scales , there exist a translation and a rotation such that .
For self-contained shapes, finding no valid placements at scale immediately implies , which allows us to apply a binary search: Starting with scale , we double the scale factor until no valid placements are found at some scale , which we then use as the upper bound for a binary search between and .
Lemma 8.
Let be a self-contained shape and let be an amoebot structure with a binary counter large enough to store . Given a valid placement search procedure for , the amoebots can compute within iterations such that each iteration runs the valid placement search once for some scale and has constant overhead.
5 Efficient Placement Search Procedures
In this section, we introduce placement search procedures allowing amoebots to identify valid placements of shapes when their scale is given in a binary counter. To cover all rotations, we simply repeat the placement search six times with rotated directions. We only provide high-level descriptions of the algorithms. Please refer to the full paper [4] for details. Our procedures heavily rely on combining the PASC algorithm with binary operations on bit streams (see Lemma 4). A simple and natural way to establish the required chains is using segments:
Definition 9.
Let be a grid axis. A ()-segment is a connected set of grid nodes on a line parallel to . Let , then a maximal -segment of is a finite -segment that cannot be extended with nodes from on either end. The length of a finite segment is .
For example, chains on maximal segments of the amoebot structure can be constructed easily once a direction has been agreed upon: All amoebots on a segment identify their chain predecessor and successor by checking the existence of neighbors on the direction’s axis. The start and end points of the segment are the unique amoebots lacking a neighbor in one or both directions. Using chains on segments, we can find valid placements of line shapes.
Definition 10.
A line shape is a shape consisting of consecutive edges extending in direction from the origin. For , the shape only contains the origin point.
Lines are the fundamental primitive shapes we will use to construct much more complex shapes. Our placement search procedure for lines runs the PASC algorithm to compute indices along maximal amoebot segments and compares them to the given line length , which is transmitted on a global circuit. Exactly the amoebots whose chain index, i.e., distance to the end of the segment, is at least are valid placements of the line. If the line shape has length and the current scale is , we compute in the counter storing and run the procedure for length . Note that for line shapes, the boundary amoebots holding the information which placements are invalid lie on the same segment as the affected placement candidates, enabling this simple solution.
Lemma 11.
Let be a line shape and let be an amoebot structure that stores in some binary counter and where all amoebots agree on . Within rounds, the amoebots can compute .
Recall that for any two shapes with , is an upper bound for . Thus, the maximum scale of an edge is a natural upper bound on the maximum scale of any non-trivial shape. In particular, any longest segment in the amoebot structure provides sufficient memory to store the scale values that must be considered. To use this fact, we establish binary counters on all amoebot segments (on all axes) and use them simultaneously, deactivating counters if they run out of memory.
We now discuss efficient operations on valid placements that allow us to determine the valid placements of a transformed shape. The first, simple operation is the union of shapes. Given the valid placements and of two shapes and , the amoebots in can find the valid placements of in a single round: Due to the relation , each amoebot only has to check whether it is a valid placement of both shapes. Observe that is always connected because we assume that and contain the origin, and the location of the origin in and directly affects the shape .
5.1 The Minkowski Sum Primitive
Next, we consider the Minkowski sum of a shape with a line.
Definition 12.
Let be two shapes, then their Minkowski sum is defined as
The resulting subset of is a valid shape, and if both shapes contain the origin, then their sum also contains the origin. Observe that for any shape and any line , we have
i.e., consists of consecutive copies of . This means that an amoebot is a valid placement of if and only if it is a valid placement of the line and for every amoebot , is a valid placement of . Suppose the amoebots already know the set of valid placements of and store in a binary counter. Then, they can find the valid placements of by running the placement search for within , treating the amoebots in as if they did not exist, except for synchronization.
Lemma 13.
Let be an arbitrary shape, a line, and an amoebot structure storing and a scale in some binary counter. Given and the set , the amoebots can compute within rounds.
Observe that this already yields efficient valid placement search procedures for shapes like parallelograms and unions thereof.
5.2 The Translation Primitive
Consider some shape , its valid placements , a direction , and a distance such that . Now, let , then only differs from in the location of its origin, and the valid placements of are just translated versions of the placements of , i.e., . Given the valid placements of , we can compute the placements of with a procedure that translates the placement information from . Our translation primitive can do this efficiently for shapes with the following property:
Definition 14.
Let be a shape and a grid axis. The minimal axis width of on (or -width) is the infimum of the length of any maximal line segment in that is parallel to . We call (-)wide or wide on if its -width is at least .
For example, the minimal axis width of a triangular face is for all axes due to its corners, and the -width of is when is parallel to and otherwise. Further, observe that for any shape , direction on axis , and , the -width of is at least .
Now, consider a -wide shape and let for some scale . Note that has a -width of at least . Let be an invalid placement of , then must be part of a -segment of that has length at least or is bounded by unoccupied nodes on at least one side. This is because any unoccupied node that makes invalid lies in . Since consists of -segments of length at least , causes a similar segment which contains to be invalid, as any placement in this segment is also invalidated by .
For translating the valid placements of by steps in a direction parallel to , suppose that (otherwise, we add this edge as part of the shape transformation). Then, we can reduce the problem to translating a single segment of length at least . For this, we run a procedure in every maximal -segment of simultaneously. Suppose we want to translate some segment in . It suffices to translate the start and endpoint of , identifying and . To identify , the amoebots in run the PASC algorithm with as the start point while transmitting on a global circuit. Each amoebot compares its distance to to , and the amoebot with distance equal to becomes . Afterward, the amoebots in establish a chain circuit between and , and send a beep that is received by all amoebots on the translated segment. Due to the size of the considered segments , this procedure can run for almost all segments within simultaneously without interference. The translation primitive moves the origin of a -wide shape on the axis and adds the line connecting the old and new origin locations.
Lemma 15.
Let be a -wide shape and an amoebot structure that stores a scale in a binary counter and knows . Given a direction on axis and , the amoebots can compute within rounds.
5.3 The Triangle Primitive
Finally, we show how to find the valid placements of triangles using the above primitives. Line shapes are scaled edges and triangles are scaled faces.
Definition 16.
Let be the shape consisting of the single triangular face spanned by the edges and . We define general triangle shapes as for and call the side length or size of .
To construct the valid placements of , we cover with the union of three parallelograms. The side lengths of the parallelograms are and . Two parallelograms are translated to reach the corners of the triangle. The algorithm can be summarized as follows: The amoebots first compute and on the binary counter storing . Then, they run the line primitive to compute the valid placements of three lines of length or . Next, they apply the Minkowski sum primitive to the three sets of line placements, resulting in the valid placements of three parallelograms. To translate two of the parallelograms, they run the translation primitive, which is applicable since the parallelograms have a width of at least on the translation axis (for a translation by , the valid placements can be moved by one more step in a single round using only local communication). Finally, they intersect the valid placements of all three parallelograms (union operation) to obtain the valid placements of the triangle.
Lemma 17.
Let be a triangle shape and let be an amoebot structure that stores in some binary counter. The amoebots can compute within rounds.
6 Shape Classification
We now generalize the idea of the triangle primitive to define the class of snowflake shapes, whose valid placements can be found efficiently using our primitives. Then, we discuss interesting subsets of these shapes and combine our valid placement search procedures with suitable scale factor search approaches to solve the shape containment problem.
6.1 Snowflake Shapes
Combining the primitives discussed in the previous section, we obtain the following class of shapes. Our definition identifies shapes with trees such that every node in the tree represents a shape and every edge represents a composition or transformation of shapes.
Definition 18.
A snowflake tree is a finite, non-empty tree with three node labeling functions , and that satisfies the following constraints. Every node represents a shape such that:
-
If , then is a leaf node and (line node).
-
If , then is a leaf node and , where (triangle node).
-
If , then , where are the children of and (union node).
-
If , then , where is the unique child of and (sum node).
-
If , then , where is the unique child of , has a minimal axis width on the axis of , and (translation node).
Let be the root of , then we say that is the snowflake shape represented by .
Note that this definition constrains the location of a snowflake’s origin. Because algorithms for the shape containment problem can place the origin of a shape freely, we may include equivalent shapes in the class of snowflakes. Our algorithms always place the origin by the definition. Fig. 5 shows examples for snowflakes and non-snowflake shapes.
To compute the valid placements of a snowflake, we apply the primitives from Section 5 following a topological ordering of the shape’s tree representation. This way, the amoebots first compute valid placements of primitive shapes (lines and triangles), and then they apply the union, Minkowski sum, and translation operations successively until they arrive at the valid placements of the shape represented by the root node. This sequence of operations is encoded in the state machine of each amoebot; we say that the amoebots “have access” to the shape and its tree representation.
Consider a snowflake represented by a tree with labelings , and . We assume that each amoebot has access to a representation of and a topological ordering of from the leaves to the root. The amoebots compute as follows:
-
1.
For every leaf , perform the placement search for the scaled primitive or represented by . Let be the resulting set of valid placements.
-
2.
Process each non-leaf node in the topological ordering as follows:
-
3.
Let be the root of . Terminate with success () and report the valid placements as if , otherwise terminate with failure ().
Lemma 19.
Let be an amoebot structure storing a scale in some binary counter and let be a snowflake. Given an encoding of the tree of with a topological ordering, the amoebots can compute for within rounds.
The class of snowflake shapes is the result of our primitive operations and is therefore somewhat artificial. However, it contains a large variety of shapes, and its modular definition provides a framework for constructing efficient valid placement search algorithms for more shapes. For example, any shape that is composed of parallelograms with the same orientation is a snowflake, even if the parallelograms are only connected at the corners. This is because a parallelogram is both -wide and -wide, where is the axis of . Therefore, the translation primitive can be used to move the shape’s origin to any position in the parallelogram, after which the union primitive allows the addition of another parallelogram at this position. Since this maintains the width properties, it can be repeated until all parallelograms have been added to the shape. A similar method is possible for shapes composed of hexagons because hexagons are even wide on all three axes. Constructing shapes out of building blocks like parallelograms is a popular approach for shape formation in grid-based modular robot systems [19, 3]. Shapes in square grid models can be represented by parallelograms in the triangular grid. Furthermore, any valid placement search algorithm for non-snowflake shapes can be integrated into this framework as a primitive to expand the set of shapes.
6.2 Star Convex Shapes
To combine our valid placement search procedure with a scale factor search, we would like to know for which shapes the binary search approach is applicable. Recall from Section 4 that at least self-contained shapes permit a binary search. In this section, we characterize this class of shapes exactly as the star convex shapes.
Definition 20.
A shape is star convex if it is hole-free and contains a center node such that for every , all shortest paths from to in are contained in .
For example, all convex shapes are star convex since all their nodes are centers. It is easy to see that star convex shapes are self-contained: When placing the origin of on a center node, no translation is necessary and holds for all . We can even show that only star convex shapes are self-contained. As the authors of [15] point out in their extensive survey on starshaped sets (see p. 1007), the results in [18] show that these two properties are equivalent in much more general settings when rotations are omitted.
Theorem 21.
A shape is self-contained if and only if it is star convex.
The main proof and supporting lemmas can be found in Appendix B. In our context, this equivalence implies that the efficient binary search can only be applied directly to star convex shapes. For any non-star convex shape , there exist an amoebot structure and scale factors , , such that for all but for some ; consider, e.g., for sufficiently large and . The proof of Theorem 21 shows that this always holds for infinitely many scales .
6.3 Shape Containment Solutions
Finally, we obtain algorithms solving the shape containment problem by combining valid placement search procedures with suitable scale factor search methods. First, we observe that star convex shapes are snowflakes:
Lemma 22.
Every star convex shape is equivalent to a snowflake. If its origin is a center node, itself is a snowflake.
This implies that we can solve the shape containment problem for a star convex shape in just rounds by using a binary search. For a snowflake that is not star convex, we apply the linear search approach, which runs valid placement searches when given some upper bound . To obtain this upper bound, we use the observation that a snowflake without faces will always be a union of line shapes meeting at the origin, and therefore star convex. Thus, a non-star convex snowflake must contain at least one face, so is a suitable upper bound (for any ). Since is star convex, can be computed in rounds. And since a triangle fills an area, we have , so we have an upper bound of . Together, we obtain the following theorem (see Appendix C for the proof):
Theorem 23.
Let be an amoebot structure and a snowflake shape. Given a tree representation of , the amoebots can compute in a binary counter and determine for all within rounds if is star convex and rounds otherwise, where .
7 Conclusion and Future Work
In this paper, we introduced the shape containment problem for the amoebot model of programmable matter and presented sublinear solutions using reconfigurable circuits. We showed that for some shapes, there is a lower bound of rounds due to the arbitrary distribution of valid and invalid placements, even if the maximum scale is known. Using efficient methods of transferring information using circuits, we constructed the class of snowflake shapes that can be solved in sublinear time and contains a large variety of shapes. For the subset of shapes that are star convex, we showed how to solve the problem in polylogarithmic time and proved that binary search is not generally applicable to other shapes.
It is unclear how non-snowflake shapes can be characterized and what exactly distinguishes shapes that are affected by the lower bound from shapes with more efficient solutions, such as star convex shapes. It would be interesting to explore whether the lower bound can be improved when including the scale factor search. Naturally, efficient solutions for arbitrary shapes or other shape classes are of interest as well.
The related problems of finding the smallest scale at which a given shape contains the amoebot structure, as well as finding scales and placements with maximal overlap and minimal difference, could also be investigated to support shape formation algorithms. To expand the set of possible applications further, one could examine other, non-uniform scaling behaviors, perhaps allowing the shapes to maintain fine details at larger scales, similar to fractal shapes.
References
- [1] Pankaj K. Agarwal, Nina Amenta, and Micha Sharir. Largest Placement of One Convex Polygon Inside Another. Discrete & Computational Geometry, 19(1):95–104, 1998. doi:10.1007/PL00009337.
- [2] Md Abdul Aziz Al Aman, Raina Paul, Apurba Sarkar, and Arindam Biswas. Largest Area Parallelogram Inside a Digital Object in a Triangular Grid. In Reneta P. Barneva, Valentin E. Brimkov, and Giorgio Nordo, editors, Combinatorial Image Analysis - 21st International Workshop (IWCIA), volume 13348 of LNCS, pages 122–135, Cham, 2022. Springer. doi:10.1007/978-3-031-23612-9_8.
- [3] Greg Aloupis, Sébastien Collette, Erik D. Demaine, Stefan Langerman, Vera Sacristán, and Stefanie Wuhrer. Reconfiguration of Cube-Style Modular Robots Using O(log n) Parallel Moves. In Seok-Hee Hong, Hiroshi Nagamochi, and Takuro Fukunaga, editors, Algorithms and Computation, volume 5369 of Lecture Notes in Computer Science, pages 342–353, Berlin, Heidelberg, 2008. Springer. doi:10.1007/978-3-540-92182-0_32.
- [4] Matthias Artmann, Andreas Padalkin, and Christian Scheideler. On the shape containment problem within the amoebot model with reconfigurable circuits, 2025. doi:10.48550/arXiv.2501.16892.
- [5] Ahmed Amine Chafik, Jaafar Gaber, Souad Tayane, Mohamed Ennaji, Julien Bourgeois, and Tarek El Ghazawi. From Conventional to Programmable Matter Systems: A Review of Design, Materials, and Technologies. ACM Comput. Surv., 56(8):210:1–210:26, 2024. doi:10.1145/3653671.
- [6] Bernard Chazelle. The Polygon Containment Problem. Advances in Computing Research, 1(1):1–33, 1983.
- [7] Joshua J. Daymude, Robert Gmyr, Kristian Hinnenthal, Irina Kostitsyna, Christian Scheideler, and Andréa W. Richa. Convex Hull Formation for Programmable Matter. In Nandini Mukherjee and Sriram V. Pemmaraju, editors, 21st International Conference on Distributed Computing and Networking, ICDCN ’20, pages 1–10, New York, NY, USA, 2020. ACM. doi:10.1145/3369740.3372916.
- [8] Joshua J. Daymude, Andréa W. Richa, and Christian Scheideler. The canonical amoebot model: Algorithms and concurrency control. Distributed Computing, 36(2):159–192, 2023. doi:10.1007/s00446-023-00443-3.
- [9] Zahra Derakhshandeh, Shlomi Dolev, Robert Gmyr, Andréa W. Richa, Christian Scheideler, and Thim Strothmann. Brief Announcement: Amoebot - A New Model for Programmable Matter. In Proceedings of the 26th ACM Symposium on Parallelism in Algorithms and Architectures, pages 220–222, Prague, Czech Republic, 2014. ACM. doi:10.1145/2612669.2612712.
- [10] Giuseppe A. Di Luna, Paola Flocchini, Nicola Santoro, Giovanni Viglietta, and Yukiko Yamauchi. Shape formation by programmable particles. Distributed Computing, 33(1):69–101, 2020. doi:10.1007/s00446-019-00350-6.
- [11] Yuval Emek, Yuval Gil, and Noga Harlev. On the Power of Graphical Reconfigurable Circuits. In Dan Alistarh, editor, 38th International Symposium on Distributed Computing (DISC 2024), volume 319 of Leibniz International Proceedings in Informatics (LIPIcs), pages 22:1–22:16, Dagstuhl, Germany, 2024. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.DISC.2024.22.
- [12] Michael Feldmann, Andreas Padalkin, Christian Scheideler, and Shlomi Dolev. Coordinating Amoebots via Reconfigurable Circuits. Journal of Computational Biology, 29(4):317–343, 2022. doi:10.1089/cmb.2021.0363.
- [13] Melvin Gauci, Radhika Nagpal, and Michael Rubenstein. Programmable Self-disassembly for Shape Formation in Large-Scale Robot Collectives. In Roderich Groß, Andreas Kolling, Spring Berman, Emilio Frazzoli, Alcherio Martinoli, Fumitoshi Matsuno, and Melvin Gauci, editors, Distributed Autonomous Robotic Systems: The 13th International Symposium, volume 6 of Springer Proceedings in Advanced Robotics, pages 573–586, Cham, 2018. Springer. doi:10.1007/978-3-319-73008-0_40.
- [14] Kyle W. Gilpin. Shape Formation by Self-Disassembly in Programmable Matter Systems. Thesis, Massachusetts Institute of Technology, Cambridge, MA, USA, 2012.
- [15] G. Hansen, I. Herburt, H. Martini, and M. Moszyńska. Starshaped sets. Aequationes mathematicae, 94(6):1001–1092, 2020. doi:10.1007/s00010-020-00720-7.
- [16] Marvin Künnemann and André Nusser. Polygon Placement Revisited: (Degree of Freedom + 1)-SUM Hardness and an Improvement via Offline Dynamic Rectangle Union. In Joseph (Seffi) Naor and Niv Buchbinder, editors, Proceedings of the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), Proceedings, pages 3181–3201, Alexandria, VA, USA, 2022. SIAM. doi:10.1137/1.9781611977073.124.
- [17] Thiago de Castro Martins and Marcos de Sales Guerra Tsuzuki. Simulated annealing applied to the irregular rotational placement of shapes over containers with fixed dimensions. Expert Systems with Applications, 37(3):1955–1972, 2010. doi:10.1016/j.eswa.2009.06.081.
- [18] P. McMullen. Sets homothetic to intersections of their translates. Mathematika, 25(2):264–269, 1978. doi:10.1112/S0025579300009505.
- [19] Andreas Padalkin, Manish Kumar, and Christian Scheideler. Reconfiguration and Locomotion with Joint Movements in the Amoebot Model. In Arnaud Casteigts and Fabian Kuhn, editors, 3rd Symposium on Algorithmic Foundations of Dynamic Networks (SAND 2024), volume 292 of Leibniz International Proceedings in Informatics (LIPIcs), pages 18:1–18:20, Dagstuhl, Germany, 2024. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.SAND.2024.18.
- [20] Andreas Padalkin and Christian Scheideler. Polylogarithmic Time Algorithms for Shortest Path Forests in Programmable Matter. In Ran Gelles, Dennis Olivetti, and Petr Kuznetsov, editors, 43rd ACM Symposium on Principles of Distributed Computing, PODC ’24, pages 65–75, New York, NY, USA, 2024. ACM. doi:10.1145/3662158.3662776.
- [21] Andreas Padalkin, Christian Scheideler, and Daniel Warner. The Structural Power of Reconfigurable Circuits in the Amoebot Model. In Thomas E. Ouldridge and Shelley F. J. Wickham, editors, 28th International Conference on DNA Computing and Molecular Programming (DNA 28), volume 238 of Leibniz International Proceedings in Informatics (LIPIcs), pages 8:1–8:22, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.DNA.28.8.
- [22] Atish Das Sarma, Stephan Holzer, Liah Kor, Amos Korman, Danupon Nanongkai, Gopal Pandurangan, David Peleg, and Roger Wattenhofer. Distributed Verification and Hardness of Distributed Approximation. SIAM Journal on Computing, 41(5):1235–1265, 2012. doi:10.1137/11085178X.
- [23] Micha Sharir and Sivan Toledo. Extremal polygon containment problems. Computational Geometry, 4(2):99–118, 1994. doi:10.1016/0925-7721(94)90011-6.
- [24] Pierre Thalamy, Benoît Piranda, and Julien Bourgeois. A survey of autonomous self-reconfiguration methods for robot-based programmable matter. Robotics and Autonomous Systems, 120:103242, 2019. doi:10.1016/j.robot.2019.07.012.
- [25] Tommaso Toffoli and Norman Margolus. Programmable Matter: Concepts and Realization. International Journal of High Speed Computing, 05(02):155–170, 1993. doi:10.1142/S0129053393000086.
- [26] Lidong Yang, Jiangfan Yu, Shihao Yang, Ben Wang, Bradley J. Nelson, and Li Zhang. A Survey on Swarm Microrobotics. IEEE Transactions on Robotics, 38(3):1531–1551, 2022. doi:10.1109/TRO.2021.3111788.
Appendix A A Lower Bound for Finding Valid Placements
Theorem 5. [Restated, see original statement.]
There exists a shape such that for any choice of origin and every amoebot algorithm that terminates after rounds, there exists an amoebot structure for which the algorithm does not compute , even if is known.
Proof.
We use the shape with a long arm and a short arm connected by a diagonal edge, as depicted in Fig. 4. Let be an amoebot algorithm that terminates in rounds. For every , we will construct a set of amoebot structures such that for all and only one rotation matches at this scale. Let be arbitrary, then we construct as follows (see Fig. 6 for reference):
First, we place a parallelogram of width and height with its lower left corner at the origin and call this the first block. The first block contains amoebots and is shared by all . Let be the nodes occupied by the left side of the parallelogram, ordered from bottom to top. Next, we place a second parallelogram with width and height such that its right side extends the first block’s left side below the origin. This second block contains amoebots and is also the same for all structures. It is only connected to the first block by a single edge, . Let be the nodes one step to the left of the second block, again ordered from bottom to top.
We define as the set of amoebot structures that consist of these two blocks and additional amoebots on the positions , where . Thus, contains distinct structures. Now, consider placements of with maximum scale in any structure . For , there are exactly valid placements at scale , represented by the amoebots . The longest continuous lines of amoebots in have length and form the first block. In every valid placement, the longer arm of must occupy one of these lines, so no larger scales or other rotations are possible. If is not occupied for some , then is not a valid placement because the end of the shorter arm of would be placed on . At least one is always occupied, so the maximum scale of is for every . Observe that every structure has a unique configuration of valid placements of : if and only if and for some .
Next, consider the size of the structures in . The maximum number of amoebots is , obtained for . This means we have for large enough , i.e., for all and all .
Let be arbitrary and consider the final states of after has been executed on . Each amoebot must be categorized as either a valid or an invalid placement of . We can assume that this categorization is independent of any randomized decisions because otherwise, there would be a non-zero probability of false categorizations. Thus, the final state depends only on the structure itself. Recall that structures in only differ in the positions and every path between (or an occupied neighbor) and must traverse the single edge connecting the two blocks. We can assume that all communication happens via circuits (see Sec. 1.2). Since the first block is the same in all structures, the final states of only depend on the sequence of signals sent from the second block to the first block through . To compute the correct set of valid placements, each amoebot structure in therefore has to produce a unique sequence of signals: If for any two configurations, the same sequence of signals is sent through , the final states of will be identical, so at least one will be categorized incorrectly.
Let be the number of pins used by . Then, the number of different signals that can be sent via one edge in one round is , and the number of signal sequences that can be sent in rounds is . Therefore, to produce at least different sequences of signals, we require rounds. By the assumption that terminates after rounds, will produce at least one false result for sufficiently large .
It remains to be shown that the same arguments hold for all equivalent versions of that contain the origin. If the origin is placed on another node of the longer arm, the valid placement candidates are shifted to the right by or steps, respectively; everything else remains the same. If the origin is placed on the shorter arm of the shape, we switch the roles of the first and the second block. We place amoebots on all positions and use the right side of the first block as the controlling positions instead. The number and size of the resulting amoebot structures remain the same, so the same arguments hold as before.
Appendix B Self-Contained Shapes are Star Convex
To show the properties of star convex shapes, we will use the following equivalent characterization:
Lemma 24.
A shape is star convex with its origin as a center node if and only if is the union of parallelograms of the form and convex shapes of the form , where is obtained from by a clockwise rotation. The number of these shapes is linear in .
For the proof of Theorem 21, we first show several lemmas that provide the necessary tools. To start with, we show that non-star convex shapes cannot become star convex by scaling, and for a sufficiently large scale, every center candidate has a shortest path with a missing edge. It is clear that star convex shapes stay star convex after scaling (by Lemma 24), but non-star convex shapes gain new potential center nodes, making it less obvious why there still cannot be a center.
Lemma 25.
Let be an arbitrary non-star convex shape, then for every , is not star convex, and for and every node , there exists a shortest path from to a node in with at least one edge not contained in .
Next, we show a fixed point property that is particularly useful for scales and .
Lemma 26.
Let be a shape and a scale such that there exists a with . Then, must be in and we call a fixed node of . Further, for every node , a shortest path from to is also a shortest path from to and vice versa.
Finally, we eliminate the need for covering rotations by showing that for sufficiently large scales and , does not fit into for any unless is rotationally symmetric.
Definition 27.
A shape is called rotationally symmetric with respect to (or -symmetric) if there exists a translation such that .
Note that covers all possible rotational symmetries in the triangular grid and -symmetry is equivalent to - and -symmetry combined. Additionally, the translation is unique. Also note that -symmetry is more commonly called -fold symmetry, -symmetry is known as -fold symmetry and -symmetry is known as -fold symmetry.
Lemma 28.
Let be a shape and be arbitrary. If is not -symmetric, then there is a scale such that for every , does not fit into .
Using these lemmas, we can now prove the main theorem about self-contained and star convex shapes:
Theorem 21. [Restated, see original statement.]
A shape is self-contained if and only if it is star convex.
Proof.
First, let be star convex with center node and consider two scale factors . By Lemma 24, can be represented as
where the are parallelograms and the are Minkowski sums of parallelograms with triangles. Then, we have and since each of the and is a convex shape. We choose such that , then each of the constituent shapes of is contained in its counterpart in . This already shows that every star convex shape is self-contained.
Now, let be a shape that is not star convex. We will show that is not self-contained by finding a scale such that for every and , . Using Lemma 25, we can assume that for every node , there exists a shortest path to a node such that at least one edge of is not contained in . If this is not the case for already, we simply consider as the new base shape.
By Lemma 28, we can find large enough that no non-zero rotation of fits into for any scale unless is rotationally symmetric. In this case, however, the rotated version of is the same as a translation of , so we can disregard rotations altogether because they do not affect the existence of valid translations of in .
Let be the convex hull of and let be its diameter. Consider any scale and some placement such that . By Lemma 26, . As argued above, there is a node such that a shortest path from to has at least one edge that is not contained in . We choose and such that the last edge is missing, w.l.o.g. Let be the predecessor of on , i.e., the missing edge of connects and . Since does not contain , it cannot contain the two incident faces. Thus, there is an area in the shape of a regular parallelogram with side length whose diagonal is and whose interior does not intersect , i.e., only its edges could be covered by edges of (see Fig. 7). These edges are incident to and and they lie on different axes than . By Lemma 26, the grid distance between and is the length of , which is bounded by . By the choice of , the distance between and (which is ) is therefore greater than the distance between and . Now, observe that for any node on one of the parallelogram’s edges incident to , the distance to remains . Thus, cannot lie on any of these two edges.
Furthermore, recall from Lemma 26 that any shortest path from to is also a (translated) shortest path from to . Because such a path contains at least one edge parallel to , every shortest path from to contains at least one edge in the opposite direction of . Therefore, since the edges of the empty parallelogram that are incident to lie on different axes than , cannot lie on these two edges either. The direction of also implies that must be on the side of the two edges that is closer to .
Together, these constraints imply that lies inside the parallelogram that is not contained in , so the placement identified by does not satisfy , contradicting our assumption. Since this works for every choice of , there is no placement of in .
Appendix C Main Theorem
Theorem 23. [Restated, see original statement.]
Let be an amoebot structure and a snowflake shape. Given a tree representation of , the amoebots can compute in a binary counter and determine for all within rounds if is star convex and rounds otherwise, where .
Proof.
The amoebots first establish binary counters on all maximal segments in , for all axes. At least one of these will be large enough to store as long as is non-trivial. In the following, they use all these counters simultaneously and deactivate every counter exceeding its memory during an operation.
Consider the case where is star convex. By Lemma 8, combined with Lemma 19, the amoebots can compute using a binary search and find all valid placements at all six rotations within rounds. Now, let be a snowflake that is not star convex. In this case, must contain at least one triangular face because all snowflakes without faces are unions of lines meeting at the origin, which are star convex (observe that the Minkowski sum of an edge with a line on a different axis always contains some faces). Then, is an upper bound for . The amoebots can compute within rounds and store it in binary counters, since triangles are star convex. A simple linear search for yields the runtime of by Lemma 6. follows from the fact that the number of nodes covered by grows quadratically with .
