Skip to main content

pp_a_star

Function pp_a_star 

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

PP-A*: finds a set of solutions that covers the Pareto-optimal front within a factor 1 + eps[i] in each objective i.

Requirements, not checked at run time:

  • edge costs are non-negative;
  • heuristic is consistent in both objectives and zero on every goal.

Guarantees:

  • for every Pareto-optimal cost vector s some returned solution r has r[0] <= (1 + eps[0]) · s[0] and r[1] <= (1 + eps[1]) · s[1];
  • the returned solutions are real paths with their exact costs, mutually non-dominated, sorted by the first objective strictly ascending and so by the second strictly descending. Unlike boa_star_eps, a returned solution need not be Pareto-optimal itself;
  • eps = [Epsilon::ZERO; 2] returns exactly the cost vectors of boa_star.

§Why the guarantee holds

Call a pair covered when, for every path p at its state whose cost is at or above its apex a and every suffix to a goal, some returned solution is within the tolerances of the completed path. Pop order keeps apex f1 non-decreasing (merging only lowers the apex to that of one of the two pairs, both still open). Then:

  • a bounded pair that reaches a goal is covered by its br: c1(br) <= (1 + ε1) · a1 and c2(br) = a2; extending both by a suffix keeps the bound, since b + c <= (1 + ε1) · a + c <= (1 + ε1) · (a + c);
  • merging lowers the apex component-wise, so the merged pair covers both;
  • a pair dropped by the solution test is covered by the last solution r: r[0] <= (1 + ε1) · its apex f1, which is at most the dropped pair’s f1, and r[1] <= (1 + ε2) · f2;
  • a pair dropped by the per-state test has its apex at or above that of a pair already expanded there.

Every bound is relative to an apex, which only goes down along these steps, so the tolerances never compound.

§Examples

use multiobjective_search::{Epsilon, Graph, ZeroHeuristic, boa_star, pp_a_star};

/// Four routes from 0 to 1 on a convex front.
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, [100, 40]), (1, [105, 30]), (1, [150, 20]), (1, [200, 19])]);
        }
    }
}

let eps = [Epsilon::new(1, 10), Epsilon::new(1, 10)];
let out = pp_a_star(&Routes, ZeroHeuristic, 0, |s| *s == 1, eps);
let costs: Vec<_> = out.solutions.iter().map(|s| s.cost).collect();
// [105, 30] covers [100, 40]; [150, 20] covers [200, 19].
assert_eq!(costs, [[105, 30], [150, 20]]);

let exact = pp_a_star(&Routes, ZeroHeuristic, 0, |s| *s == 1, [Epsilon::ZERO; 2]);
assert_eq!(exact.solutions.len(), boa_star(&Routes, ZeroHeuristic, 0, |s| *s == 1).solutions.len());