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.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*.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 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 returns a MapfResult: 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);Not yet implemented: CBS-TA, MAPF-LNS2 and EPEA*.
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.
- 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.
- 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::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).
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().
Functions§
- cbs
- Finds a conflict-free plan that is optimal for
objectivewith conflict-based search, with every improvement ofCbsConfig::improved. - 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. - 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. - icts
- Finds a conflict-free plan with the optimal
objectivevalue by increasing cost tree search. - 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. - 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. - 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().