pub trait MultiObjective<G: ?Sized> {
// Required methods
fn objectives(&self) -> usize;
fn evaluate(&mut self, genome: &G, out: &mut [f64]) -> f64;
}Expand description
Several costs to minimise at once, plus a constraint violation.
The violation is 0 for a feasible genome and grows with how far it is from feasibility
(Jakob’s rule: never flatten infeasibility). Constrained domination prefers feasible over
infeasible genomes and, among infeasible ones, the smaller violation (Deb 2000).
use evolutionary_planning::{MultiObjective, multi_objective_fn};
// Schaffer's problem: minimise x^2 and (x - 2)^2.
let mut schaffer = multi_objective_fn(2, |x: &f64, out: &mut [f64]| {
out[0] = x * x;
out[1] = (x - 2.0) * (x - 2.0);
0.0
});
let mut out = [0.0; 2];
assert_eq!(schaffer.evaluate(&1.0, &mut out), 0.0);
assert_eq!(out, [1.0, 1.0]);Required Methods§
Sourcefn objectives(&self) -> usize
fn objectives(&self) -> usize
The number of objectives, m >= 1; constant for the lifetime of the problem.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".