use crate::configuration::{LogLevel, ProblemSolving, StoppingCriteria};
use crate::operations::{Crossover, Extension, Mutation, Selection, Survivor};
pub trait SelectionConfig {
fn with_number_of_couples(self, number_of_couples: usize) -> Self;
fn with_selection_method(self, selection_method: Selection) -> Self;
}
pub trait CrossoverConfig {
fn with_crossover_number_of_points(self, number_of_points: usize) -> Self;
fn with_crossover_probability_max(self, probability_max: f64) -> Self;
fn with_crossover_probability_min(self, probability_min: f64) -> Self;
fn with_crossover_method(self, method: Crossover) -> Self;
fn with_sbx_eta(self, eta: f64) -> Self;
fn with_blend_alpha(self, alpha: f64) -> Self;
}
pub trait MutationConfig {
fn with_mutation_probability_max(self, probability_max: f64) -> Self;
fn with_mutation_probability_min(self, probability_min: f64) -> Self;
fn with_mutation_method(self, method: Mutation) -> Self;
fn with_mutation_step(self, step: f64) -> Self;
fn with_mutation_sigma(self, sigma: f64) -> Self;
fn with_dynamic_mutation(self, enabled: bool) -> Self;
fn with_mutation_target_cardinality(self, target: f64) -> Self;
fn with_mutation_probability_step(self, step: f64) -> Self;
}
pub trait StoppingConfig {
fn with_max_generations(self, max_generations: usize) -> Self;
fn with_fitness_target(self, fitness_target: f64) -> Self;
fn with_stopping_criteria(self, criteria: StoppingCriteria) -> Self;
}
pub trait NichingConfig {
fn with_niching_enabled(self, enabled: bool) -> Self;
fn with_niching_sigma_share(self, sigma_share: f64) -> Self;
fn with_niching_alpha(self, alpha: f64) -> Self;
}
pub trait ElitismConfig {
fn with_elitism(self, elitism_count: usize) -> Self;
}
pub trait ExtensionConfig {
fn with_extension_method(self, method: Extension) -> Self;
fn with_extension_diversity_threshold(self, threshold: f64) -> Self;
fn with_extension_survival_rate(self, rate: f64) -> Self;
fn with_extension_mutation_rounds(self, rounds: usize) -> Self;
fn with_extension_elite_count(self, count: usize) -> Self;
}
pub trait ConfigurationT:
SelectionConfig
+ CrossoverConfig
+ MutationConfig
+ StoppingConfig
+ NichingConfig
+ ElitismConfig
+ ExtensionConfig
{
fn new() -> Self;
fn with_adaptive_ga(self, adaptive_ga: bool) -> Self;
fn with_threads(self, number_of_threads: usize) -> Self;
fn with_logs(self, log_level: LogLevel) -> Self;
fn with_survivor_method(self, method: Survivor) -> Self;
fn with_problem_solving(self, problem_solving: ProblemSolving) -> Self;
fn with_population_size(self, population_size: usize) -> Self;
fn with_genes_per_chromosome(self, genes_per_chromosome: usize) -> Self;
fn with_needs_unique_ids(self, needs_unique_ids: bool) -> Self;
fn with_alleles_can_be_repeated(self, alleles_can_be_repeated: bool) -> Self;
fn with_save_progress(self, save_progress: bool) -> Self;
fn with_save_progress_interval(self, save_progress_interval: usize) -> Self;
fn with_save_progress_path(self, save_progress_path: String) -> Self;
fn with_rng_seed(self, seed: u64) -> Self;
}