1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! # 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 [`Agent`]s 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 for [`sum_of_costs`] or [`makespan`]
//! ([`Objective`]), with prioritized conflicts, bypass, the CG, DG or WDG heuristic
//! ([`CbsHeuristic`]), a conflict
//! avoidance table and disjoint [`Splitting`]; [`cbs_with`] and [`CbsConfig`] switch
//! them individually.
//! - [`cbs_ta()`]: CBS with task assignment over a [`TaskInstance`], whose agents each have
//! candidate goals; optimal over all assignments, with every [`CbsConfig`] improvement
//! ([`cbs_ta_with`]).
//! - [`focbs()`]: FOCBS for a [`UaInstance`], 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 a [`Weight`] `w`, 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_with`] and [`MStarConfig`] select
//! 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 stored `f`.
//! - [`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 any [`OrientedGraph`] such as a [`Grid`] ([`TurnResult`]).
//! - [`pbs()`]: priority-based search, fast but neither optimal nor complete.
//! - `mo_cbs`, `mo_cbs_with` and `mo_cbs_per_agent`, with the `multi-objective` feature:
//! 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 under [`Constraint`]s, built on the
//! `heuristic-search` crate's A*.
//! - [`first_conflict`] and [`conflicts`]: conflict detection on any set of paths.
//! - [`parse_map`], [`parse_scenario`] and [`scenario_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);
//! # Ok::<(), mapf_search::InstanceError>(())
//! ```
//!
//! Repository: <https://github.com/sunsided/mapf-search>
extern crate alloc;
/// Doctests for the code examples in README.md (not part of the API).
pub use ;
pub use ;
pub use ;
pub use ecbs;
pub use epea;
pub use ;
pub use ;
pub use icts;
pub use ;
pub use ;
pub use space_time_astar;
pub use ;
pub use ;
pub use ;
pub use ;
pub use pbs;
pub use pibt;
pub use ;
pub use ;