Expand description
§Multi-agent pathfinding
Multi-agent pathfinding (MAPF): one path per agent on a shared graph, without collisions, minimizing a joint objective.
An Instance is a Graph (such as a Grid or an AdjacencyList) and a list
of Agents with distinct starts and goals. Time is discrete; each step an agent moves
along an edge or waits, at cost 1. After its path ends, an agent stays at its goal and
keeps blocking it. Two agents Conflict if they share a vertex at the same time or
swap vertices along an edge.
cbs(): conflict-based search, optimal forsum_of_costsormakespan(Objective), with prioritized conflicts, bypass, the CG, DG or WDG heuristic (CbsHeuristic), a conflict avoidance table and disjointSplitting;cbs_withandCbsConfigswitch them individually.cbs_ta(): CBS with task assignment over aTaskInstance, whose agents each have candidate goals; optimal over all assignments, with everyCbsConfigimprovement (cbs_ta_with).focbs(): FOCBS for aUaInstance, where some agents have no goal and only must get out of the way; CBS over the agents with goals and a min-cost flow oracle for the others, optimal for the goal agents’ sum of costs (focbs_with,UaResult).ecbs(): enhanced CBS, bounded-suboptimal within aWeightw, with focal search at both levels.icts(): increasing cost tree search with pairwise pruning, optimal.mstar(): recursive M* with operator decomposition (subdimensional expansion), optimal, and able to prove unsolvability;mstar_withandMStarConfigselect basic M*, recursive M* without operator decomposition, and OD-M*.epea(): enhanced partial expansion A* in the joint space, optimal, and able to prove unsolvability; it generates only the children at a node’s storedf.lns2(): MAPF-LNS2, large neighborhood search that repairs a plan with collisions a few agents at a time; seeded (Lns2Config), neither optimal nor complete.pibt(): priority inheritance with backtracking, one time step for all agents at a time; very fast, neither optimal nor complete.pibt_turns(): PIBT*_T, PIBT for agents that face a heading, move only forward and need time to turn, on anyOrientedGraphsuch as aGrid(TurnResult).pbs(): priority-based search, fast but neither optimal nor complete.mo_cbs,mo_cbs_withandmo_cbs_per_agent, with themulti-objectivefeature: multi-objective CBS (MO-CBS and MO-CBS-t, over BOA* or NAMOA*dr), every Pareto-optimal plan when moves and waits cost vectors, shared or per agent, with an opt-in feasibility check, conflict prioritization, bypass and disjoint splitting.
Every solver but lns2(), pibt() and pibt_turns(), which only seek a feasible
plan, and focbs(), which minimizes the sum of costs, takes an Objective: sum of
costs or makespan.
space_time_astar: the single-agent low level underConstraints, built on theheuristic-searchcrate’s A*.first_conflictandconflicts: conflict detection on any set of paths.parse_map,parse_scenarioandscenario_instance: Moving AI benchmarks.
Every solver but focbs() (a UaResult) returns a MapfResult (pibt_turns()
inside a TurnResult with the headings): an Outcome (with a Solution if solved)
and high-level Stats. Budget, Limits and Stats are re-exported from
heuristic-search; they bound and count the high-level expansions. Weight is too.
The crate is no_std and needs only alloc.
§Example
use mapf_search::{Agent, Grid, Instance, Limits, Objective, cbs, first_conflict};
// Two agents swap the ends of a corridor that has one side pocket.
let grid = Grid::parse(&["...", "@.@"]);
let agents = vec![
Agent { start: grid.vertex(0, 0), goal: grid.vertex(2, 0) },
Agent { start: grid.vertex(2, 0), goal: grid.vertex(0, 0) },
];
let instance = Instance::new(grid, agents)?;
let result = cbs(&instance, Objective::SumOfCosts, Limits::expansions(1_000));
let solution = result.solution().expect("the pocket lets them pass");
assert_eq!(first_conflict(&solution.paths), None);
assert_eq!(solution.sum_of_costs, 7);Repository: https://github.com/sunsided/mapf-search
Structs§
- Adjacency
List - A graph stored as one list of out-neighbours per vertex.
- Agent
- One agent: where it starts and where it must end up and stay.
- CbsConfig
- What
cbs_withoptimizes and which improvements it uses. - Constraint
Set - The constraints of one agent, indexed for the checks of a space-time search.
- Grid
- A rectangular 4-connected grid. Cells are vertices in row-major order,
y * width + x; blocked cells are vertices without edges. - Instance
- A validated MAPF instance.
- Limits
- Simple counter limits. The default is unlimited.
- Lns2
Config - The settings of
lns2. - MStar
Config - What
mstar_withoptimizes and which form of M* it runs. - Mapf
Result - The result of a solver run.
- MoCbs
Config - How
mo_cbs_withorders the high-level search, which low level it uses and which improvements it applies. - Pareto
Result - The result of an
mo_cbsrun. - Pareto
Solution - One Pareto-optimal joint plan.
- Parse
Error - A syntax error in a Moving AI file.
- Scenario
Entry - One agent of a Moving AI
.scenfile. - Solution
- A conflict-free plan: one path per agent.
- Stats
- Counters collected during one search run.
- Task
Agent - One agent of a
TaskInstance: where it starts and the goals it may be assigned. - Task
Instance - A validated task-assignment MAPF instance: each agent must end at one of its candidate goals, and no two agents at the same one.
- Turn
Result - The result of a
pibt_turnsrun. - UaInstance
- A validated instance of MAPF with unassigned agents (MAPF-UA): agents with a goal, and agents with only a start that may end anywhere but must not get in the way.
- UaResult
- The result of a
focbsrun. - UaSolution
- A plan for a
UaInstance. - Weight
- A rational heuristic weight
w = numerator / denominatorfor Weighted A*.
Enums§
- CbsHeuristic
- An admissible estimate of how much the sum of costs of a constraint-tree node must still
rise (
CbsConfig::heuristic). - Conflict
- A conflict between the paths of two agents.
- Constraint
- Forbids or requires one agent one vertex or one move at one time.
- Instance
Error - Why
Instance::new,TaskInstance::neworUaInstance::newrejected an instance. - LowLevel
- Which multi-objective search the low level runs.
- Objective
- What a multi-agent search minimizes.
- Outcome
- How a solver run ended.
- Pareto
Outcome - How an
mo_cbsrun ended. - Parse
Error Kind - What is wrong in a
ParseError. - Scenario
Error - Why
scenario_instancecould not build an instance. - Splitting
- How CBS splits a conflict between agents
aandb(CbsConfig::splitting). - UaOutcome
- How a
focbsrun ended.
Traits§
- Budget
- Decides when a search must stop before it finishes, given its counters so far.
- Graph
- A finite directed graph over vertices
0..vertex_count(). - Oriented
Graph - A
Graphon which agents face a heading and only move forward, for solvers that model turning in place as taking time (pibt_turns).
Functions§
- cbs
- Finds a conflict-free plan that is optimal for
objectivewith conflict-based search, with every improvement ofCbsConfig::improved. - cbs_ta
- Assigns each agent one of its candidate goals and finds a conflict-free plan to them,
optimal for
objectiveover all assignments and plans, with conflict-based search with task assignment and every improvement ofCbsConfig::improved. - cbs_
ta_ with - Assigns each agent one of its candidate goals and finds a conflict-free plan to them,
optimal for
config.objectiveover all assignments and plans, with conflict-based search with task assignment and the improvementsconfigselects. - cbs_
with - Finds a conflict-free plan that is optimal for
config.objectivewith conflict-based search and the improvementsconfigselects. - conflicts
- All conflicts among
paths, in the order offirst_conflict. - ecbs
- Finds a conflict-free plan whose
objectivevalue is at mostweighttimes the optimum, with enhanced conflict-based search. - epea
- Finds a conflict-free plan with the optimal
objectivevalue with enhanced partial expansion A* in the joint space. - first_
conflict - The earliest conflict among
paths, indexed by agent: smallest time first, then the smallest agent pair, and a vertex conflict before a swap starting at the same time. - focbs
- Plans the assigned agents of
instancewith the least sum of costs that still lets the unassigned agents get out of the way, and routes those at the fewest moves, with FOCBS and every improvement ofCbsConfig::improved. - focbs_
with - Plans the assigned agents of
instancewith the least sum of costs that still lets the unassigned agents get out of the way, and routes those at the fewest moves, with FOCBS and the improvementsconfigselects. - icts
- Finds a conflict-free plan with the optimal
objectivevalue by increasing cost tree search. - lns2
- Finds a conflict-free plan with MAPF-LNS2: an initial plan that may have collisions, then large neighborhood search that replans a few agents at a time until no two paths collide.
- makespan
- The largest
path_costof all paths: when the last agent arrives for good.0for no paths. - mo_cbs
mo_cbs_withwithMoCbsConfig::improved: every Pareto-optimal plan ofinstance.- mo_
cbs_ per_ agent mo_cbs_withwith one cost function per agent:costs(agent, from, to)is what the move (or, iffrom == to, the wait) costsagent.- mo_
cbs_ with - Multi-objective CBS: every cost-unique Pareto-optimal plan of
instanceunder the vector costscosts, shared by all agents (seemo_cbs), searched asconfigsays. - mstar
- Finds a conflict-free plan with the optimal
objectivevalue with recursive M* and operator decomposition (MStarConfig::od_recursive). - mstar_
with - Finds a conflict-free plan with the optimal
config.objectivevalue with the form of M* thatconfigselects. - parse_
map - Parses a Moving AI
.mapfile into aGrid. - parse_
scenario - Parses a Moving AI
.scenfile: aversionline, then one entry per line with nine whitespace-separated fields (seeScenarioEntry). Empty lines are skipped. - path_
cost - The cost of one path: the time of its final arrival at its last vertex.
- pbs
- Finds a conflict-free plan with priority-based search, aiming at a low
objectivevalue. - pibt
- Finds a conflict-free plan with PIBT: one time step for every agent at a time, by priority, with priority inheritance and backtracking.
- pibt_
turns - Finds a conflict-free plan for agents that need time to turn, with PIBT*_T: one step for all agents at a time, by priority, with priority inheritance, backtracking, cycle handling, swaps and the push escape trigger.
- position_
at - The vertex
pathoccupies attime, counting the stay at the last vertex. - scenario_
instance - Builds an instance from the first
agentsentries of a scenario ongrid. - space_
time_ astar - The cheapest path of
agentongraphthat satisfiesconstraintsand ends at the goal for good (goal-stay: no later constraint forbids the goal). - sum_
of_ costs - The sum of the
path_costs of all paths.
Type Aliases§
- AgentId
- Index of an agent in
Instance::agents. - Heading
- The direction an agent faces on an
OrientedGraph, belowOrientedGraph::heading_count. - Path
- The positions of one agent at
t = 0, 1, .... Never empty in a solution. - Time
- A time step. Time starts at
0. - Vertex
- A vertex id. Graphs number their vertices densely as
0..vertex_count().