Push and Swap is a complete algorithm for solving the Multi-Agent Path Finding (MAPF) problem on general graphs, where agents are treated as indistinguishable and operate under a 'pebble motion' model. Its core innovation is using a series of local, reversible maneuvers—'push' and 'swap'—to rearrange agents in tightly constrained, densely packed workspaces where direct paths are blocked. The algorithm guarantees a solution if one exists, making it particularly valuable for warehouse robotics and logistics automation where space is a premium.
Glossary
Push and Swap

What is Push and Swap?
Push and Swap is a complete, decentralized algorithm for solving Multi-Agent Path Finding (MAPF) on graphs, specifically designed for densely packed environments where agents must rearrange themselves to reach goals.
The algorithm operates in two main phases. First, it attempts to 'push' agents toward their goals along shortest paths, creating temporary chains of movement. When a deadlock occurs—such as two agents needing to pass each other in a narrow corridor—it executes a 'swap' maneuver. This involves moving agents into a designated buffer vertex to exchange positions, a operation proven to always be possible on a biconnected graph. This local reasoning allows Push and Swap to avoid the exponential complexity of full joint-space search, providing a scalable, suboptimal but complete solution for complex rearrangement puzzles.
Key Characteristics of Push and Swap
Push and Swap is a complete, rule-based algorithm for solving Multi-Agent Path Finding (MAPF) on graphs, designed to operate in densely packed, grid-like environments where agents are often initially adjacent to their goals.
Algorithmic Completeness
Push and Swap is formally proven to be complete for any solvable MAPF instance on a graph, meaning it is guaranteed to find a solution if one exists. This distinguishes it from many heuristic or sampling-based approaches that may fail to find a solution even when one is present. Its completeness relies on a structured set of local operations that can systematically rearrange agents in strongly connected graphs, even in highly congested scenarios.
Core Maneuvers: Push & Swap
The algorithm is built around two fundamental, local operations:
- Push: Moves a chain of agents along a path to create an empty vertex (a "hole"). This is the primary method for repositioning agents.
- Swap: Exchanges the positions of two adjacent agents. This is the essential operation for resolving deadlocks where agents are mutually blocking each other's goals. These maneuvers are applied iteratively according to a set of priority rules to guide each agent toward its destination without creating unsolvable gridlock.
Operation in Dense Congestion
A defining strength of Push and Swap is its effectiveness in densely packed environments where the ratio of agents to free space is high. Unlike algorithms that require significant free space for maneuvering, Push and Swap uses the agents themselves as movable obstacles to create temporary pathways. It is particularly well-suited for warehouse rack aisles or factory floor grids where agents start very close to their target locations but are interleaved.
Graph Requirements & Limitations
The algorithm's guarantees hold under specific topological conditions:
- Graph must be biconnected: The environment must remain connected even if any single vertex is removed. This ensures the "hole" created by a Push operation can always be moved.
- At least one empty vertex: The algorithm requires at least one unoccupied starting location (a "hole") to initiate the Push maneuver. These requirements make it ideal for well-connected grid or lattice workspaces but less suitable for environments with narrow corridors or choke points that violate biconnectivity.
Decentralized Execution Potential
While often analyzed as a centralized algorithm, the rule-based nature of Push and Swap allows for decentralized or distributed implementations. Each agent can execute the Push and Swap rules based on local observations of its immediate neighbors and a shared priority ordering. This aligns with modern multi-agent system principles where agents operate with limited communication, making it relevant for scalable fleet orchestration where central coordination is a bottleneck.
Relation to Other MAPF Methods
Push and Swap occupies a unique niche within the MAPF taxonomy:
- *Vs. Search-based (CBS, MAA)**: It is rule-based, not search-based, avoiding exponential growth in joint state space. It provides completeness but not optimality guarantees on metrics like Sum of Costs.
- Vs. Reactive (ORCA): It is a planned, deterministic algorithm, not a reactive collision avoidance scheme. It solves the full problem from start to goal, not just instantaneous velocity selection.
- Vs. Prioritized Planning: It does not assign a fixed, global priority. Priorities are dynamic and local, derived from the rule set, allowing more complex interactions than simple sequential planning.
Push and Swap vs. Other MAPF Algorithms
A feature and performance comparison of the Push and Swap algorithm against other prominent centralized and decentralized approaches to Multi-Agent Path Finding (MAPF).
| Feature / Metric | Push and Swap | Optimal Centralized (e.g., CBS, MAA*) | Decoupled / Prioritized (e.g., Priority Planning) | Reactive (e.g., ORCA, VO) |
|---|---|---|---|---|
Algorithmic Paradigm | Centralized, rule-based | Centralized, search-based | Decoupled, sequential | Decentralized, reactive |
Solution Guarantee (Completeness) | ||||
Solution Optimality | ||||
Primary Performance Metric | Makespan (suboptimal) | Sum of Costs (SOC) or Makespan | Makespan or SOC | Collision avoidance success rate |
Scalability (Agent Count) | High (dense graphs) | Low to Medium (< 100 agents) | Medium | Very High |
Handles Dense, Packed Environments | ||||
Requires Global Coordination | ||||
Online Replanning Capability | ||||
Typical Use Case | Warehousing (rearrangement) | Robotics research, small fleets | Structured logistics | Crowd simulation, drones |
Practical Applications of Push and Swap
The Push and Swap algorithm excels in dense, grid-based environments where agents are tightly packed and must rearrange themselves to reach goals. Its core operations provide robust solutions for specific industrial challenges.
Warehouse Pallet Rearrangement
In automated storage and retrieval systems (AS/RS), robots must frequently access pallets stored in dense grid racks. Push and Swap is directly applicable for retrieving a target pallet blocked by others. The algorithm systematically executes push maneuvers to create temporary space and swap maneuvers to reposition blocking agents, enabling the retrieval robot to reach its goal without requiring empty slots. This minimizes the need for large, inefficient buffer zones within the racking system.
Container Yard Management
Port container yards are classic examples of tightly packed grid environments. Transfer cranes (the agents) must navigate to specific containers, which are often buried behind others. Push and Swap provides a complete method for planning the sequence of moves where containers (modeled as agents) are temporarily relocated. The swap operation is crucial here, allowing two adjacent containers to exchange positions, a common requirement for creating access lanes in extremely congested layouts without predefined empty slots.
Multi-Robot Parking Garages
For fully automated valet parking systems, a fleet of autonomous mobile robots (AMRs) must park and retrieve customer vehicles in a structured, grid-like garage. Push and Swap algorithms plan the coordinated movements to extract a target vehicle blocked by others. The local push and swap maneuvers correspond to the precise, low-speed movements required to shuffle vehicles within the confined space of a parking bay, ensuring all vehicles remain accessible.
Electronics Manufacturing Lines
In circuit board assembly, components are placed by robots on panels that move through stations. If a panel must be reworked, it may need to be routed back through the line, requiring other panels to be temporarily moved. Modeling panels as agents on a linear or grid-like track, Push and Swap can plan the deadlock-free reshuffling in buffer zones to prioritize the rework panel without halting the entire production flow, utilizing the limited buffer space efficiently.
Game Level Design & Puzzle Solving
Beyond physical robotics, Push and Swap provides the foundational logic for a class of video game puzzles and Sokoban-like problems. The algorithm guarantees a solution exists for any solvable configuration of movable blocks (agents) and empty spaces (holes) on a graph. Game engines can use it to:
- Verify level solvability during design.
- Generate hint systems by computing the next optimal push/swap move.
- Power AI-controlled characters in games requiring cooperative block-pushing puzzles.
Modular Reconfigurable Robotics
Systems composed of identical modular robots that can connect and disconnect to form structures must often rearrange themselves. Push and Swap offers a planning framework for modules moving on the surface of a structure. A module can push a line of connected modules (like a train) and swap positions with an adjacent module. This enables complex self-reconfiguration tasks, such as changing the shape of a robotic swarm or repairing a structure by replacing a faulty module from within.
Frequently Asked Questions
Push and Swap is a complete algorithm for solving Multi-Agent Path Finding (MAPF) on graphs, designed for densely packed environments. It uses a series of local maneuvers to rearrange agents into their goal positions.
Push and Swap is a complete, decentralized algorithm for solving the Multi-Agent Path Finding (MAPF) problem on general graphs, specifically designed for environments where agents are densely packed. It operates by executing a sequence of two fundamental local operations: 'push' maneuvers, which move an agent along an empty path, and 'swap' maneuvers, which allow two adjacent agents to exchange positions. The algorithm's completeness guarantee means it will always find a solution if one exists, without requiring a centralized planner to search the entire joint state space, making it scalable for large fleets in constrained workspaces like warehouse aisles or grid-based floors.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Push and Swap operates within the broader field of Multi-Agent Path Finding (MAPF). These related concepts define the algorithmic landscape, performance metrics, and alternative strategies for coordinating multiple agents.
Multi-Agent Path Finding (MAPF)
The foundational computational problem that Push and Swap solves. MAPF seeks collision-free paths for multiple agents from start to goal locations in a shared graph or grid environment. Core challenges include:
- Optimality: Minimizing metrics like Makespan or Sum of Costs (SOC).
- Completeness: Guaranteeing a solution will be found if one exists.
- Scalability: Managing the exponential growth of the joint state space as agent count increases.
Conflict-Based Search (CBS)
A leading optimal algorithm often contrasted with Push and Swap. CBS is a two-level search:
- High-level: Searches a constraint tree, where each node imposes constraints (e.g., "Agent A cannot be at vertex V at time T") to resolve conflicts.
- Low-level: Plans individual paths for each agent using a fast single-agent solver like A*, respecting the current constraints. It guarantees optimality but can be computationally heavy in dense, highly coupled environments where Push and Swap's local maneuvers excel.
Cardinal Conflict
The most severe type of conflict in MAPF, central to understanding algorithmic complexity. A Cardinal Conflict occurs between two agents where any resolution (e.g., making one agent wait) unavoidably increases the Sum of Costs. This represents an irreducible cost addition. Algorithms like CBS must branch on these conflicts. Push and Swap's completeness relies on its ability to perform non-cost-preserving swaps and pushes to resolve such deadlocks in dense packing scenarios.
Makespan vs. Sum of Costs
The two primary optimality criteria for evaluating MAPF solutions like those from Push and Swap.
- Makespan: The total time until the last agent reaches its goal. Minimizing makespan focuses on overall throughput.
- Sum of Costs (SOC): The sum of each agent's individual path length or travel time. Minimizing SOC focuses on total fleet effort or energy use. Push and Swap is complete (finds a solution if one exists) but is not designed for optimality under these metrics, prioritizing solvability in dense, complex graphs.
Windowed Hierarchical Cooperative A* (WHCA*)
A scalable, suboptimal algorithm used in large-scale or lifelong MAPF settings. WHCA* operates by:
- Planning paths for each agent within a short, fixed-duration time window.
- Using a reservation table to avoid collisions within that window.
- Replanning periodically as agents move. It contrasts with Push and Swap's approach: WHCA* is decentralized and fast for open spaces but can deadlock in tightly packed scenarios where Push and Swap's systematic swaps guarantee progress.
Multi-Value Decision Diagram (MDD)
A compact data structure used to reason about agent paths in optimal MAPF algorithms. An MDD for a single agent encodes all possible optimal paths from start to goal within a given cost bound (e.g., shortest path length).
- Each layer of the MDD corresponds to a timestep.
- Nodes represent possible locations at that time. Algorithms like CBS and ICTS use MDDs for efficient conflict detection and reasoning. While not directly used in Push and Swap, understanding MDDs highlights the structured search space that Push and Swap navigates through local operations.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us