[][src]Struct ddo::core::implementation::heuristics::MaxUB

pub struct MaxUB;

This is the default heuristic to set the order in which nodes are popped from the fringe So far, this is not only the default heuristic, but it is also your only choice (this was configurable in the past and could possibly change back in the future).

This ordering optimistically selects the most promising nodes first. That is, it ranks nodes based on the upper bound reachable passing through them (larger is ranked higher) and then on the length of their longest path (again, longer is better).

Note

This ordering considers the worst nodes as being the least elements of the order.

Example


let a = Node {state: 'a', info: NodeInfo{lp_len: 42, lp_arc: None, ub: 300, is_exact: true, is_relaxed: false}};
let b = Node {state: 'b', info: NodeInfo{lp_len:  2, lp_arc: None, ub: 100, is_exact: true, is_relaxed: false}};
let c = Node {state: 'c', info: NodeInfo{lp_len: 24, lp_arc: None, ub: 150, is_exact: true, is_relaxed: false}};
let d = Node {state: 'd', info: NodeInfo{lp_len: 13, lp_arc: None, ub:  60, is_exact: true, is_relaxed: false}};
let e = Node {state: 'e', info: NodeInfo{lp_len: 65, lp_arc: None, ub: 700, is_exact: true, is_relaxed: false}};
let f = Node {state: 'f', info: NodeInfo{lp_len: 19, lp_arc: None, ub: 100, is_exact: true, is_relaxed: false}};

let nodes = vec![a.clone(), b.clone(), c.clone(), d.clone(), e.clone(), f.clone()];
let mut priority_q = BinaryHeap::from_vec_cmp(nodes, MaxUB);

assert_eq!(e, priority_q.pop().unwrap()); // because 700 is the highest upper bound
assert_eq!(a, priority_q.pop().unwrap()); // because 300 is the next highest
assert_eq!(c, priority_q.pop().unwrap()); // idem, because of ub = 150
assert_eq!(f, priority_q.pop().unwrap()); // because ub = 100 but lp_len = 19
assert_eq!(b, priority_q.pop().unwrap()); // because ub = 100 but lp_len = 2
assert_eq!(d, priority_q.pop().unwrap()); // because ub = 13 which is the worst

Trait Implementations

impl Clone for MaxUB[src]

impl<T> Compare<Node<T>, Node<T>> for MaxUB[src]

impl Debug for MaxUB[src]

impl Default for MaxUB[src]

Auto Trait Implementations

impl RefUnwindSafe for MaxUB

impl Send for MaxUB

impl Sync for MaxUB

impl Unpin for MaxUB

impl UnwindSafe for MaxUB

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<F, L, R> Compare<L, R> for F where
    F: Fn(&L, &R) -> Ordering + ?Sized,
    L: ?Sized,
    R: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.