pub struct DifferentialEvolution {
pub config: DifferentialEvolutionConfig,
pub bounds: RealBounds,
}Expand description
Single-objective DE/rand/1/bin (spec §12.4).
Vec<f64> decisions only; single-objective problems only. Bounds come from
the embedded RealBounds, and mutant vectors are clamped to those bounds.
§Example
use heuropt::prelude::*;
struct Sphere;
impl Problem for Sphere {
type Decision = Vec<f64>;
fn objectives(&self) -> ObjectiveSpace {
ObjectiveSpace::new(vec![Objective::minimize("f")])
}
fn evaluate(&self, x: &Vec<f64>) -> Evaluation {
Evaluation::new(vec![x.iter().map(|v| v * v).sum::<f64>()])
}
}
let mut opt = DifferentialEvolution::new(
DifferentialEvolutionConfig {
population_size: 20,
generations: 50,
differential_weight: 0.5,
crossover_probability: 0.9,
seed: 42,
},
RealBounds::new(vec![(-5.0, 5.0); 5]),
);
let r = opt.run(&Sphere);
// DE crushes Sphere; expect very small objective.
assert!(r.best.unwrap().evaluation.objectives[0] < 1e-3);Fields§
§config: DifferentialEvolutionConfigAlgorithm configuration.
bounds: RealBoundsPer-variable bounds — used both to seed the population and to clamp mutants.
Implementations§
Source§impl DifferentialEvolution
impl DifferentialEvolution
Sourcepub fn new(config: DifferentialEvolutionConfig, bounds: RealBounds) -> Self
pub fn new(config: DifferentialEvolutionConfig, bounds: RealBounds) -> Self
Construct a DifferentialEvolution optimizer.
Trait Implementations§
Source§impl AlgorithmInfo for DifferentialEvolution
impl AlgorithmInfo for DifferentialEvolution
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Canonical short algorithm name — e.g.
"NSGA-II",
"DE", "CMA-ES". This is the form that should appear
in tables, plot legends, and exported JSON metadata.Source§impl Clone for DifferentialEvolution
impl Clone for DifferentialEvolution
Source§fn clone(&self) -> DifferentialEvolution
fn clone(&self) -> DifferentialEvolution
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DifferentialEvolution
impl Debug for DifferentialEvolution
Auto Trait Implementations§
impl Freeze for DifferentialEvolution
impl RefUnwindSafe for DifferentialEvolution
impl Send for DifferentialEvolution
impl Sync for DifferentialEvolution
impl Unpin for DifferentialEvolution
impl UnsafeUnpin for DifferentialEvolution
impl UnwindSafe for DifferentialEvolution
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