Skip to main content

NSGAIIParameters

Struct NSGAIIParameters 

Source
pub struct NSGAIIParameters<C, M, Sel>{
    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: TerminationCriteria

Implementations§

Source§

impl<C, M, Sel> NSGAIIParameters<C, M, Sel>

Source

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}
Source

pub fn with_threads(self, num_threads: usize) -> Self

Source

pub fn with_parallel(self) -> Self

Source

pub fn sequential(self) -> Self

Source

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>
where C: Freeze, M: Freeze, Sel: Freeze,

§

impl<C, M, Sel> RefUnwindSafe for NSGAIIParameters<C, M, Sel>

§

impl<C, M, Sel> Send for NSGAIIParameters<C, M, Sel>
where C: Send, M: Send, Sel: Send,

§

impl<C, M, Sel> Sync for NSGAIIParameters<C, M, Sel>
where C: Sync, M: Sync, Sel: Sync,

§

impl<C, M, Sel> Unpin for NSGAIIParameters<C, M, Sel>
where C: Unpin, M: Unpin, Sel: Unpin,

§

impl<C, M, Sel> UnsafeUnpin for NSGAIIParameters<C, M, Sel>
where C: UnsafeUnpin, M: UnsafeUnpin, Sel: UnsafeUnpin,

§

impl<C, M, Sel> UnwindSafe for NSGAIIParameters<C, M, Sel>
where C: UnwindSafe, M: UnwindSafe, Sel: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.