4. Methodology
As mentioned previously, we have not identified a direct method to decompose a MAPF instance into multiple subproblems. Thus, we initiate the process with an initial decomposition, progressively refining it to generate smaller subproblems while ensuring that each step pass the mentioned solvability check. We define two types of subproblems encountered in various stages: clusters, which have no restrictions on the order of solving, and levels, which impose limitations on the order of solving.
The decomposition of a MAPF instance involves three steps:
1, identifying all agents’ dependence path and establishing initial clusters based on them;
2, refining agent dependencies to bipartition clusters until they cannot be further divided into smaller clusters;
3, further refining agent dependencies to decompose clusters into levels and sorting.
An overview of the decomposition process of a MAPF instance is depicted in
Figure 1.
Following decomposition, we explore methods to solve subproblems independently and then combine their results to obtain a conflict-free solution for the original MAPF instance, as detailed in
Section 4.4.
4.1. Decomposetion to clusters
The first step is to determine the connectivity graph from a grid space and the related agents . We then determine initial clusters based on the dependence paths derived from the connectivity graph.
Definition 7. Relevance of two agents: If an agent ’s dependence path contains another agent ’s start or target, we consider those two agents as relevant, regardless of whether ’s dependence path contains ’s start or target.
It is noteworthy that the relevance of two agents is determined by their dependence paths, so whether two agents are relevant changes as their dependence paths change.
Definition 8. Graph of agents’ relevance : an undirected graph where nodes represent agents and edges represent whether two agents are relevant.
It is important to note that the relevance of two agents is determined by , , and . While the subgraph is constant, and are variables, meaning that the relevance between two agents may change as these sets are modified.
Essentially, based on the definition of a cluster, a cluster is a maximal connected component in . Intuitively, a cluster is a set of agents from the raw MAPF instance, where any agents within it are only relevant to agents within the same set (based on their dependence paths). Additionally, we refer to an agent set that constitutes a cluster as an independent agent set.
An intuitive way to obtain clusters is by generating clusters from the graph of agent’s relavance determined by the dependence paths that visit the fewest number of agents for each agent. We refer to such clusters as initial clusters(Line 1 ∼ 8 in Algorithm 1). An example about initialize of clusters are shown in
Figure 9.
However, it is evident that selecting dependence paths containing the fewest agents may not always result in the smallest possible clusters, as it does not consider how to guide dependence paths to avoid agents from other clusters.
There is room for decomposing these initial clusters into smaller ones by updating the dependence paths of agents. Thus, we propose a method to iteratively bipartition initial clusters until further subdivision is not possible, aiming to minimize the size of subproblems. More details about bipartitioning can be found in the following section. This process ensures the legality of decomposition, and the more bipartitioning steps, the better the results obtained, although it does not guarantee the discovery of the optimal decomposition. An overview of the process of decomposing an instance into clusters is outlined in Algorithm 1.
Figure 9.
These figures show the initialization of clusters in a simple instance. Figure A illustrates the instance, where white cells represent passable cells and grey cells represent unpassable cells. The notations “” and “” denote the start and target states of agent . Figure B displays the simplified connectivity graph of agents. Figure C shows the relevant agents for each agent, and Figure D presents the graph of agent relevance ().
Figure E shows the initial clusters determined by the graph of agent relevance, i.e., all connected components in .
Figure 9.
These figures show the initialization of clusters in a simple instance. Figure A illustrates the instance, where white cells represent passable cells and grey cells represent unpassable cells. The notations “” and “” denote the start and target states of agent . Figure B displays the simplified connectivity graph of agents. Figure C shows the relevant agents for each agent, and Figure D presents the graph of agent relevance ().
Figure E shows the initial clusters determined by the graph of agent relevance, i.e., all connected components in .
4.2. Bipartition of Clusters
This section is dedicated to decomposing a cluster into two smaller clusters. However, before delving into the decomposition process, it’s essential to introduce some necessary concepts.
Definition 9. Unavoidable agents of an agent a in a cluster r refer to those agents within r that must be traversed by a’s dependence path. In other words, these agents must belong to the same cluster and cannot be further divided.
For example, for the instance in
Figure 8,
and
are unavoidable agents of
, as
’s dependence path must pass through
and
.
Definition 10. Unavoidance graph of a cluster: an undirected representation of whether one agent is unavoidable to another agent within the cluster. Assume there are two agent and , is unavoidable to if ’s dependence path must pass ’s start or target, meanwhile all dependence paths cannot pass a agent’s start or target if the agent is not in current cluster. It is important to note that for a given cluster r, its unavoidance graph is unique.
Figure 10.
These figures demonstrate the process of bipartitioning cluster
, as mentioned in
Figure 9. Figure A illustrates the unavoidable agents for each agent. Figure B shows the related unavoidance graph
. Figures C, D, and E depict steps 2, 3, and 4 in the bipartition process of the cluster.
Figure 10.
These figures demonstrate the process of bipartitioning cluster
, as mentioned in
Figure 9. Figure A illustrates the unavoidable agents for each agent. Figure B shows the related unavoidance graph
. Figures C, D, and E depict steps 2, 3, and 4 in the bipartition process of the cluster.
Both the unavoidance graph and the relevance graph depict relationships between agents within the cluster.
Definition 11. Maximum unavoidable agents of cluster: the largest connected component of the unavoidance graph associated with the cluster.
Intuitively, these maximum unavoidable agents represent the largest undividable subset within the current cluster, are referred to as “major set" during the cluster bipartition process. Agents within the cluster, excluding those belonging to the maximum unavoidable agents, are referred to as “remaining set" during the cluster bipartition process. An example of the maximum unavoidable agents of a cluster can be found in Figure 10.
It is noteworthy that during the bipartition process, agents in the remaining set will be moved to the major set, but agents in the remaining set will not move into the major set until both the major set and the remaining set are independent.
The bipartition of a cluster comprises four steps:
1, identify the maximum unavoidable agents of the cluster, referred to as the major set (Line 1 ∼ 12 in Algorithm 2);
2, examine each agent in the remaining set to determine if its dependence path must pass through agents of the major set. Move agents meeting this criterion to the major set, until the remain set is independent or empty(Line 16 ∼ 27 in Algorithm 2);
3, check any newly added agents to the major set to ascertain if their dependence paths must pass through agents in the remaining set. Transfer such agents from agents the remaining set to the major set, until the major set is independent(Line 29 ∼ 40 in Algorithm 2);
4, verify whether the major set and the remaining set both meet the legality requirements of the cluster (for every agent in a cluster, its dependence path does not pass through the start or target states of agents in other clusters). If they do (or if the remaining set is empty), exit and return the major set and the remaining set as the result of the bipartition. (Line 42 ∼ 44 in Algorithm 2) Otherwise, proceed to step 2;
The bipartition process of a cluster concludes when both sets satisfy the cluster’s requirements, or when there are no remaining agents, indicating that the cluster cannot be further decomposed into smaller clusters.
The pseudocode for bipartitioning a cluster is outlined in Algorithm 2. An example of the bipartition of a cluster is shown in
Figure 10. The verification of the legality of these clusters is shown in
Figure 11.
4.3. Decomposing to Levels and Sorting
Clusters can be solved irrespective of the order of solving, thus providing an opportunity to decompose MAPF into smaller problems by considering the order of solving. By considering the order of solving, we can divide two agents into different subproblems even if one agent’s dependence path contains the start or target of another agent. We refer to these smaller problems decomposed from clusters as levels. In this section, we focus on how to decompose clusters into levels and determine the order of solving. To facilitate this discussion, we introduce some new concepts.
Definition 12. Order of solving agents: If an agent must be solved before another agent , we denote it as ; if must be solved later than , we denote it as .
It is important to note that both and can coexist (indicating that both agents must be solved in the same problem) or neither can exist (indicating no order limitation between solving and ).
The order of solving agents is determined by whether an agent’s dependence path contains another agent’s start or target. If
’s dependence path contains
’s start, it implies that
must be solved later than
to ensure that
’s start is not occupied (to enable
and
could be in different subproblem). Conversely, if
’s dependence path contains
’s target,
must be solved before
to ensure that
’s target is not occupied. Furthermore, the order of solving levels is determined by the order of solving agents within them.
|
Algorithm 1 Decomposition instance to clusters |
-
Input:
-
Output
- 1:
determine initial clusters
- 2:
; dependence path of all agents
- 3:
for i = 1, 2,...,k do
- 4:
;
- 5:
end for
- 6:
get from P;
- 7:
get initial clusters
- 8:
= all connected components of ;
- 9:
; final clusters
- 10:
fordo
- 11:
;
- 12:
while do
- 13:
= Bipartition of cluster ();
- 14:
add to ;
- 15:
;
- 16:
end while
- 17:
end for
- 18:
return;
|
Definition 13. Solving order graph of a cluster: a directed graph representing whether an agent must be solved before another agent. Its nodes are agents, and edges indicate the order of solving between agents. The structure of the solving order graph is determined by each agent’s dependence path. Specifically, if agent must be solved before agent , the corresponding edge in is denoted as .
An example of the solving order graph can be found in
Figure 12.
Essentially, a level is a strongly connected component of . Intuitively, a level is a group of agents that form a loop in , meaning that the agents within the loop must be solved simultaneously. For example, if three agents, A, B, and C, are in the same loop such that , it implies that A must be solved before B, B before C, and C before A. Therefore, A, B, and C must be solved together in parallel. Unlike clusters, where the order of solving is arbitrary, the order of solving levels is strictly determined.
The order of solve levels is determine by the edge in that connect them.
The order of solving levels is determined by the edges in that connect them.
Definition 14. Order of solving levels: if a level must be solved before another level , we denote it as ; if must be solved later than , we denote it as .
Definition 15. Level ordering graph is a directed graph whose nodes are levels, and edges indicate whether a level must be solved earlier than another level. If there is no edge connecting two levels, this implies that there is no explicit order to solve them, although there may be an implicit order. For example, if level A has no edge connecting to level C, but level A is connected to level B (A > B) and level B is connected to level C (B > C), it implies that level A must be solved earlier than level C.
Essentially, serves as a condensed version of .
There are five steps involved in decomposing a cluster into multiple levels and determining the order of solving:
|
Algorithm 2 Bipartition of cluster |
-
Input
-
Output
- 1:
step 1
- 2:
;
- 3:
fordo
- 4:
for do
- 5:
if then
- 6:
if then
- 7:
add as an edge to ;
- 8:
end if
- 9:
end if
- 10:
end for
- 11:
end for
- 12:
= largest connected component of ;
- 13:
;
- 14:
whiledo
- 15:
step 2
- 16:
;
- 17:
while do
- 18:
for do
- 19:
if , then
- 20:
move from to ;
- 21:
add to ;
- 22:
end if
- 23:
end for
- 24:
if is independent is empty then
- 25:
break;
- 26:
end if
- 27:
end while
- 28:
step 3
- 29:
while do
- 30:
for do
- 31:
if then
- 32:
consider belong to cluster r, following search path always success
- 33:
);
- 34:
move agents in () from to ;
- 35:
end if
- 36:
end for
- 37:
if is independent then
- 38:
break;
- 39:
end if
- 40:
end while
- 41:
step 4
- 42:
if both and are independent then
- 43:
break;
- 44:
end if
- 45:
end while
- 46:
return;
|
|
Algorithm 3 Decomposing to levels and sorting |
-
Input
-
Output
- 1:
determine initial dependence paths
- 2:
; means agent a’s denpendence path
- 3:
for agent a in r do
- 4:
;
- 5:
add to P;
- 6:
end for
- 7:
get from P;
- 8:
determine all loop in via strong component detect;
- 9:
sort levels;
- 10:
construct graph via ;
- 11:
= level in that not later than other level;
- 12:
set order of all level to 0;
- 13:
= ;
- 14:
while levels is not empty do
- 15:
= ∅;
- 16:
for level in levels do
- 17:
for another_level that later than level in do
- 18:
if ’s order ≤ level’s order then
- 19:
’s order = level’s order + 1;
- 20:
add to ;
- 21:
end if
- 22:
end for
- 23:
end for
- 24:
= ;
- 25:
end while
- 26:
return all levels in the order of last visit to them;
|
|
Algorithm 4 Merge results |
-
Input
assume there are m subproblems and their solution is
-
Output
- 1:
set last occupied time of all cells to 0;
- 2:
for each solution P in do
- 3:
while True do
- 4:
t=1; current time index
- 5:
check whether insert wait action to P
- 6:
= False;
- 7:
= True;
- 8:
for path p in P do
- 9:
if t > size of then
- 10:
don’t check path that have reach target
- 11:
continue;
- 12:
else
- 13:
= False;
- 14:
end if
- 15:
means path p’s location at time t
- 16:
if last occupied time of then
- 17:
= True;
- 18:
break;
- 19:
end if
- 20:
end for
- 21:
if all_finished then
- 22:
break;
- 23:
end if
- 24:
insert wait action to all path in P
- 25:
if need_wait then
- 26:
for path p in P do
- 27:
if t > size of then
- 28:
continue;
- 29:
end if
- 30:
repeat in p at time index t;
- 31:
end for
- 32:
else
- 33:
update last occupied time of cells
- 34:
for path p in P do
- 35:
if t > size of then
- 36:
continue;
- 37:
end if
- 38:
set last occupied time of to t;
- 39:
end for
- 40:
end if
- 41:
t = t + 1;
- 42:
end while
- 43:
end for
- 44:
return;
|
|
Algorithm 5 Layered MAPF |
-
Input
, MAPF
-
Output
P
- 1:
1, decomposition of MAPF instance
- 2:
construct from ;
- 3:
R = Decomposing to cluster();
- 4:
;
- 5:
for cluster r in R do
- 6:
= Decomposing to leve and sorting(r, );
- 7:
merge to L;
- 8:
end for
- 9:
= ∅;
- 10:
2, solve subproblems
- 11:
forl in L do
- 12:
if MAPF is serial then
- 13:
set later subproblem’s start in to unpassable;
- 14:
= MAPF();
- 15:
add to ;
- 16:
reset ;
- 17:
else
- 18:
set previous subproblem’s target and later subproblem’s start in to unpassable;
- 19:
= MAPF();
- 20:
add to ;
- 21:
reset ;
- 22:
end if
- 23:
end for
- 24:
3, merge solutions of subproblems
- 25:
if MAPF is serial then
- 26:
P = ;
- 27:
else
- 28:
P = Merge results();
- 29:
end if
- 30:
returnP;
|
1, determine each agent’s dependence path, and available agents constrained to the agents of the current cluster (Line 1 ∼ 6 in Algorithm 3);
2, obtain the solving order graph from the dependence paths of the current cluster(Line 7 in Algorithm 3);
3, identify all strong components of as levels (Line 8 in Algorithm 3);
4, determine the relationships between levels by examining the edges that connect them. Construct the level ordering graph , which represents the order of solving between level (Line 9 ∼ 10 in Algorithm 3);
5, set levels that are not later than any other levels as root levels. Then, using Breadth First Search, traverse all levels in , where the order of the last visit to each level represents the order of solving them (Line 11 ∼ 25 in Algorithm 3).
In implementation, Tarjan’s algorithm [
26] is utilized to determine strongly connected components from a directed graph.
It is important to note that after completing all steps of decomposition, we ensure that the final subproblems do not compromise legality. The entire process of decomposing into levels and sorting them is depicted in Algorithm 3. An example of decomposing a cluster into levels can be found in
Figure 12.
4.4. Solving and Combining
After completing the decomposition of a MAPF instance, the next step involves considering how to solve the subproblems separately and combine their results without conflicts. There are two main types of MAPF methods: serial MAPF methods and parallel MAPF methods. Serial MAPF methods, such as CBS-based methods, can use external paths as constraints to avoid conflicts, as they search for an agent’s path while the paths of other agents remain static. On the other hand, parallel MAPF methods, such as LaCAM and PIBT, cannot always treat external paths as dynamic obstacles to avoid, as they may avoid the same state (all agents’ locations) occur multiple times. For simplicity in this article, we do not set external paths as dynamic obstacles to avoid for all parallel MAPF methods.
In serial MAPF methods, we only need to merge separate results into a single set. However, for the second type of MAPF method, we need to add wait actions in the resulting paths to avoid conflicts between paths from different subproblems, as shown in Algorithm 4.
In detail, this algorithm maintains a table that records the last visited time step for each cell, in order to determine whether a subproblem’s solution collides with the solution of a previous subproblem. Starting from , it checks each agent’s solution to see if it conflicts with the solution of a previous subproblem (Lines 1 to 20 in Algorithm 4). If a solution collides with another solution at time t, a wait action is added at t to resolve the conflict (Lines 24 to 32 in Algorithm 4). Otherwise, the table is updated, and the algorithm checks whether there is a conflict with other solutions at time (Lines 33 to 39 in Algorithm 4), continuing until the last state is reached (i.e., the process is finished). Once all solutions are completed, the algorithm exits (Lines 21 to 23 in Algorithm 4).
In the following, we define serial MAPF as MAPF, and parallel MAPF methods as MAPF, where represents agents and P represents external paths that need to be avoided.
The overall process of decomposing a MAPF instance into multiple subproblems (Line 1 ∼ 9 in Algorithm 5), solving the subproblems (Line 10 ∼ 23 in Algorithm 5), and merging their results (Line 24 ∼ 29 in Algorithm 5) is illustrated in Algorithm 5.
As mentioned earlier, our algorithm aims to minimize the loss of solvability in subproblems by introducing a legality check. Although we have not provided a theoretical analysis regarding the percentage of solvability loss, we offer empirical analysis based on extensive testing. This is detailed in the comparison between Layered LaCAM2 and raw LaCAM2 in
Section 6.
4.5. Time Complexity Analysis
• Construction of connectivity graph
As mentioned in “Data Structures and Network Algorithms”[
27], since Tarjan’s algorithm visits each node and edge only once, the time complexity of detecting connected components in a graph
is
.
Assuming a MAPF instance ( = 2), the map’s width and height are w and h, respectively. It contains at most cells and edges (when all cells are passable). Therefore, the time complexity to determine the of an instance is . By extension, for a MAPF instance with , the time complexity to determine is , where n represents the total number of states (e.g., for = 2, n is the area of the map; for = 3, n is the volume of the map).
• Variants of path search
As mentioned earlier, the number of nodes in
is
, where
k is the number of agents. In the worst case, the number of edges in
is
. According to Introduction to Algorithms [
28], the time complexity of BFS is
(where
and
represent the sizes of the nodes and edges, respectively). Therefore, the time complexity of
and
is
.
• Decomposing to clusters
In initialization of clusters, every agents need using one time. So the time complexity of are .
Considering there are k nodes and at most edges in the graph of an agent’s relevance, , and that the time complexity of detecting the connected components of a graph is .
In the best case, there are
k clusters, and each cluster has only one agent after detecting the connected components of
, so no further decomposition is needed. Therefore, the total time complexity of the decomposition in the best case is
(this usually happens in maps with sparse agents, such as the “warehouse-20-40-10-2-2" map and “Boston_0_256" in
Section 5). However, in the worst case, further decomposition is needed, such as the bipartition of clusters and decomposition into levels (like the “random-32-32-20" map and “room-32-32-4" in
Section 5).
In the bipartition of clusters, we first determine the complexity of decomposing a cluster into two clusters. Assuming there are m agents in a cluster, in the worst case, it takes calls to to determine that one agent needs to be moved from the remaining set to the major set, and agents need to be moved from the remaining set to the major set. Therefore, the time complexity of splitting one cluster into two clusters is .
Considering that the larger the cluster, the greater the time cost of splitting it, the worst case in the bipartition of clusters occurs when the major set always contains only one agent (i.e., maximizing the number of agents in the remaining set) until the remaining set is empty (as illustrated in
Figure 14). This requires
splits of a cluster into two clusters, where the number of agents in the clusters is
. Therefore, the time complexity of the bipartition of a cluster in the worst case is:
.
• Decomposition to level and sorting
In the initialization of levels, each agent needs to use once. For a cluster with m agents, the time complexity of is .
Considering there are m nodes and at most edges in , and that in the construction of , we need to run Tarjan’s algorithm on , whose time complexity is . Therefore, the time complexity for constructing is .
The time complexity of level sorting is determined by a BFS search, so its complexity depends on the size of the level-ordering graph. In the worst case, each level contains only one agent, and there are m levels in , resulting in at most edges in . Since the time complexity of both DFS and BFS is , the time complexity of level sorting in the worst case is .
Considering that , the time complexity for decomposing a cluster with m agents into levels is .
So, in summary, considering the total number of agents in all clusters is k, the worst-case time complexity of decomposing all clusters into levels is .
• Combining results
As mentioned before, serial MAPF methods can take extra paths as constraints to avoid (e.g., EECBS), so no extra actions are needed to merge subproblem solutions. However, parallel MAPF methods (e.g., LaCAM) need to add wait actions to avoid conflicts between the solutions of different subproblems.
For a MAPF instance with k agents, assuming there are m subproblems, let the number of agents in the i-th subproblem be denoted as , and the makespan of their solution as for . In the worst case, every subproblem needs to add wait actions equal to the sum of the previous subproblem’s makespan to ensure collision-free execution (i.e., waiting until all agents from previous subproblems have arrived at their targets, except for the first subproblem, as described in the simplified scenario). Thus, the total number of added wait actions in the worst case is . Assuming there is an upper bound on the makespan, T, we have: . Therefore, the time complexity in the worst case is .
It is noteworthy that the makespan of solutions varies across different MAPF methods, so the time cost of merging results also differs depending on the method used.