use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NASConfig {
pub population_size: usize,
pub max_generations: usize,
pub mutation_rate: f64,
pub crossover_rate: f64,
pub early_stopping_patience: usize,
pub target_performance: f64,
pub max_training_epochs: usize,
pub evaluation_timeout: u64,
pub resource_constraints: ResourceConstraints,
pub random_seed: u64,
pub multi_objective_weights: MultiObjectiveWeights,
pub progressive_strategy: ProgressiveStrategy,
pub hardware_aware: bool,
pub enable_transfer_learning: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MultiObjectiveWeights {
pub performance_weight: f64,
pub efficiency_weight: f64,
pub latency_weight: f64,
pub energy_weight: f64,
pub size_weight: f64,
pub custom_weights: HashMap<String, f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProgressiveStrategy {
pub enabled: bool,
pub initial_complexity: SearchComplexity,
pub complexity_schedule: ComplexitySchedule,
pub progression_thresholds: Vec<f64>,
pub enable_knowledge_transfer: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, PartialOrd)]
pub enum SearchComplexity {
Simple,
Medium,
Complex,
VeryComplex,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ComplexitySchedule {
Linear { steps: usize },
Exponential { base: f64 },
Adaptive { threshold: f64 },
Manual { schedule: Vec<(usize, SearchComplexity)> },
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceConstraints {
pub max_parameters: usize,
pub max_memory_mb: usize,
pub max_training_time_minutes: usize,
pub max_inference_latency_ms: f64,
pub target_compression_ratio: f64,
}
impl Default for NASConfig {
fn default() -> Self {
Self {
population_size: 50,
max_generations: 100,
mutation_rate: 0.1,
crossover_rate: 0.8,
early_stopping_patience: 10,
target_performance: 0.95,
max_training_epochs: 100,
evaluation_timeout: 3600, resource_constraints: ResourceConstraints::default(),
random_seed: 42,
multi_objective_weights: MultiObjectiveWeights::default(),
progressive_strategy: ProgressiveStrategy::default(),
hardware_aware: true,
enable_transfer_learning: false,
}
}
}
impl Default for MultiObjectiveWeights {
fn default() -> Self {
Self {
performance_weight: 0.6,
efficiency_weight: 0.2,
latency_weight: 0.1,
energy_weight: 0.05,
size_weight: 0.05,
custom_weights: HashMap::new(),
}
}
}
impl Default for ProgressiveStrategy {
fn default() -> Self {
Self {
enabled: false,
initial_complexity: SearchComplexity::Simple,
complexity_schedule: ComplexitySchedule::Linear { steps: 10 },
progression_thresholds: vec![0.8, 0.85, 0.9],
enable_knowledge_transfer: true,
}
}
}
impl Default for ResourceConstraints {
fn default() -> Self {
Self {
max_parameters: 10_000_000, max_memory_mb: 2000, max_training_time_minutes: 120, max_inference_latency_ms: 100.0, target_compression_ratio: 0.1, }
}
}