Skip to main content

supported_solutions

Function supported_solutions 

Source
pub fn supported_solutions<G, H, C, P>(
    graph: &G,
    heuristic: H,
    start: G::State,
    is_goal: P,
) -> Output<G::State, [C; 2]>
where G: Graph<Weight = [C; 2]>, H: Heuristic<G::State, [C; 2]>, C: Cost + WideMul, P: Fn(&G::State) -> bool,
Expand description

Phase 1: the extreme supported solutions, those whose costs are the vertices of the convex hull of the Pareto-optimal front, sorted by cost.

Dichotomic search (Aneja and Nair 1979): starting from the two lexicographic optima, for two neighbours a and b minimize the weighted sum (a2 - b2) · c1 + (b1 - a1) · c2, whose level line runs through a and b, and keep the minimizer if it lies strictly below that line. Weighted sums are compared exactly with WideMul, ties broken lexicographically, so a minimizer is always a hull vertex.

Requirements, not checked at run time: non-negative costs and a heuristic consistent in both objectives and zero on every goal.

§Examples

use multiobjective_search::{Graph, ZeroHeuristic, supported_solutions};

/// Four routes from 0 to 1; (5, 5) lies above the hull of the others.
struct Routes;

impl Graph for Routes {
    type State = u8;
    type Weight = [u32; 2];

    fn successors(&self, state: &u8, out: &mut Vec<(u8, [u32; 2])>) {
        if *state == 0 {
            out.extend([(1, [1, 9]), (1, [3, 3]), (1, [5, 5]), (1, [9, 1])]);
        }
    }
}

let out = supported_solutions(&Routes, ZeroHeuristic, 0, |s| *s == 1);
let costs: Vec<_> = out.solutions.iter().map(|s| s.cost).collect();
assert_eq!(costs, [[1, 9], [3, 3], [9, 1]]);