Skip to main content

Front

Struct Front 

Source
pub struct Front<C, const N: usize> { /* private fields */ }
Expand description

A Pareto frontier of N-objective cost vectors.

Holds mutually non-dominated points, at most one per distinct vector, sorted lexicographically ascending. For two objectives that means the first objective strictly ascending and the second strictly descending.

Only points that are lexicographically no greater than a probe can weakly dominate it, so queries binary-search that prefix first:

OperationN <= 2N > 2
Front::weakly_dominatesO(log n)O(log n + k), k the prefix length
Front::insertO(log n) plus a tail shiftO(n)

§Examples

use multiobjective_search::Front;

let mut front = Front::new();
assert!(front.insert([1_u32, 2, 3]));
assert!(front.insert([3, 2, 1]));
assert!(!front.insert([3, 3, 3])); // dominated by both
assert!(front.insert([1, 2, 2])); // replaces [1, 2, 3]
assert_eq!(front.as_slice(), &[[1, 2, 2], [3, 2, 1]]);

Implementations§

Source§

impl<C: Cost, const N: usize> Front<C, N>

Source

pub const fn new() -> Self

Creates an empty frontier.

Source

pub fn weakly_dominates(&self, point: &[C; N]) -> bool

Returns true if some point on the frontier is no worse than point in every objective, equality included.

Source

pub fn insert(&mut self, point: [C; N]) -> bool

Inserts point unless the frontier already weakly dominates it.

Removes every point that point dominates. Returns true if the point was inserted, false if it was dominated by or equal to an existing point.

Source

pub fn len(&self) -> usize

Number of points on the frontier.

Source

pub fn is_empty(&self) -> bool

Returns true if the frontier holds no points.

Source

pub fn as_slice(&self) -> &[[C; N]]

The points, strictly ascending in lexicographic order.

Trait Implementations§

Source§

impl<C: Clone, const N: usize> Clone for Front<C, N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug, const N: usize> Debug for Front<C, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C, const N: usize> Default for Front<C, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<C: Eq, const N: usize> Eq for Front<C, N>

Source§

impl<C: PartialEq, const N: usize> PartialEq for Front<C, N>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C: PartialEq, const N: usize> StructuralPartialEq for Front<C, N>

Auto Trait Implementations§

§

impl<C, const N: usize> Forget for Front<C, N>

§

impl<C, const N: usize> Freeze for Front<C, N>
where Vec<[C; N]>: Freeze,

§

impl<C, const N: usize> Move for Front<C, N>

§

impl<C, const N: usize> RefUnwindSafe for Front<C, N>

§

impl<C, const N: usize> Send for Front<C, N>
where Vec<[C; N]>: Send,

§

impl<C, const N: usize> Sync for Front<C, N>
where Vec<[C; N]>: Sync,

§

impl<C, const N: usize> Unpin for Front<C, N>
where Vec<[C; N]>: Unpin,

§

impl<C, const N: usize> UnsafeUnpin for Front<C, N>

§

impl<C, const N: usize> UnwindSafe for Front<C, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.