pub struct NSGAIIParameters<C, M, Sel>where
C: CrossoverOperator<f64, ParetoCrowdingDistanceQuality>,
M: MutationOperator<f64, ParetoCrowdingDistanceQuality>,
Sel: SelectionOperator<f64, ParetoCrowdingDistanceQuality>,{
pub population_size: usize,
pub crossover_probability: f64,
pub mutation_probability: f64,
pub crossover_operator: C,
pub mutation_operator: M,
pub selection_operator: Sel,
pub num_threads: Option<usize>,
pub random_seed: Option<u64>,
pub termination_criteria: TerminationCriteria,
}Fields§
§population_size: usize§crossover_probability: f64§mutation_probability: f64§crossover_operator: C§mutation_operator: M§selection_operator: Sel§num_threads: Option<usize>§random_seed: Option<u64>§termination_criteria: TerminationCriteriaImplementations§
Source§impl<C, M, Sel> NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> NSGAIIParameters<C, M, Sel>
Sourcepub fn new(
population_size: usize,
crossover_probability: f64,
mutation_probability: f64,
crossover_operator: C,
mutation_operator: M,
selection_operator: Sel,
termination_criteria: TerminationCriteria,
) -> Self
pub fn new( population_size: usize, crossover_probability: f64, mutation_probability: f64, crossover_operator: C, mutation_operator: M, selection_operator: Sel, termination_criteria: TerminationCriteria, ) -> Self
Examples found in repository?
examples/zdt1_nsga2_demo.rs (lines 19-27)
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}pub fn with_threads(self, num_threads: usize) -> Self
pub fn with_parallel(self) -> Self
pub fn sequential(self) -> Self
Sourcepub fn with_seed(self, seed: u64) -> Self
pub fn with_seed(self, seed: u64) -> Self
Examples found in repository?
examples/zdt1_nsga2_demo.rs (line 28)
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}Auto Trait Implementations§
impl<C, M, Sel> Freeze for NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> RefUnwindSafe for NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> Send for NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> Sync for NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> Unpin for NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> UnsafeUnpin for NSGAIIParameters<C, M, Sel>
impl<C, M, Sel> UnwindSafe for NSGAIIParameters<C, M, Sel>
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