mapf-search 0.3.0

Multi-agent pathfinding on grids and graphs: CBS with its improvements, CBS-TA, FOCBS, ECBS, ICTS, PBS, PIBT, PIBT*_T, M*, EPEA*, MAPF-LNS2 and multi-objective MO-CBS
Documentation
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
//! FOCBS (Jin et al. 2026): flow-oracle conflict-based search for MAPF with unassigned
//! agents, over a [`UaInstance`] whose agents either have a goal (*assigned*) or only a
//! start (*unassigned*).
//!
//! CBS searches the paths of the assigned agents alone, ordered by their sum of costs. At
//! every conflict-free node a flow oracle ([`route`]) routes the unassigned agents around
//! those paths at the fewest moves, up to the latest arrival. If no routing exists, the
//! oracle's minimum cut names the reservations of assigned agents that block it, and the
//! node gets one child per blocker that forbids it to its agent (*flow-conflict
//! branching*): every plan below the node must release one of them.

use alloc::vec::Vec;

use heuristic_search::{Budget, Stats};

use super::{CbsConfig, Node, Search};
use crate::constraint::Constraint;
use crate::flow::{Blocker, Routing, route};
use crate::graph::{Graph, Vertex};
use crate::instance::UaInstance;
use crate::low_level::distance_tables;
use crate::path::{Objective, Path};
use crate::solution::{Outcome, Solution};

/// A plan for a [`UaInstance`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UaSolution {
    /// The paths of the assigned agents, indexed like [`UaInstance::assigned`]; its sum of
    /// costs is the objective FOCBS minimizes.
    pub assigned: Solution,
    /// The paths of the unassigned agents, indexed like [`UaInstance::unassigned`], each up
    /// to the latest arrival of an assigned agent, trimmed of trailing waits; the agent
    /// stays at its last vertex.
    pub unassigned: Vec<Path>,
    /// The number of moves of the unassigned agents, the least possible for these assigned
    /// paths.
    pub unassigned_moves: u32,
}

/// How a [`focbs`] run ended.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum UaOutcome {
    /// A conflict-free plan for every agent.
    Solved(UaSolution),
    /// Proven unsolvable: an assigned agent cannot reach its goal even alone, or the search
    /// ran out of options.
    Unsolvable,
    /// The [`Budget`] stopped the search; the instance may be unsolvable.
    LimitReached,
}

/// The result of a [`focbs`] run.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UaResult {
    /// How the run ended.
    pub outcome: UaOutcome,
    /// High-level counters, as for [`cbs_with`](crate::cbs_with); blocker splits count as
    /// expansions.
    pub stats: Stats,
}

impl UaResult {
    /// The plan, if one was found.
    #[must_use]
    pub fn solution(&self) -> Option<&UaSolution> {
        match &self.outcome {
            UaOutcome::Solved(solution) => Some(solution),
            UaOutcome::Unsolvable | UaOutcome::LimitReached => None,
        }
    }
}

/// Plans the assigned agents of `instance` with 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 of [`CbsConfig::improved`].
///
/// See [`focbs_with`] for the guarantee and the budget.
///
/// # Examples
///
/// ```
/// use mapf_search::{Agent, Grid, Limits, UaInstance, focbs};
///
/// // An idle robot waits in a corridor with a side pocket; the other one must pass.
/// let grid = Grid::parse(&["...", "@.@"]);
/// let crossing = Agent { start: grid.vertex(0, 0), goal: grid.vertex(2, 0) };
/// let instance = UaInstance::new(grid.clone(), vec![crossing], vec![grid.vertex(1, 0)])?;
///
/// let result = focbs(&instance, Limits::expansions(1_000));
/// let solution = result.solution().expect("the idle robot steps into the pocket");
/// assert_eq!(solution.assigned.sum_of_costs, 2);
/// assert_eq!(solution.unassigned, [vec![grid.vertex(1, 0), grid.vertex(1, 1)]]);
/// assert_eq!(solution.unassigned_moves, 1);
/// # Ok::<(), mapf_search::InstanceError>(())
/// ```
pub fn focbs<G: Graph>(instance: &UaInstance<G>, budget: impl Budget<Stats>) -> UaResult {
    focbs_with(instance, CbsConfig::improved(Objective::SumOfCosts), budget)
}

