pub use crate::nsga2::configuration::ObjectiveDirection;
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Nsga3Configuration {
pub num_objectives: usize,
pub population_size: usize,
pub max_generations: usize,
pub objective_directions: Vec<ObjectiveDirection>,
reference_points_auto_p: Option<usize>,
reference_points_custom: Option<Vec<Vec<f64>>>,
}
impl Default for Nsga3Configuration {
fn default() -> Self {
Nsga3Configuration {
num_objectives: 3,
population_size: 100,
max_generations: 200,
objective_directions: Vec::new(),
reference_points_auto_p: None,
reference_points_custom: None,
}
}
}
impl Nsga3Configuration {
pub fn new() -> Self {
Self::default()
}
pub fn with_num_objectives(mut self, n: usize) -> Self {
self.num_objectives = n;
self
}
pub fn with_population_size(mut self, size: usize) -> Self {
self.population_size = size;
self
}
pub fn with_max_generations(mut self, gens: usize) -> Self {
self.max_generations = gens;
self
}
pub fn with_objective_directions(mut self, directions: Vec<ObjectiveDirection>) -> Self {
self.objective_directions = directions;
self
}
pub fn with_reference_points_auto(mut self, p: usize) -> Self {
self.reference_points_auto_p = Some(p);
self.reference_points_custom = None;
self
}
pub fn with_reference_points(mut self, points: Vec<Vec<f64>>) -> Self {
self.reference_points_custom = Some(points);
self.reference_points_auto_p = None;
self
}
pub fn effective_reference_points(&self) -> Option<Vec<Vec<f64>>> {
if let Some(p) = self.reference_points_auto_p {
Some(crate::nsga3::das_dennis::generate_das_dennis(
self.num_objectives,
p,
))
} else {
self.reference_points_custom.clone()
}
}
pub(crate) fn reference_points_auto_p(&self) -> Option<usize> {
self.reference_points_auto_p
}
pub fn effective_directions(&self) -> Vec<ObjectiveDirection> {
if self.objective_directions.is_empty() {
vec![ObjectiveDirection::Minimize; self.num_objectives]
} else {
self.objective_directions.clone()
}
}
}