NSGAII

pub struct NSGAII { /* private fields */ }
Expand description

NSGA-II (Non-dominated Sorting Genetic Algorithm II) implementation

A state-of-the-art evolutionary algorithm for multi-objective optimization that maintains a diverse set of Pareto-optimal solutions.

§Examples

use sklears_multioutput::optimization::evolutionary_multi_objective::NSGAII;
// Use SciRS2-Core for arrays and random number generation (SciRS2 Policy)
use scirs2_core::ndarray::array;

// Define a multi-objective function (minimize both objectives)
let objectives = |x: &scirs2_autograd::scirs2_core::ndarray::ArrayView1`<f64>`| {
    let obj1 = x[0].powi(2) + x[1].powi(2);           // Minimize distance from origin
    let obj2 = (x[0] - 1.0).powi(2) + (x[1] - 1.0).powi(2); // Minimize distance from (1,1)
    array![obj1, obj2]
};

let nsga2 = NSGAII::new()
    .population_size(100)
    .n_generations(50)
    .crossover_probability(0.9)
    .mutation_probability(0.1)
    .variable_bounds(vec![(-2.0, 2.0), (-2.0, 2.0)])
    .random_state(42);

let result = nsga2.optimize(objectives, 2).unwrap();
assert!(result.pareto_front().len() > 0);

Implementations§

Source§

impl NSGAII

Source

pub fn new() -> Self

Create a new NSGA-II optimizer with default parameters

Source

pub fn population_size(self, size: usize) -> Self

Set the population size

Source

pub fn n_generations(self, generations: usize) -> Self

Set the number of generations

Source

pub fn crossover_probability(self, prob: Float) -> Self

Set the crossover probability

Source

pub fn mutation_probability(self, prob: Float) -> Self

Set the mutation probability

Source

pub fn variable_bounds(self, bounds: Vec<(Float, Float)>) -> Self

Set bounds for decision variables

Source

pub fn random_state(self, seed: u64) -> Self

Set random state for reproducibility

Source

pub fn crossover_eta(self, eta: Float) -> Self

Set crossover distribution index (higher values = more uniform crossover)

Source

pub fn mutation_eta(self, eta: Float) -> Self

Set mutation distribution index (higher values = smaller mutations)

Source

pub fn optimize<F>( &self, objective_fn: F, n_objectives: usize, ) -> SklResult<OptimizationResult>
where F: Fn(&ArrayView1<'_, Float>) -> Array1<Float>,

Optimize a multi-objective function using NSGA-II

Trait Implementations§

Source§

impl Clone for NSGAII

Source§

fn clone(&self) -> NSGAII

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NSGAII

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NSGAII

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for NSGAII

§

impl RefUnwindSafe for NSGAII

§

impl Send for NSGAII

§

impl Sync for NSGAII

§

impl Unpin for NSGAII

§

impl UnwindSafe for NSGAII

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V