pub trait Objective<T>: Send + Sync {
// Required method
fn score(&self, candidate: &T, context: &ObjectiveContext) -> f64;
// Provided methods
fn precision(&self, _candidate: &T, _context: &ObjectiveContext) -> f64 { ... }
fn passes_score(&self, score: f64, context: &ObjectiveContext) -> bool { ... }
fn passes(&self, candidate: &T, context: &ObjectiveContext) -> bool { ... }
fn batch_score(
&self,
candidates: &[T],
context: &ObjectiveContext,
) -> Vec<(usize, f64)> { ... }
fn select<'a>(
&self,
candidates: &'a [T],
context: &ObjectiveContext,
) -> Vec<Selection<&'a T>> { ... }
fn select_top<'a>(
&self,
candidates: &'a [T],
n: usize,
context: &ObjectiveContext,
) -> Vec<Selection<&'a T>> { ... }
fn name(&self) -> &str { ... }
}Expand description
Deterministic, composable objective function over a candidate set.
Required Methods§
Sourcefn score(&self, candidate: &T, context: &ObjectiveContext) -> f64
fn score(&self, candidate: &T, context: &ObjectiveContext) -> f64
Evaluate a single candidate.
Provided Methods§
Sourcefn precision(&self, _candidate: &T, _context: &ObjectiveContext) -> f64
fn precision(&self, _candidate: &T, _context: &ObjectiveContext) -> f64
Precision (inverse variance) of the score estimate; default 1.0 (fully trusted).
Sourcefn passes_score(&self, score: f64, context: &ObjectiveContext) -> bool
fn passes_score(&self, score: f64, context: &ObjectiveContext) -> bool
Check if a score passes the threshold; non-finite scores never pass.
Sourcefn passes(&self, candidate: &T, context: &ObjectiveContext) -> bool
fn passes(&self, candidate: &T, context: &ObjectiveContext) -> bool
Check if a candidate passes the threshold.
Sourcefn batch_score(
&self,
candidates: &[T],
context: &ObjectiveContext,
) -> Vec<(usize, f64)>
fn batch_score( &self, candidates: &[T], context: &ObjectiveContext, ) -> Vec<(usize, f64)>
Score a batch of candidates and return passing (index, score) pairs.
Sourcefn select<'a>(
&self,
candidates: &'a [T],
context: &ObjectiveContext,
) -> Vec<Selection<&'a T>>
fn select<'a>( &self, candidates: &'a [T], context: &ObjectiveContext, ) -> Vec<Selection<&'a T>>
Select all passing candidates in score-descending order.
Sourcefn select_top<'a>(
&self,
candidates: &'a [T],
n: usize,
context: &ObjectiveContext,
) -> Vec<Selection<&'a T>>
fn select_top<'a>( &self, candidates: &'a [T], n: usize, context: &ObjectiveContext, ) -> Vec<Selection<&'a T>>
Select the top N candidates by precision-weighted score.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T, F> Objective<T> for F
Implement Objective for closures.