pub struct SBXCrossover { /* private fields */ }Expand description
Simulated Binary Crossover (SBX)
A crossover operator for real-valued variables that simulates the behavior of single-point crossover on binary strings. Widely used in multi-objective optimization.
Implementations§
Source§impl SBXCrossover
impl SBXCrossover
Sourcepub fn new(distribution_index: f64) -> Self
pub fn new(distribution_index: f64) -> Self
Create a new SBX crossover operator
§Parameters
distribution_index: Controls the spread of offspring (typical value: 20.0) Higher values produce offspring closer to parents
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create with default distribution index
Examples found in repository?
examples/zdt1_nsga2_demo.rs (line 23)
14fn main() {
15 let seed = seed_from_cli_or(42);
16
17 let problem = ZDT1Problem::new(30);
18
19 let parameters = NSGAIIParameters::new(
20 60,
21 0.9,
22 1.0 / 30.0,
23 SBXCrossover::new_default(),
24 PolynomialMutation::new_default(),
25 MultiObjectiveTournamentSelection::new(),
26 TerminationCriteria::new(vec![TerminationCriterion::MaxIterations(40)]),
27 )
28 .with_seed(seed);
29
30 let mut algorithm = NSGAII::new(parameters);
31 let observer = ConsoleObserver::new(true);
32 let observer2 = ChartObserver::new_default();
33 algorithm.add_observer(Box::new(observer));
34 algorithm.add_observer(Box::new(observer2));
35 let result = algorithm
36 .run(&problem)
37 .expect("NSGA-II run failed");
38
39 if let Some(best) = result.get(0) {
40 println!(
41 "NSGA-II finished (seed={}). population={}, best objectives={:?}",
42 seed,
43 result.size(),
44 best.objectives()
45 );
46 } else {
47 println!("NSGA-II finished with empty population (seed={})", seed);
48 }
49}Trait Implementations§
Source§impl<Q> CrossoverOperator<f64, Q> for SBXCrossover
impl<Q> CrossoverOperator<f64, Q> for SBXCrossover
Source§fn execute(
&self,
parent1: &Solution<f64, Q>,
parent2: &Solution<f64, Q>,
rng: &mut Random,
) -> Vec<Solution<f64, Q>>
fn execute( &self, parent1: &Solution<f64, Q>, parent2: &Solution<f64, Q>, rng: &mut Random, ) -> Vec<Solution<f64, Q>>
Applies crossover to two parent solutions and returns offspring. Read more
Source§fn execute_several(
&self,
solutions: Vec<Solution<f64, Q>>,
rng: &mut Random,
) -> Vec<Solution<f64, Q>>
fn execute_several( &self, solutions: Vec<Solution<f64, Q>>, rng: &mut Random, ) -> Vec<Solution<f64, Q>>
Applies crossover to several parent solutions and returns offspring. Read more
Source§fn number_of_offspring(&self) -> usize
fn number_of_offspring(&self) -> usize
Returns the expected number of offspring produced by this operator
Auto Trait Implementations§
impl Freeze for SBXCrossover
impl RefUnwindSafe for SBXCrossover
impl Send for SBXCrossover
impl Sync for SBXCrossover
impl Unpin for SBXCrossover
impl UnsafeUnpin for SBXCrossover
impl UnwindSafe for SBXCrossover
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