/// Plans the assigned agents of `instance` with 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 improvements `config` selects.
///
/// The guarantee is the paper's *sequential* optimality: the assigned paths have the least
/// sum of costs among all that leave a conflict-free routing for the unassigned agents, and
/// the routing has the fewest moves *for those paths* (not necessarily over all plans with
/// that sum of costs). The unassigned agents only need to be conflict-free until the
/// latest arrival of an assigned agent; after it nobody moves.
///
/// `budget` is asked before every constraint-tree expansion and before every oracle call.
/// On an unsolvable instance the search may run until its budget, as CBS does.
///
/// # Panics
///
/// Panics if `config.objective` is [`Objective::Makespan`]: FOCBS minimizes the sum of
/// costs.
pub fn focbs_with<G: Graph>(
    instance: &UaInstance<G>,
    config: CbsConfig,
    mut budget: impl Budget<Stats>,
) -> UaResult {
    assert_eq!(
        config.objective,
        Objective::SumOfCosts,
        "FOCBS minimizes the sum of costs"
    );

    let assigned = instance.assigned();
    let mut search = Search::forest(
        instance.graph(),
        assigned.iter().map(|agent| agent.start).collect(),
        assigned.iter().map(|agent| agent.goal).collect(),
        distance_tables(instance.graph(), assigned),
        None,
        config,
    );
    search.trees.push((0..assigned.len()).collect());
    search.unassigned = Some(Unassigned {
        starts: instance.unassigned().to_vec(),
        routing: None,
    });

    let outcome = match search.run(&mut budget) {
        Outcome::Solved(solution) => {
            let routing = search
                .unassigned
                .and_then(|unassigned| unassigned.routing)
                .expect("a solved node was routed");
            UaOutcome::Solved(UaSolution {
                assigned: solution,
                unassigned: routing.paths,
                unassigned_moves: routing.moves,
            })
        }
        Outcome::Unsolvable => UaOutcome::Unsolvable,
        Outcome::LimitReached | Outcome::Exhausted => UaOutcome::LimitReached,
    };

    UaResult {
        outcome,
        stats: search.stats,
    }
}

/// The unassigned agents of a FOCBS run.
pub(super) struct Unassigned {
    /// Their starts.
    starts: Vec<Vertex>,
    /// The routing of the node that solved the instance, once found.
    routing: Option<Routing>,
}

impl<G: Graph> Search<'_, G> {
    /// Returns `true` if popping `node` ends the search without further work: it is
    /// conflict-free and there are no unassigned agents to route (the oracle still runs for
    /// an empty set, trivially, to record its routing).
    pub(super) fn is_final(&self, node: &Node) -> bool {
        let nobody = self
            .unassigned
            .as_ref()
            .is_none_or(|unassigned| unassigned.starts.is_empty());

        node.conflict.is_none() && nobody
    }

    /// Routes the unassigned agents around the paths of the conflict-free `node`: `None`
    /// if that works (or there are none), else the blockers of the oracle's cut.
    pub(super) fn route_unassigned(&mut self, node: &Node) -> Option<Vec<Blocker>> {
        let unassigned = self.unassigned.as_mut()?;
        match route(self.graph, &node.paths, &unassigned.starts) {
            Ok(routing) => {
                unassigned.routing = Some(routing);
                None
            }
            Err(blockers) => Some(blockers),
        }
    }

    /// Flow-conflict branching: one child of `parent` per blocker, each forbidding the
    /// blocker to its agent; without any child, the node is dropped.
    ///
    /// Every blocker is a reservation of a path of `parent`, which satisfies its
    /// constraints, so none is forbidden already.
    pub(super) fn expand_blockers(&mut self, parent: &Node, blockers: &[Blocker]) {
        self.stats.expanded += 1;

        for constraint in blockers.iter().map(|&blocker| releasing(blocker)) {
            debug_assert!(
                !parent.constraints.contains(&constraint),
                "a blocker is a reservation the node allows"
            );
            if let Some(child) = self.child(parent, constraint) {
                self.push(child.node);
            }
        }
    }
}

/// The constraint that releases `blocker`.
///
/// Never a vertex at step 0: the only arcs into the first layer leave the source towards
/// the unassigned starts, which no path holds, so no cut separates a fixed start.
fn releasing(blocker: Blocker) -> Constraint {
    match blocker {
        Blocker::Vertex {
            agent,
            vertex,
            time,
        } => {
            debug_assert!(time > 0, "the starts are never cut");
            Constraint::Vertex {
                agent,
                vertex,
                time,
            }
        }
        Blocker::Move {
            agent,
            from,
            to,
            time,
        } => Constraint::Edge {
            agent,
            from,
            to,
            time,
        },
    }
}

#[cfg(test)]
mod tests {
    //! FOCBS against a brute-force joint search over all agents.

