scirs2_optimize/multi_objective/algorithms/
nsga3.rs1use super::{MultiObjectiveOptimizer, MultiObjectiveResult};
6use crate::error::OptimizeError;
7use crate::multi_objective::solutions::{Population, Solution};
8use ndarray::{Array1, ArrayView1};
9
10#[derive(Debug, Clone)]
12pub struct NSGAIII {
13 population_size: usize,
14 n_objectives: usize,
15 n_variables: usize,
16 reference_points: Vec<Vec<f64>>,
17 population: Population,
18 generation: usize,
19 evaluations: usize,
20}
21
22impl NSGAIII {
23 pub fn new(population_size: usize, n_objectives: usize, n_variables: usize) -> Self {
25 Self {
26 population_size,
27 n_objectives,
28 n_variables,
29 reference_points: Vec::new(),
30 population: Population::with_capacity(population_size, n_objectives, n_variables),
31 generation: 0,
32 evaluations: 0,
33 }
34 }
35
36 fn generate_reference_points(&mut self) {
38 }
40}
41
42impl MultiObjectiveOptimizer for NSGAIII {
43 fn optimize<F>(&mut self, objective_function: F) -> Result<MultiObjectiveResult, OptimizeError>
44 where
45 F: Fn(&ArrayView1<f64>) -> Array1<f64> + Send + Sync,
46 {
47 Ok(MultiObjectiveResult {
49 pareto_front: Vec::new(),
50 population: Vec::new(),
51 n_evaluations: 0,
52 n_generations: 0,
53 success: true,
54 message: "NSGA-III not yet implemented".to_string(),
55 hypervolume: Some(0.0),
56 metrics: Default::default(),
57 })
58 }
59
60 fn evolve_generation<F>(&mut self, _objective_function: &F) -> Result<(), OptimizeError>
61 where
62 F: Fn(&ArrayView1<f64>) -> Array1<f64> + Send + Sync,
63 {
64 self.generation += 1;
65 Ok(())
66 }
67
68 fn initialize_population(&mut self) -> Result<(), OptimizeError> {
69 Ok(())
71 }
72
73 fn check_convergence(&self) -> bool {
74 false
76 }
77
78 fn get_population(&self) -> &Population {
79 &self.population
80 }
81
82 fn get_generation(&self) -> usize {
83 self.generation
84 }
85
86 fn get_evaluations(&self) -> usize {
87 self.evaluations
88 }
89
90 fn name(&self) -> &str {
91 "NSGA-III"
92 }
93}