FlattenedBiConstraintStream

Struct FlattenedBiConstraintStream 

Source
pub struct FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where Sc: Score,
{ /* private fields */ }
Expand description

O(1) flattened bi-constraint stream.

Pre-indexes C items by key for O(1) lookup.

§Type Parameters

  • S - Solution type
  • A - Entity type A (e.g., Shift)
  • B - Entity type B (e.g., Employee)
  • C - Flattened item type (e.g., NaiveDate)
  • K - Join key type
  • CK - C item key type for indexing
  • EA - Extractor function for A entities
  • EB - Extractor function for B entities
  • KA - Key extractor for A
  • KB - Key extractor for B
  • Flatten - Function that extracts a slice from B
  • CKeyFn - Function that extracts index key from C
  • ALookup - Function that extracts lookup key from A
  • F - Combined filter type over (A, C) pairs
  • Sc - Score type

Implementations§

Source§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, Sc> FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, TrueFilter, Sc>
where S: Send + Sync + 'static, A: Clone + Send + Sync + 'static, B: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, CK: Eq + Hash + Clone + Send + Sync, EA: Fn(&S) -> &[A] + Send + Sync, EB: Fn(&S) -> &[B] + Send + Sync, KA: Fn(&A) -> K + Send + Sync, KB: Fn(&B) -> K + Send + Sync, Flatten: Fn(&B) -> &[C] + Send + Sync, CKeyFn: Fn(&C) -> CK + Send + Sync, ALookup: Fn(&A) -> CK + Send + Sync, Sc: Score + 'static,

Source

pub fn new( extractor_a: EA, extractor_b: EB, key_a: KA, key_b: KB, flatten: Flatten, c_key_fn: CKeyFn, a_lookup_fn: ALookup, ) -> Self

Creates a new O(1) indexed flattened bi-constraint stream.

This is called from CrossBiConstraintStream::flatten_last_indexed().

Source§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where S: Send + Sync + 'static, A: Clone + Send + Sync + 'static, B: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, CK: Eq + Hash + Clone + Send + Sync, EA: Fn(&S) -> &[A] + Send + Sync, EB: Fn(&S) -> &[B] + Send + Sync, KA: Fn(&A) -> K + Send + Sync, KB: Fn(&B) -> K + Send + Sync, Flatten: Fn(&B) -> &[C] + Send + Sync, CKeyFn: Fn(&C) -> CK + Send + Sync, ALookup: Fn(&A) -> CK + Send + Sync, F: BiFilter<S, A, C>, Sc: Score + 'static,

Source

pub fn filter<P>( self, predicate: P, ) -> FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, AndBiFilter<F, FnBiFilter<impl Fn(&S, &A, &C) -> bool + Send + Sync>>, Sc>
where P: Fn(&A, &C) -> bool + Send + Sync,

Adds a filter predicate to the stream.

Source

pub fn penalize( self, weight: Sc, ) -> FlattenedBiConstraintBuilder<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, impl Fn(&A, &C) -> Sc + Send + Sync, Sc>
where Sc: Copy,

Penalizes each matching (A, C) pair with a fixed weight.

Source

pub fn penalize_with<W>( self, weight_fn: W, ) -> FlattenedBiConstraintBuilder<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, W, Sc>
where W: Fn(&A, &C) -> Sc + Send + Sync,

Penalizes each matching (A, C) pair with a dynamic weight.

Source

pub fn penalize_hard_with<W>( self, weight_fn: W, ) -> FlattenedBiConstraintBuilder<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, W, Sc>
where W: Fn(&A, &C) -> Sc + Send + Sync,

Penalizes each matching (A, C) pair with a dynamic weight, explicitly marked as hard.

Source

pub fn reward( self, weight: Sc, ) -> FlattenedBiConstraintBuilder<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, impl Fn(&A, &C) -> Sc + Send + Sync, Sc>
where Sc: Copy,

Rewards each matching (A, C) pair with a fixed weight.

Source

pub fn reward_with<W>( self, weight_fn: W, ) -> FlattenedBiConstraintBuilder<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, W, Sc>
where W: Fn(&A, &C) -> Sc + Send + Sync,

Rewards each matching (A, C) pair with a dynamic weight.

Trait Implementations§

Source§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc: Score> Debug for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> Freeze for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where EA: Freeze, EB: Freeze, KA: Freeze, KB: Freeze, Flatten: Freeze, CKeyFn: Freeze, ALookup: Freeze, F: Freeze,

§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> RefUnwindSafe for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>

§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> Send for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where EA: Send, EB: Send, KA: Send, KB: Send, Flatten: Send, CKeyFn: Send, ALookup: Send, F: Send, S: Send, A: Send, B: Send, C: Send, K: Send, CK: Send,

§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> Sync for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where EA: Sync, EB: Sync, KA: Sync, KB: Sync, Flatten: Sync, CKeyFn: Sync, ALookup: Sync, F: Sync, S: Sync, A: Sync, B: Sync, C: Sync, K: Sync, CK: Sync,

§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> Unpin for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where EA: Unpin, EB: Unpin, KA: Unpin, KB: Unpin, Flatten: Unpin, CKeyFn: Unpin, ALookup: Unpin, F: Unpin, S: Unpin, A: Unpin, B: Unpin, C: Unpin, K: Unpin, CK: Unpin, Sc: Unpin,

§

impl<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc> UnwindSafe for FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, F, Sc>
where EA: UnwindSafe, EB: UnwindSafe, KA: UnwindSafe, KB: UnwindSafe, Flatten: UnwindSafe, CKeyFn: UnwindSafe, ALookup: UnwindSafe, F: UnwindSafe, S: UnwindSafe, A: UnwindSafe, B: UnwindSafe, C: UnwindSafe, K: UnwindSafe, CK: UnwindSafe, Sc: 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.