pub fn minsum_maxmin<G, H, C, K, P>(
graph: &G,
heuristic: H,
start: G::State,
is_goal: P,
) -> Output<G::State, (C, Bottleneck<K>)>Expand description
Finds one path for every Pareto-optimal (cost, bottleneck) pair from
start to a state that satisfies is_goal: the cost (the sum of the
edges’ first components) as small as possible, the bottleneck (the
smallest of their second components) as large as possible.
Labels leave the open list in increasing cost + heuristic, and among
equal ones in decreasing bottleneck. A label is then dominated exactly
when an earlier label at its state, or an earlier solution, has a
bottleneck at least as large, as in BOA*: one value per state suffices.
A min–max objective (a largest delay to minimize) is the same problem
with K = core::cmp::Reverse<_>.
Requirements, not checked at run time: non-negative costs and a
heuristic on the cost that is consistent and zero on every goal.
Solutions are sorted by cost ascending, bottleneck strictly descending,
as (cost, bottleneck); a start that is a goal gives the unbounded
bottleneck None.
§Examples
use multiobjective_search::{Graph, heuristic_fn, minsum_maxmin};
/// Two routes from 0 to 2: cheap and narrow, or dear and wide.
struct Links;
impl Graph for Links {
type State = u8;
type Weight = (u32, u32);
fn successors(&self, state: &u8, out: &mut Vec<(u8, (u32, u32))>) {
match state {
0 => out.extend([(1, (1, 10)), (2, (5, 100))]),
1 => out.push((2, (1, 100))),
_ => {}
}
}
}
let out = minsum_maxmin(&Links, heuristic_fn(|_: &u8| Some(0)), 0, |s| *s == 2);
let costs: Vec<_> = out.solutions.iter().map(|s| s.cost).collect();
assert_eq!(costs, [(2, Some(10)), (5, Some(100))]);