Expand description
Clean Vec
This module provides self-contained, easy-to-use implementations of
multi-objective evolutionary algorithms that work directly with Rust
Vec<f64> slices — no ndarray wrappers required.
§Modules
| Module | Algorithm |
|---|---|
[nsga2] | NSGA-II — Non-dominated Sorting Genetic Algorithm II (Deb 2002) |
[nsga3] | NSGA-III — Many-objective NSGA with reference-point niching (Deb 2014) |
[moead] | MOEA/D — Decomposition-based MOEA (Zhang 2007) |
pareto | Pareto dominance, ranking, hypervolume, and distance metrics |
indicators | Quality indicators: HV, IGD, IGD+, GD, ε-indicator, R2, spacing |
§Quick start
use scirs2_optimize::multiobjective::nsga2::{nsga2, Nsga2Config};
// 2-variable, 2-objective ZDT1 benchmark
let bounds = vec![(0.0_f64, 1.0_f64); 5];
let mut cfg = Nsga2Config::default();
cfg.population_size = 20;
cfg.n_generations = 5;
let result = nsga2(2, &bounds, |x| {
let f1 = x[0];
let g = 1.0 + 9.0 * x[1..].iter().sum::<f64>() / (x.len()-1) as f64;
vec![f1, g * (1.0 - (f1 / g).sqrt())]
}, cfg).expect("valid input");
println!("Pareto front size: {}", result.pareto_front.len());§Many-objective (≥ 4 objectives) example
use scirs2_optimize::multiobjective::nsga3::{nsga3, Nsga3Config};
let n_obj = 4;
let bounds: Vec<(f64, f64)> = vec![(0.0, 1.0); n_obj + 3];
let mut cfg = Nsga3Config::default();
cfg.population_size = 30;
cfg.n_generations = 10;
cfg.n_divisions = 3;
let result = nsga3(n_obj, &bounds, |x| {
let n = x.len();
let k = n - n_obj + 1;
let g: f64 = x[n-k..].iter().map(|&xi| (xi - 0.5).powi(2)).sum();
let mut f = vec![0.0f64; n_obj];
for i in 0..n_obj {
let mut val = 1.0 + g;
for j in 0..n_obj - 1 - i {
val *= (x[j] * std::f64::consts::FRAC_PI_2).cos();
}
if i > 0 { val *= (x[n_obj - 1 - i] * std::f64::consts::FRAC_PI_2).sin(); }
f[i] = val;
}
f
}, cfg).expect("valid input");
println!("Reference points: {}", result.reference_points.len());Re-exports§
pub use hypervolume::exclusive_hypervolume;pub use hypervolume::hypervolume_2d as hv_2d;pub use hypervolume::hypervolume_3d;pub use hypervolume::hypervolume_contribution_wfg;pub use hypervolume::hypervolume_wfg;pub use indicators::additive_epsilon_indicator;pub use indicators::delta_metric;pub use indicators::dominates;pub use indicators::generational_distance;pub use indicators::hypervolume_2d;pub use indicators::hypervolume_contribution;pub use indicators::hypervolume_mc;pub use indicators::igd;pub use indicators::igd_plus;pub use indicators::non_dominated_sort;pub use indicators::r2_indicator;pub use indicators::spacing_metric;pub use indicators::spread;pub use indicators::R2Utility;pub use moead::build_neighborhood;pub use moead::generate_weight_vectors;pub use moead::moead;pub use moead::tchebycheff_scalarization;pub use moead::MoeadConfig;pub use moead::MoeadResult;pub use nsga2::nsga2;pub use nsga2::Individual;pub use nsga2::Nsga2Config;pub use nsga2::Nsga2Result;pub use nsga3::adapt_reference_points;pub use nsga3::associate_to_reference_points;pub use nsga3::generate_reference_points;pub use nsga3::generate_reference_points_inner;pub use nsga3::nsga3;pub use nsga3::reference_line_distance;pub use nsga3::Nsga3Config;pub use nsga3::Nsga3Result;pub use pareto::crowding_distance;pub use pareto::dominates as pareto_dominates;pub use pareto::epsilon_indicator;pub use pareto::generational_distance as pareto_gd;pub use pareto::hypervolume_2d as pareto_hv2d;pub use pareto::hypervolume_indicator as pareto_hv;pub use pareto::igd as pareto_igd;pub use pareto::non_dominated_sort as pareto_nds;pub use pareto::pareto_front;pub use pareto::pareto_front_2d;pub use pareto::pareto_rank;pub use pareto::spread_metric;
Modules§
- hypervolume
- Hypervolume indicator computation for multi-objective optimization.
- indicators
- Performance indicators for multi-objective optimization
- moead
- MOEA/D: Multi-Objective Evolutionary Algorithm based on Decomposition
- nsga2
- NSGA-II: Non-dominated Sorting Genetic Algorithm II
- nsga3
- NSGA-III: Non-dominated Sorting Genetic Algorithm III
- pareto
- Pareto front utilities for multi-objective optimization.