pub trait Objective<G: ?Sized> {
// Required method
fn evaluate(&mut self, genome: &G) -> f64;
}Expand description
A cost to minimise for each genome.
Implemented for every FnMut(&G) -> f64, so a closure is an objective. Evaluation may
have side effects (a simulator, a counter); the algorithms call it exactly once per
evaluated individual and count those calls against the budget.
use evolutionary_planning::Objective;
let mut sphere = |x: &Vec<f64>| x.iter().map(|v| v * v).sum::<f64>();
assert_eq!(sphere.evaluate(&vec![1.0, 2.0]), 5.0);Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".