#[derive(Debug, Clone)]
pub struct AdvancedInterpolationConfig {
pub enable_method_selection: bool,
pub enable_adaptive_optimization: bool,
pub enable_quantum_optimization: bool,
pub enable_knowledge_transfer: bool,
pub target_accuracy: f64,
pub max_memory_mb: usize,
pub monitoring_interval: usize,
pub enable_real_time_learning: bool,
pub enable_error_prediction: bool,
pub cache_size_limit: usize,
pub adaptation_threshold: f64,
pub enable_hardware_optimization: bool,
}
impl Default for AdvancedInterpolationConfig {
fn default() -> Self {
Self {
enable_method_selection: true,
enable_adaptive_optimization: true,
enable_quantum_optimization: true,
enable_knowledge_transfer: true,
target_accuracy: 1e-6,
max_memory_mb: 4096, monitoring_interval: 50,
enable_real_time_learning: true,
enable_error_prediction: true,
cache_size_limit: 500,
adaptation_threshold: 0.05, enable_hardware_optimization: true,
}
}
}
#[derive(Debug, Default)]
pub struct AdvancedInterpolationConfigBuilder {
config: AdvancedInterpolationConfig,
}
impl AdvancedInterpolationConfigBuilder {
pub fn new() -> Self {
Self {
config: AdvancedInterpolationConfig::default(),
}
}
pub fn method_selection(mut self, enabled: bool) -> Self {
self.config.enable_method_selection = enabled;
self
}
pub fn adaptive_optimization(mut self, enabled: bool) -> Self {
self.config.enable_adaptive_optimization = enabled;
self
}
pub fn quantum_optimization(mut self, enabled: bool) -> Self {
self.config.enable_quantum_optimization = enabled;
self
}
pub fn knowledge_transfer(mut self, enabled: bool) -> Self {
self.config.enable_knowledge_transfer = enabled;
self
}
pub fn target_accuracy(mut self, accuracy: f64) -> Self {
self.config.target_accuracy = accuracy;
self
}
pub fn max_memory_mb(mut self, memory_mb: usize) -> Self {
self.config.max_memory_mb = memory_mb;
self
}
pub fn monitoring_interval(mut self, interval: usize) -> Self {
self.config.monitoring_interval = interval;
self
}
pub fn real_time_learning(mut self, enabled: bool) -> Self {
self.config.enable_real_time_learning = enabled;
self
}
pub fn error_prediction(mut self, enabled: bool) -> Self {
self.config.enable_error_prediction = enabled;
self
}
pub fn cache_size_limit(mut self, limit: usize) -> Self {
self.config.cache_size_limit = limit;
self
}
pub fn adaptation_threshold(mut self, threshold: f64) -> Self {
self.config.adaptation_threshold = threshold;
self
}
pub fn hardware_optimization(mut self, enabled: bool) -> Self {
self.config.enable_hardware_optimization = enabled;
self
}
pub fn build(self) -> AdvancedInterpolationConfig {
self.config
}
}
pub struct ConfigPresets;
impl ConfigPresets {
pub fn high_accuracy() -> AdvancedInterpolationConfig {
AdvancedInterpolationConfigBuilder::new()
.target_accuracy(1e-12)
.method_selection(true)
.adaptive_optimization(true)
.quantum_optimization(true)
.knowledge_transfer(true)
.max_memory_mb(8192)
.build()
}
pub fn high_performance() -> AdvancedInterpolationConfig {
AdvancedInterpolationConfigBuilder::new()
.target_accuracy(1e-3)
.method_selection(true)
.adaptive_optimization(false)
.quantum_optimization(false)
.knowledge_transfer(false)
.max_memory_mb(2048)
.monitoring_interval(100)
.build()
}
pub fn balanced() -> AdvancedInterpolationConfig {
AdvancedInterpolationConfig::default()
}
pub fn memory_constrained() -> AdvancedInterpolationConfig {
AdvancedInterpolationConfigBuilder::new()
.max_memory_mb(512)
.cache_size_limit(50)
.adaptive_optimization(false)
.quantum_optimization(false)
.build()
}
pub fn real_time() -> AdvancedInterpolationConfig {
AdvancedInterpolationConfigBuilder::new()
.target_accuracy(1e-4)
.method_selection(true)
.adaptive_optimization(false)
.quantum_optimization(false)
.knowledge_transfer(false)
.real_time_learning(true)
.monitoring_interval(10)
.build()
}
pub fn research() -> AdvancedInterpolationConfig {
AdvancedInterpolationConfigBuilder::new()
.method_selection(true)
.adaptive_optimization(true)
.quantum_optimization(true)
.knowledge_transfer(true)
.real_time_learning(true)
.error_prediction(true)
.hardware_optimization(true)
.max_memory_mb(16384)
.build()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_config() {
let config = AdvancedInterpolationConfig::default();
assert!(config.enable_method_selection);
assert!(config.enable_adaptive_optimization);
assert_eq!(config.target_accuracy, 1e-6);
}
#[test]
fn test_config_builder() {
let config = AdvancedInterpolationConfigBuilder::new()
.target_accuracy(1e-9)
.method_selection(false)
.max_memory_mb(1024)
.build();
assert_eq!(config.target_accuracy, 1e-9);
assert!(!config.enable_method_selection);
assert_eq!(config.max_memory_mb, 1024);
}
#[test]
fn test_preset_configurations() {
let high_acc = ConfigPresets::high_accuracy();
assert_eq!(high_acc.target_accuracy, 1e-12);
assert_eq!(high_acc.max_memory_mb, 8192);
let high_perf = ConfigPresets::high_performance();
assert_eq!(high_perf.target_accuracy, 1e-3);
assert!(!high_perf.enable_adaptive_optimization);
let memory_const = ConfigPresets::memory_constrained();
assert_eq!(memory_const.max_memory_mb, 512);
assert_eq!(memory_const.cache_size_limit, 50);
}
}