    use super::*;
    use alloc::collections::{BTreeMap, BinaryHeap};
    use alloc::vec;
    use core::cmp::Reverse;

    use heuristic_search::Limits;
    use proptest::prelude::*;

    use crate::cbs::cbs_with;
    use crate::conflict::first_conflict;
    use crate::graph::Grid;
    use crate::instance::{Agent, Instance};
    use crate::path::{Time, path_cost, position_at};

    /// The expansion budget of the runs in these tests.
    const BUDGET: u64 = 5_000;

    /// The expansion budget on instances the joint search proves unsolvable. On those FOCBS
    /// can only run into its budget, and each expansion routes a flow, so the full budget
    /// made the property test take minutes. As in the integration tests' property tests.
    const UNSOLVABLE_BUDGET: u64 = 60;

    /// A joint state: each assigned agent's vertex and finished flag, then each unassigned
    /// agent's vertex.
    type Joint = (Vec<(Vertex, bool)>, Vec<Vertex>);

    /// The least sum of costs of the assigned agents over all conflict-free joint plans, by
    /// Dijkstra over joint states with goal-stay pricing (an unfinished assigned agent pays
    /// 1 per step, finishing at its goal is free, unassigned agents move for free); `None`
    /// if no plan exists.
    fn optimal_sst(instance: &UaInstance<Grid>) -> Option<u32> {
        let start: Joint = (
            instance
                .assigned()
                .iter()
                .map(|a| (a.start, false))
                .collect(),
            instance.unassigned().to_vec(),
        );
        let mut best = BTreeMap::from([(start.clone(), 0_u32)]);
        let mut open = BinaryHeap::from([Reverse((0_u32, start))]);
        while let Some(Reverse((cost, state))) = open.pop() {
            if best.get(&state).is_some_and(|&known| known < cost) {
                continue;
            }

            if state.0.iter().all(|&(_, finished)| finished) {
                return Some(cost);
            }

            for (next, step) in successors(instance, &state) {
                let total = cost + step;
                if best.get(&next).is_none_or(|&known| total < known) {
                    best.insert(next.clone(), total);
                    open.push(Reverse((total, next)));
                }
            }
        }

        None
    }

    /// The conflict-free joint steps from `state`, each with its cost.
    fn successors(instance: &UaInstance<Grid>, state: &Joint) -> Vec<(Joint, u32)> {
        let grid = instance.graph();
        let options = |vertex: Vertex| {
            let mut next = vec![vertex];
            grid.neighbors(vertex, |n| next.push(n));
            next
        };

        let mut choices: Vec<Vec<(Vertex, bool, u32)>> = Vec::new();
        for (&(vertex, finished), agent) in state.0.iter().zip(instance.assigned()) {
            choices.push(if finished {
                vec![(vertex, true, 0)]
            } else {
                let mut list: Vec<_> = options(vertex).into_iter().map(|n| (n, false, 1)).collect();
                if vertex == agent.goal {
                    list.push((vertex, true, 0));
                }
                list
            });
        }

        for &vertex in &state.1 {
            choices.push(options(vertex).into_iter().map(|n| (n, false, 0)).collect());
        }

        let from: Vec<Vertex> = state
            .0
            .iter()
            .map(|&(v, _)| v)
            .chain(state.1.iter().copied())
            .collect();
        let mut found = Vec::new();
        let mut pick = vec![0; choices.len()];
        loop {
            let to: Vec<Vertex> = pick
                .iter()
                .zip(&choices)
                .map(|(&i, list)| list[i].0)
                .collect();
            if is_free(&from, &to) {
                let assigned = instance.assigned().len();
                let next = (
                    (0..assigned)
                        .map(|a| (to[a], choices[a][pick[a]].1))
                        .collect(),
                    to[assigned..].to_vec(),
                );
                let cost = (0..assigned).map(|a| choices[a][pick[a]].2).sum();
                found.push((next, cost));
            }

            let Some(position) = (0..pick.len()).find(|&k| pick[k] + 1 < choices[k].len()) else {
                break;
            };
            pick[position] += 1;
            pick[..position].fill(0);
        }

        found
    }

    /// Returns `true` if moving every agent `from -> to` has no vertex conflict and no swap.
    fn is_free(from: &[Vertex], to: &[Vertex]) -> bool {
        (0..to.len()).all(|a| {
            (a + 1..to.len()).all(|b| {
                to[a] != to[b] && !(from[a] == to[b] && from[b] == to[a] && from[a] != to[a])
            })
        })
    }

