Skip to main content

TreeFront

Struct TreeFront 

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

A Pareto frontier of N-objective cost vectors in a balanced tree.

Holds the same points as Front and answers the same queries, but with sublinear typical cost for many objectives; see the module documentation. Prefer Front for one to three objectives, where its sorted Vec is faster.

§Examples

use multiobjective_search::TreeFront;

let mut front = TreeFront::new();
assert!(front.insert([1_u32, 2, 3, 4]));
assert!(front.insert([4, 3, 2, 1]));
assert!(!front.insert([4, 4, 4, 4])); // dominated by both
assert!(front.insert([1, 2, 3, 3])); // replaces [1, 2, 3, 4]
assert_eq!(front.to_vec(), [[1, 2, 3, 3], [4, 3, 2, 1]]);
assert!(front.weakly_dominates(&[5, 5, 5, 5]));

Implementations§

Source§

impl<C, const N: usize> TreeFront<C, N>

Source

pub const fn new() -> Self

Creates an empty frontier.

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§

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

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 to_vec(&self) -> Vec<[C; N]>

The points, strictly ascending in lexicographic order.

Trait Implementations§

Source§

impl<C: Clone, const N: usize> Clone for TreeFront<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 TreeFront<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 TreeFront<C, N>

Source§

fn default() -> Self

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

impl<C: Cost, const N: usize> Eq for TreeFront<C, N>

Source§

impl<C: Cost, const N: usize> PartialEq for TreeFront<C, N>

Source§

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

Two frontiers are equal when they hold the same points.

1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

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

§

impl<C, const N: usize> Freeze for TreeFront<C, N>
where Vec<TreeNode<C, N>>: Freeze,

§

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

§

impl<C, const N: usize> RefUnwindSafe for TreeFront<C, N>
where Vec<TreeNode<C, N>>: RefUnwindSafe,

§

impl<C, const N: usize> Send for TreeFront<C, N>
where Vec<TreeNode<C, N>>: Send,

§

impl<C, const N: usize> Sync for TreeFront<C, N>
where Vec<TreeNode<C, N>>: Sync,

§

impl<C, const N: usize> Unpin for TreeFront<C, N>
where Vec<TreeNode<C, N>>: Unpin,

§

impl<C, const N: usize> UnsafeUnpin for TreeFront<C, N>
where Vec<TreeNode<C, N>>: UnsafeUnpin,

§

impl<C, const N: usize> UnwindSafe for TreeFront<C, N>
where Vec<TreeNode<C, N>>: UnwindSafe,

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.