Skip to main content

nsga3

Function nsga3 

Source
pub fn nsga3<F>(
    n_objectives: usize,
    bounds: &[(f64, f64)],
    objectives: F,
    config: Nsga3Config,
) -> OptimizeResult<Nsga3Result>
where F: Fn(&[f64]) -> Vec<f64>,
Expand description

Run NSGA-III on a many-objective optimisation problem.

§Arguments

  • n_objectives - Number of objectives (must be ≥ 2; designed for ≥ 4).
  • bounds - Decision-variable bounds [(lo, hi); n_vars].
  • objectives - Closure mapping a gene vector to objective values (all minimised).
  • config - Algorithm hyper-parameters.

§Errors

Returns an error for empty bounds, degenerate bounds, or < 2 objectives.

§Examples

use scirs2_optimize::multiobjective::nsga3::{nsga3, Nsga3Config};

// DTLZ2 benchmark: 3 variables, 3 objectives
let bounds: Vec<(f64, f64)> = vec![(0.0, 1.0); 7];
let mut cfg = Nsga3Config::default();
cfg.population_size = 20;
cfg.n_generations   = 10;

let result = nsga3(3, &bounds, |x| {
    let n = x.len();
    let k = n - 3 + 1;
    let g: f64 = x[n-k..].iter().map(|&xi| (xi - 0.5).powi(2)).sum();
    let f1 = (1.0 + g) * x[0].cos() * x[1].cos();
    let f2 = (1.0 + g) * x[0].cos() * x[1].sin();
    let f3 = (1.0 + g) * x[0].sin();
    vec![f1, f2, f3]
}, cfg).expect("valid input");

assert!(!result.pareto_front.is_empty());