pub struct Bi<S, Out, K, Src, F, KF, PF, W, Sc>{ /* private fields */ }Expand description
Symmetric self-join constraint over retained projected rows.
Projected rows from Src that pass F are bucketed by KF; each unordered
pair of distinct rows with equal keys that passes the pair filter PF is
scored by W, signed by the impact. Pairs are oriented by RowCoordinate,
and the pair filter receives each row’s primary owner entity index, not a
storage row id. Produced by stream::projected::Stream::join(equal(..)).
Implementations§
Source§impl<S, Out, K, Src, F, KF, PF, W, Sc> Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> Bi<S, Out, K, Src, F, KF, PF, W, Sc>
Sourcepub fn new(
constraint_ref: ConstraintRef,
impact_type: ImpactType,
source: Src,
filter: F,
key_fn: KF,
pair_filter: PF,
weight: W,
is_hard: bool,
) -> Self
pub fn new( constraint_ref: ConstraintRef, impact_type: ImpactType, source: Src, filter: F, key_fn: KF, pair_filter: PF, weight: W, is_hard: bool, ) -> Self
Creates the constraint. is_hard is the reported hardness; impact_type
signs every pair weight.
Trait Implementations§
Source§impl<S, Out, K, Src, F, KF, PF, W, Sc> IncrementalConstraint<S, Sc> for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> IncrementalConstraint<S, Sc> for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
Source§fn evaluate(&self, solution: &S) -> Sc
fn evaluate(&self, solution: &S) -> Sc
Computes this constraint’s whole score from scratch, without reading
or changing retained state.
Source§fn match_count(&self, solution: &S) -> usize
fn match_count(&self, solution: &S) -> usize
Returns the number of matches for this constraint in
solution.Source§fn initialize(&mut self, solution: &S) -> Sc
fn initialize(&mut self, solution: &S) -> Sc
Builds retained state from
solution and returns the constraint’s
whole score, equal to evaluate.Source§fn on_insert(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
) -> Sc
fn on_insert( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, ) -> Sc
Called after entity
entity_index of entity class descriptor_index
changed; returns the score its matches now add.Source§fn on_retract(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
) -> Sc
fn on_retract( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, ) -> Sc
Called before entity
entity_index of entity class
descriptor_index changes; returns the negation of the score its
matches currently contribute.Source§fn reset(&mut self)
fn reset(&mut self)
Drops all retained state.
initialize runs again before the next
notification.Source§fn constraint_ref(&self) -> &ConstraintRef
fn constraint_ref(&self) -> &ConstraintRef
Returns the constraint’s reference (package and name), the same for
its whole life.
Source§fn is_hard(&self) -> bool
fn is_hard(&self) -> bool
Returns whether this is a hard constraint. Every constraint sharing
this constraint’s full reference must agree.
Source§fn get_matches<'a>(
&'a self,
_solution: &S,
) -> Vec<DetailedConstraintMatch<'a, Sc>>
fn get_matches<'a>( &'a self, _solution: &S, ) -> Vec<DetailedConstraintMatch<'a, Sc>>
Returns each match with the entities that justify it, for score
explanation. The default returns no matches.
Source§fn evaluate_weighted(&self, solution: &S, multiplier: u32) -> Sc
fn evaluate_weighted(&self, solution: &S, multiplier: u32) -> Sc
Weighted counterparts of the scoring methods. Read more
Source§fn initialize_weighted(&mut self, solution: &S, multiplier: u32) -> Sc
fn initialize_weighted(&mut self, solution: &S, multiplier: u32) -> Sc
Weighted
initialize: the initial score scaled by multiplier.Source§fn on_insert_weighted(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
multiplier: u32,
) -> Sc
fn on_insert_weighted( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, multiplier: u32, ) -> Sc
Weighted
on_insert: the insert delta scaled by multiplier.Source§fn on_retract_weighted(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
multiplier: u32,
) -> Sc
fn on_retract_weighted( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, multiplier: u32, ) -> Sc
Weighted
on_retract: the retract delta scaled by multiplier.Source§fn get_matches_weighted<'a>(
&'a self,
solution: &S,
multiplier: u32,
) -> Vec<DetailedConstraintMatch<'a, Sc>>
fn get_matches_weighted<'a>( &'a self, solution: &S, multiplier: u32, ) -> Vec<DetailedConstraintMatch<'a, Sc>>
Weighted
get_matches: every match score scaled by
multiplier.impl<S, Out, K, Src, F, KF, PF, W, Sc> SingleConstraint for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
Auto Trait Implementations§
impl<S, Out, K, Src, F, KF, PF, W, Sc> Forget for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> Freeze for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> Move for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> RefUnwindSafe for Bi<S, Out, K, Src, F, KF, PF, W, Sc>where
Src: RefUnwindSafe,
F: RefUnwindSafe,
KF: RefUnwindSafe,
PF: RefUnwindSafe,
W: RefUnwindSafe,
Option<<Src as Source<S, Out>>::State>: RefUnwindSafe,
Vec<Option<ProjectedJoinRow<Out>>>: RefUnwindSafe,
HashMap<K, Vec<usize>, BuildHasherDefault<FastHasher>>: RefUnwindSafe,
PhantomData<(fn() -> S, fn() -> Out, fn() -> Sc)>: RefUnwindSafe,
impl<S, Out, K, Src, F, KF, PF, W, Sc> Send for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> Sync for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> Unpin for Bi<S, Out, K, Src, F, KF, PF, W, Sc>
impl<S, Out, K, Src, F, KF, PF, W, Sc> UnsafeUnpin for Bi<S, Out, K, Src, F, KF, PF, W, Sc>where
Src: UnsafeUnpin,
F: UnsafeUnpin,
KF: UnsafeUnpin,
PF: UnsafeUnpin,
W: UnsafeUnpin,
Option<<Src as Source<S, Out>>::State>: UnsafeUnpin,
Vec<Option<ProjectedJoinRow<Out>>>: UnsafeUnpin,
HashMap<K, Vec<usize>, BuildHasherDefault<FastHasher>>: UnsafeUnpin,
PhantomData<(fn() -> S, fn() -> Out, fn() -> Sc)>: UnsafeUnpin,
impl<S, Out, K, Src, F, KF, PF, W, Sc> UnwindSafe for Bi<S, Out, K, Src, F, KF, PF, W, Sc>where
Src: UnwindSafe,
F: UnwindSafe,
KF: UnwindSafe,
PF: UnwindSafe,
W: UnwindSafe,
Option<<Src as Source<S, Out>>::State>: UnwindSafe,
Vec<Option<ProjectedJoinRow<Out>>>: UnwindSafe,
HashMap<K, Vec<usize>, BuildHasherDefault<FastHasher>>: UnwindSafe,
PhantomData<(fn() -> S, fn() -> Out, fn() -> Sc)>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S, Sc, C> ConstraintSet<S, Sc> for C
impl<S, Sc, C> ConstraintSet<S, Sc> for C
Source§fn evaluate_all(&self, solution: &S) -> Sc
fn evaluate_all(&self, solution: &S) -> Sc
Evaluates all constraints and returns the total score.
Source§fn constraint_count(&self) -> usize
fn constraint_count(&self) -> usize
Returns the number of constraints in this set.
Source§fn constraint_metadata_entries(&self) -> Vec<ConstraintMetadata<'_>>
fn constraint_metadata_entries(&self) -> Vec<ConstraintMetadata<'_>>
Returns one metadata entry per constraint in authored order, keeping
duplicates. Read more
Source§fn evaluate_each<'a>(&'a self, solution: &S) -> Vec<ConstraintResult<'a, Sc>>
fn evaluate_each<'a>(&'a self, solution: &S) -> Vec<ConstraintResult<'a, Sc>>
Evaluates each constraint individually and returns per-constraint results. Read more
Source§fn evaluate_detailed<'a>(
&'a self,
solution: &S,
) -> Vec<ConstraintAnalysis<'a, Sc>>
fn evaluate_detailed<'a>( &'a self, solution: &S, ) -> Vec<ConstraintAnalysis<'a, Sc>>
Evaluates each constraint with detailed match information. Read more
Source§fn initialize_all(&mut self, solution: &S) -> Sc
fn initialize_all(&mut self, solution: &S) -> Sc
Initializes all constraints by inserting all entities. Read more
Source§fn on_insert_all(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
) -> Sc
fn on_insert_all( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, ) -> Sc
Called when an entity is inserted. Read more
Source§fn on_retract_all(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
) -> Sc
fn on_retract_all( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, ) -> Sc
Called when an entity is retracted. Read more
fn on_insert_all_overflowing( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, ) -> (Sc, bool)
fn on_retract_all_overflowing( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, ) -> (Sc, bool)
Source§fn constraint_weight_refs<'a>(&'a self, refs: &mut Vec<&'a ConstraintRef>)
fn constraint_weight_refs<'a>(&'a self, refs: &mut Vec<&'a ConstraintRef>)
Runtime constraint weights. Read more
Source§fn evaluate_all_weighted(&self, solution: &S, multipliers: &[u32]) -> Sc
fn evaluate_all_weighted(&self, solution: &S, multipliers: &[u32]) -> Sc
Weighted
evaluate_all: multipliers holds one
multiplier per weight slot.Source§fn evaluate_each_weighted<'a>(
&'a self,
solution: &S,
multipliers: &[u32],
) -> Vec<ConstraintResult<'a, Sc>>
fn evaluate_each_weighted<'a>( &'a self, solution: &S, multipliers: &[u32], ) -> Vec<ConstraintResult<'a, Sc>>
Weighted
evaluate_each: weighted scores, with each
result’s weight_multiplier set from its slot.Source§fn evaluate_detailed_weighted<'a>(
&'a self,
solution: &S,
multipliers: &[u32],
) -> Vec<ConstraintAnalysis<'a, Sc>>
fn evaluate_detailed_weighted<'a>( &'a self, solution: &S, multipliers: &[u32], ) -> Vec<ConstraintAnalysis<'a, Sc>>
Weighted
evaluate_detailed: weighted totals and
match scores, with each analysis’s weight_multiplier set from its slot.Source§fn initialize_all_weighted(&mut self, solution: &S, multipliers: &[u32]) -> Sc
fn initialize_all_weighted(&mut self, solution: &S, multipliers: &[u32]) -> Sc
Weighted
initialize_all.Source§fn on_insert_all_weighted(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
multipliers: &[u32],
) -> Sc
fn on_insert_all_weighted( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, multipliers: &[u32], ) -> Sc
Weighted
on_insert_all.Source§fn on_retract_all_weighted(
&mut self,
solution: &S,
entity_index: usize,
descriptor_index: usize,
multipliers: &[u32],
) -> Sc
fn on_retract_all_weighted( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, multipliers: &[u32], ) -> Sc
Weighted
on_retract_all.fn on_insert_all_weighted_overflowing( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, multipliers: &[u32], ) -> (Sc, bool)
fn on_retract_all_weighted_overflowing( &mut self, solution: &S, entity_index: usize, descriptor_index: usize, multipliers: &[u32], ) -> (Sc, bool)
Source§fn constraint_metadata(&self) -> Vec<ConstraintMetadata<'_>>
fn constraint_metadata(&self) -> Vec<ConstraintMetadata<'_>>
Returns deduplicated immutable metadata for constraints in this set.