pub struct SharedOperatorTerminal<S, O, A, Scorers, Sc> { /* private fields */ }Expand description
Scoring terminal that owns one operator tree and scores it for several named constraints.
#[solverforge_constraints] appends terminals to one grouped node through
penalize/reward and
SharedOperatorBuilder::named. Every entity notification advances the
operator once, then each scorer in Scorers re-scores the changed rows, so
terminals share accumulator state but keep their own identity, weight and
weight slot. A adapts each terminal’s weight to the operator’s rows.
Implementations§
Sourcepub fn penalize<W>(
self,
weight: W,
) -> SharedOperatorBuilder<S, O, A, Scorers, W, Sc>
pub fn penalize<W>( self, weight: W, ) -> SharedOperatorBuilder<S, O, A, Scorers, W, Sc>
Starts another penalizing terminal over the same operator.
Sourcepub fn reward<W>(
self,
weight: W,
) -> SharedOperatorBuilder<S, O, A, Scorers, W, Sc>
pub fn reward<W>( self, weight: W, ) -> SharedOperatorBuilder<S, O, A, Scorers, W, Sc>
Starts another rewarding terminal over the same operator.
Sourcepub fn evaluate(&self, solution: &S) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
pub fn evaluate(&self, solution: &S) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
Sums every scorer over the operator’s current rows, without retained state.
Sourcepub fn initialize(&mut self, solution: &S) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
pub fn initialize(&mut self, solution: &S) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
Initializes the operator from solution and returns the summed score of
every scorer.
Sourcepub fn on_retract(
&mut self,
solution: &S,
index: usize,
descriptor: usize,
) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
pub fn on_retract(
&mut self,
solution: &S,
index: usize,
descriptor: usize,
) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
Retracts an entity from the operator and returns the summed score delta.
§Panics
Panics if the delta overflows.
Sourcepub fn on_insert(&mut self, solution: &S, index: usize, descriptor: usize) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
pub fn on_insert(&mut self, solution: &S, index: usize, descriptor: usize) -> Scwhere
Scorers: OperatorScorerSet<S, O, Sc>,
Inserts an entity into the operator and returns the summed score delta.
§Panics
Panics if the delta overflows.
Sourcepub fn update_count(&self) -> usize
pub fn update_count(&self) -> usize
Number of notifications that changed at least one operator row.
Sourcepub fn changed_key_count(&self) -> usize
pub fn changed_key_count(&self) -> usize
Number of group keys whose collector result a notification changed, summed over notifications.
Trait Implementations§
Source§fn evaluate_all(&self, solution: &S) -> Sc
fn evaluate_all(&self, solution: &S) -> Sc
Source§fn constraint_count(&self) -> usize
fn constraint_count(&self) -> usize
Source§fn constraint_metadata_entries(&self) -> Vec<ConstraintMetadata<'_>>
fn constraint_metadata_entries(&self) -> Vec<ConstraintMetadata<'_>>
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>>
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>>
Source§fn initialize_all(&mut self, solution: &S) -> Sc
fn initialize_all(&mut self, solution: &S) -> Sc
Source§fn on_insert_all(&mut self, solution: &S, index: usize, descriptor: usize) -> Sc
fn on_insert_all(&mut self, solution: &S, index: usize, descriptor: usize) -> Sc
Source§fn on_retract_all(
&mut self,
solution: &S,
index: usize,
descriptor: usize,
) -> Sc
fn on_retract_all( &mut self, solution: &S, index: usize, descriptor: usize, ) -> Sc
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>)
Source§fn evaluate_all_weighted(&self, solution: &S, multipliers: &[u32]) -> Sc
fn evaluate_all_weighted(&self, solution: &S, multipliers: &[u32]) -> Sc
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>>
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>>
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
initialize_all.Source§fn on_insert_all_weighted(
&mut self,
solution: &S,
index: usize,
descriptor: usize,
multipliers: &[u32],
) -> Sc
fn on_insert_all_weighted( &mut self, solution: &S, index: usize, descriptor: usize, multipliers: &[u32], ) -> Sc
on_insert_all.Source§fn on_retract_all_weighted(
&mut self,
solution: &S,
index: usize,
descriptor: usize,
multipliers: &[u32],
) -> Sc
fn on_retract_all_weighted( &mut self, solution: &S, index: usize, descriptor: usize, multipliers: &[u32], ) -> Sc
on_retract_all.Source§fn constraint_metadata(&self) -> Vec<ConstraintMetadata<'_>>
fn constraint_metadata(&self) -> Vec<ConstraintMetadata<'_>>
Source§fn evaluate(&self, solution: &S) -> Sc
fn evaluate(&self, solution: &S) -> Sc
Source§fn match_count(&self, solution: &S) -> usize
fn match_count(&self, solution: &S) -> usize
solution.Source§fn initialize(&mut self, solution: &S) -> Sc
fn initialize(&mut self, solution: &S) -> Sc
solution and returns the constraint’s
whole score, equal to evaluate.Source§fn on_insert(&mut self, solution: &S, index: usize, descriptor: usize) -> Sc
fn on_insert(&mut self, solution: &S, index: usize, descriptor: usize) -> Sc
entity_index of entity class descriptor_index
changed; returns the score its matches now add.Source§fn on_retract(&mut self, solution: &S, index: usize, descriptor: usize) -> Sc
fn on_retract(&mut self, solution: &S, index: usize, descriptor: usize) -> Sc
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)
initialize runs again before the next
notification.Source§fn constraint_ref(&self) -> &ConstraintRef
fn constraint_ref(&self) -> &ConstraintRef
Source§fn is_hard(&self) -> bool
fn is_hard(&self) -> bool
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>>
Source§fn evaluate_weighted(&self, solution: &S, multiplier: u32) -> Sc
fn evaluate_weighted(&self, solution: &S, multiplier: u32) -> Sc
Source§fn initialize_weighted(&mut self, solution: &S, multiplier: u32) -> Sc
fn initialize_weighted(&mut self, solution: &S, multiplier: u32) -> Sc
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
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
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>>
get_matches: every match score scaled by
multiplier.Auto Trait Implementations§
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
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
Source§fn constraint_count(&self) -> usize
fn constraint_count(&self) -> usize
Source§fn constraint_metadata_entries(&self) -> Vec<ConstraintMetadata<'_>>
fn constraint_metadata_entries(&self) -> Vec<ConstraintMetadata<'_>>
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>>
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>>
Source§fn initialize_all(&mut self, solution: &S) -> Sc
fn initialize_all(&mut self, solution: &S) -> Sc
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
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
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>)
Source§fn evaluate_all_weighted(&self, solution: &S, multipliers: &[u32]) -> Sc
fn evaluate_all_weighted(&self, solution: &S, multipliers: &[u32]) -> Sc
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>>
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>>
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
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
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
on_retract_all.