    /// The fewest moves the unassigned agents need around the fixed `assigned` paths until
    /// the latest arrival, by Dijkstra over their joint positions and the step.
    fn fewest_moves(instance: &UaInstance<Grid>, assigned: &[Path]) -> Option<u32> {
        let horizon: Time = assigned.iter().map(|p| path_cost(p)).max().unwrap_or(0);
        let idle = |here: &[Vertex]| {
            UaInstance::new(instance.graph().clone(), Vec::new(), here.to_vec()).expect("valid")
        };
        let start = (0, instance.unassigned().to_vec());
        let mut best = BTreeMap::from([(start.clone(), 0_u32)]);
        let mut open = BinaryHeap::from([Reverse((0_u32, start))]);
        while let Some(Reverse((cost, (time, here)))) = open.pop() {
            if time == horizon {
                return Some(cost);
            }

            let fixed = |at: Time| assigned.iter().map(move |p| position_at(p, at));
            let from: Vec<Vertex> = fixed(time).chain(here.iter().copied()).collect();
            for ((_, next), _) in successors(&idle(&here), &(Vec::new(), here.clone())) {
                let to: Vec<Vertex> = fixed(time + 1).chain(next.iter().copied()).collect();
                if !is_free(&from, &to) {
                    continue;
                }

                let moves = here.iter().zip(&next).filter(|(a, b)| a != b).count();
                let total = cost + u32::try_from(moves).expect("few agents");
                let key = (time + 1, next);
                if best.get(&key).is_none_or(|&known| total < known) {
                    best.insert(key.clone(), total);
                    open.push(Reverse((total, key)));
                }
            }
        }

        None
    }

    /// Up to 3 agents on a grid of 2-3 by 2-3 cells with walls, 1-2 of them assigned.
    fn instance() -> impl Strategy<Value = UaInstance<Grid>> {
        (
            2_usize..=3,
            2_usize..=3,
            prop::collection::vec(prop::bool::weighted(0.15), 9),
            1_usize..=2,
            0_usize..=2,
        )
            .prop_flat_map(|(width, height, blocked, assigned, unassigned)| {
                let cells = width * height;
                let free: Vec<Vertex> = (0..cells).filter(|&v| !blocked[v]).collect();
                (
                    Just((width, height, blocked)),
                    Just(free.clone()).prop_shuffle(),
                    Just(free).prop_shuffle(),
                    Just((assigned, unassigned)),
                )
            })
            .prop_filter_map(
                "enough free cells",
                |((width, height, blocked), starts, goals, (assigned, unassigned))| {
                    if starts.len() < assigned + unassigned || assigned + unassigned > 3 {
                        return None;
                    }

                    let mut grid = Grid::new(width, height);
                    for vertex in (0..width * height).filter(|&v| blocked[v]) {
                        let (x, y) = grid.cell(vertex);
                        grid.block(x, y);
                    }

                    let agents = (0..assigned)
                        .map(|i| Agent {
                            start: starts[i],
                            goal: goals[i],
                        })
                        .collect();
                    let idle = starts[assigned..assigned + unassigned].to_vec();

                    UaInstance::new(grid, agents, idle).ok()
                },
            )
    }

    proptest! {
        #![proptest_config(ProptestConfig::with_cases(256))]

        /// FOCBS finds the least assigned sum of costs over all joint plans, with plain and
        /// improved CBS; its plan is conflict-free; and its unassigned routing has the
        /// fewest moves for its assigned paths.
        #[test]
        fn matches_a_joint_search(instance in instance(), improved in any::<bool>()) {
            let soc = Objective::SumOfCosts;
            let config = if improved { CbsConfig::improved(soc) } else { CbsConfig::plain(soc) };
            let expected = optimal_sst(&instance);
            let budget = if expected.is_some() { BUDGET } else { UNSOLVABLE_BUDGET };
            let result = focbs_with(&instance, config, Limits::expansions(budget));

            match (&result.outcome, expected) {
                (UaOutcome::Solved(solution), Some(cost)) => {
                    prop_assert_eq!(solution.assigned.sum_of_costs, cost);
                    let mut all = solution.assigned.paths.clone();
                    all.extend(solution.unassigned.iter().cloned());
                    prop_assert_eq!(first_conflict(&all), None);
                    for (path, agent) in solution.assigned.paths.iter().zip(instance.assigned()) {
                        prop_assert_eq!((path.first(), path.last()), (Some(&agent.start), Some(&agent.goal)));
                    }

                    for (path, &start) in solution.unassigned.iter().zip(instance.unassigned()) {
                        prop_assert_eq!(path.first(), Some(&start));
                    }

                    prop_assert_eq!(Some(solution.unassigned_moves), fewest_moves(&instance, &solution.assigned.paths));
                }
                (UaOutcome::Unsolvable | UaOutcome::LimitReached, None) | (UaOutcome::LimitReached, Some(_)) => {}
                (outcome, cost) => prop_assert!(false, "{outcome:?}, expected {cost:?}"),
            }
        }
    }

    /// The idle robot sits on the goal at the end of a corridor with a pocket. The
    /// conflict-free path alone (sum of costs 2) leaves it no way out, so the oracle's
    /// blockers force the assigned agent to wait once while the robot slips into the pocket.
    #[test]
    fn branches_on_blockers() {
        // `0 1 2` over `@ 4 @`; the assigned agent runs 0 -> 2, the robot sits at 2.
        let grid = Grid::parse(&["...", "@.@"]);
        let instance =
            UaInstance::new(grid, vec![Agent { start: 0, goal: 2 }], vec![2]).expect("valid");

        for config in [
            CbsConfig::plain(Objective::SumOfCosts),
            CbsConfig::improved(Objective::SumOfCosts),
        ] {
            let result = focbs_with(&instance, config, Limits::expansions(BUDGET));
            let solution = result.solution().expect("solvable");

            assert_eq!(Some(solution.assigned.sum_of_costs), optimal_sst(&instance));
            assert_eq!(solution.assigned.sum_of_costs, 3);
            assert_eq!(solution.unassigned, [vec![2, 1, 4]]);
            assert_eq!(solution.unassigned_moves, 2);
        }
    }

    /// On a one-way ring the robot can only move along; it leaves as the assigned agent
    /// arrives behind it.
    #[test]
    fn follows_directed_edges() {
        let ring = crate::graph::AdjacencyList::directed(3, &[(0, 1), (1, 2), (2, 0)]);
        let instance =
            UaInstance::new(ring, vec![Agent { start: 0, goal: 1 }], vec![1]).expect("valid");

        let result = focbs(&instance, Limits::expansions(BUDGET));
        let solution = result.solution().expect("solvable");

        assert_eq!(solution.assigned.paths, [vec![0, 1]]);
        assert_eq!(solution.unassigned, [vec![1, 2]]);
    }

    /// Without unassigned agents, FOCBS is CBS, with the same statistics, also when the
    /// budget runs out exactly as the solution is popped.
    #[test]
    fn without_unassigned_agents_is_cbs() {
        let grid = Grid::parse(&["...", "@.@"]);
        let agents = vec![Agent { start: 0, goal: 2 }, Agent { start: 2, goal: 0 }];
        let ua = UaInstance::new(grid.clone(), agents.clone(), Vec::new()).expect("valid");
        let plain = Instance::new(grid, agents).expect("valid");

        for config in [
            CbsConfig::plain(Objective::SumOfCosts),
            CbsConfig::improved(Objective::SumOfCosts),
        ] {
            let needed = cbs_with(&plain, config, Limits::NONE).stats.expanded;
            for budget in 0..=needed {
                let focbs = focbs_with(&ua, config, Limits::expansions(budget));
                let cbs = cbs_with(&plain, config, Limits::expansions(budget));

                assert_eq!(
                    focbs.solution().map(|s| &s.assigned),
                    cbs.solution(),
                    "budget {budget}"
                );
                assert_eq!(focbs.stats, cbs.stats);
            }
        }
    }

    /// No agents at all, and only unassigned ones, are solved without moves.
    #[test]
    fn trivial_instances() {
        let empty = UaInstance::new(Grid::new(2, 2), Vec::new(), Vec::new()).expect("valid");
        let idle = UaInstance::new(Grid::new(2, 2), Vec::new(), vec![0, 3]).expect("valid");

        let none = focbs(&empty, Limits::NONE);
        let parked = focbs(&idle, Limits::NONE);

        assert_eq!(none.solution().map(|s| s.unassigned_moves), Some(0));
        assert_eq!(
            parked.solution().map(|s| s.unassigned.clone()),
            Some(vec![vec![0], vec![3]])
        );
    }

    /// `Objective::Makespan` is rejected.
    #[test]
    #[should_panic(expected = "FOCBS minimizes the sum of costs")]
    fn rejects_makespan() {
        let instance = UaInstance::new(Grid::new(2, 1), Vec::new(), Vec::new()).expect("valid");

        let _ = focbs_with(
            &instance,
            CbsConfig::plain(Objective::Makespan),
            Limits::NONE,
        );
    }
}