optirs-core 0.3.1

OptiRS core optimization algorithms and utilities
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
// Configuration management for adaptive streaming optimization
//
// This module provides comprehensive configuration types and settings for
// streaming optimization scenarios, including drift detection parameters,
// performance tracking settings, resource allocation strategies, and
// adaptive buffer management configurations.

use serde::{Deserialize, Serialize};
use std::time::Duration;

/// Main configuration for adaptive streaming optimization
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct StreamingConfig {
    /// Buffer management configuration
    pub buffer_config: BufferConfig,
    /// Drift detection configuration
    pub drift_config: DriftConfig,
    /// Performance tracking configuration
    pub performance_config: PerformanceConfig,
    /// Resource management configuration
    pub resource_config: ResourceConfig,
    /// Meta-learning configuration
    pub meta_learning_config: MetaLearningConfig,
    /// Anomaly detection configuration
    pub anomaly_config: AnomalyConfig,
    /// Learning rate adaptation configuration
    pub learning_rate_config: LearningRateConfig,
}

/// Buffer management configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BufferConfig {
    /// Initial buffer size
    pub initial_size: usize,
    /// Maximum buffer size
    pub max_size: usize,
    /// Minimum buffer size
    pub min_size: usize,
    /// Buffer size adaptation strategy
    pub size_strategy: BufferSizeStrategy,
    /// Quality threshold for buffer processing
    pub quality_threshold: f64,
    /// Enable adaptive buffer sizing
    pub enable_adaptive_sizing: bool,
    /// Buffer processing timeout
    pub processing_timeout: Duration,
    /// Memory limit for buffer in MB
    pub memory_limit_mb: usize,
}

impl Default for BufferConfig {
    fn default() -> Self {
        Self {
            initial_size: 1000,
            max_size: 10000,
            min_size: 100,
            size_strategy: BufferSizeStrategy::Adaptive,
            quality_threshold: 0.8,
            enable_adaptive_sizing: true,
            processing_timeout: Duration::from_secs(30),
            memory_limit_mb: 512,
        }
    }
}

/// Buffer sizing strategies
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum BufferSizeStrategy {
    /// Fixed buffer size
    Fixed,
    /// Linear growth/shrinkage
    Linear { growth_rate: f64 },
    /// Exponential growth/shrinkage
    Exponential { base: f64 },
    /// Adaptive based on performance
    Adaptive,
    /// Based on resource availability
    ResourceBased,
}

/// Drift detection configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DriftConfig {
    /// Enable drift detection
    pub enable_detection: bool,
    /// Drift detection method
    pub detection_method: DriftDetectionMethod,
    /// Sensitivity for drift detection
    pub sensitivity: f64,
    /// Minimum samples before drift detection
    pub min_samples: usize,
    /// Warning threshold for gradual drift
    pub warning_threshold: f64,
    /// Drift threshold for concept drift
    pub drift_threshold: f64,
    /// Window size for statistical tests
    pub window_size: usize,
    /// Enable false positive tracking
    pub enable_false_positive_tracking: bool,
    /// Statistical significance level
    pub significance_level: f64,
    /// Adaptation speed after drift detection
    pub adaptation_speed: f64,
}

impl Default for DriftConfig {
    fn default() -> Self {
        Self {
            enable_detection: true,
            detection_method: DriftDetectionMethod::Statistical(StatisticalMethod::ADWIN),
            sensitivity: 0.05,
            min_samples: 30,
            warning_threshold: 0.8,
            drift_threshold: 1.2,
            window_size: 1000,
            enable_false_positive_tracking: true,
            significance_level: 0.05,
            adaptation_speed: 0.1,
        }
    }
}

/// Drift detection methods
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DriftDetectionMethod {
    /// Statistical methods for drift detection
    Statistical(StatisticalMethod),
    /// Distribution-based methods
    Distribution(DistributionMethod),
    /// Model-based drift detection
    ModelBased(ModelType),
    /// Ensemble of multiple methods
    Ensemble {
        methods: Vec<DriftDetectionMethod>,
        voting_strategy: VotingStrategy,
    },
}

/// Statistical methods for drift detection
#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)]
pub enum StatisticalMethod {
    /// Adaptive Windowing (ADWIN)
    ADWIN,
    /// Drift Detection Method (DDM)
    DDM,
    /// Early Drift Detection Method (EDDM)
    EDDM,
    /// Page Hinkley test
    PageHinkley,
    /// CUSUM test
    CUSUM,
    /// Kolmogorov-Smirnov test
    KolmogorovSmirnov,
    /// Mann-Whitney U test
    MannWhitneyU,
}

/// Distribution-based drift detection methods
#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)]
pub enum DistributionMethod {
    /// Kullback-Leibler divergence
    KLDivergence,
    /// Jensen-Shannon divergence
    JSDivergence,
    /// Hellinger distance
    HellingerDistance,
    /// Wasserstein distance
    WassersteinDistance,
    /// Earth Mover's Distance
    EarthMoverDistance,
}

/// Model types for drift detection
#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)]
pub enum ModelType {
    /// Linear model comparison
    Linear,
    /// Neural network based
    NeuralNetwork,
    /// Decision tree based
    DecisionTree,
    /// Ensemble methods
    Ensemble,
}

/// Voting strategies for ensemble drift detection
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum VotingStrategy {
    /// Majority voting
    Majority,
    /// Weighted voting
    Weighted { weights: Vec<f64> },
    /// Unanimous decision
    Unanimous,
    /// Threshold-based (minimum number of votes)
    Threshold { min_votes: usize },
}

/// Performance tracking configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PerformanceConfig {
    /// Enable performance tracking
    pub enable_tracking: bool,
    /// Performance metrics to track
    pub metrics: Vec<PerformanceMetricType>,
    /// Performance history size
    pub history_size: usize,
    /// Performance evaluation frequency
    pub evaluation_frequency: usize,
    /// Enable trend analysis
    pub enable_trend_analysis: bool,
    /// Trend window size
    pub trend_window_size: usize,
    /// Enable performance prediction
    pub enable_prediction: bool,
    /// Prediction horizon (steps ahead)
    pub prediction_horizon: usize,
    /// Performance baseline update frequency
    pub baseline_update_frequency: usize,
}

impl Default for PerformanceConfig {
    fn default() -> Self {
        Self {
            enable_tracking: true,
            metrics: vec![
                PerformanceMetricType::Loss,
                PerformanceMetricType::Accuracy,
                PerformanceMetricType::Convergence,
                PerformanceMetricType::ResourceUsage,
            ],
            history_size: 1000,
            evaluation_frequency: 10,
            enable_trend_analysis: true,
            trend_window_size: 100,
            enable_prediction: true,
            prediction_horizon: 10,
            baseline_update_frequency: 100,
        }
    }
}

/// Types of performance metrics to track
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PerformanceMetricType {
    /// Loss function value
    Loss,
    /// Accuracy metric
    Accuracy,
    /// Convergence rate
    Convergence,
    /// Resource usage efficiency
    ResourceUsage,
    /// Gradient norm
    GradientNorm,
    /// Parameter updates magnitude
    ParameterUpdates,
    /// Learning rate effectiveness
    LearningRateEffectiveness,
    /// Custom metric
    Custom(String),
}

/// Resource management configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceConfig {
    /// Maximum memory usage in MB
    pub max_memory_mb: usize,
    /// Maximum CPU usage percentage
    pub max_cpu_percent: f64,
    /// Resource allocation strategy
    pub allocation_strategy: ResourceAllocationStrategy,
    /// Enable dynamic resource allocation
    pub enable_dynamic_allocation: bool,
    /// Resource monitoring frequency
    pub monitoring_frequency: Duration,
    /// Resource budget constraints
    pub budget_constraints: ResourceBudgetConstraints,
    /// Enable resource prediction
    pub enable_resource_prediction: bool,
    /// Resource cleanup threshold
    pub cleanup_threshold: f64,
}

impl Default for ResourceConfig {
    fn default() -> Self {
        Self {
            max_memory_mb: 2048,
            max_cpu_percent: 80.0,
            allocation_strategy: ResourceAllocationStrategy::Adaptive,
            enable_dynamic_allocation: true,
            monitoring_frequency: Duration::from_secs(10),
            budget_constraints: ResourceBudgetConstraints::default(),
            enable_resource_prediction: true,
            cleanup_threshold: 0.9,
        }
    }
}

/// Resource allocation strategies
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ResourceAllocationStrategy {
    /// Static allocation
    Static,
    /// Dynamic allocation based on demand
    Dynamic,
    /// Adaptive allocation based on performance
    Adaptive,
    /// Proportional allocation
    Proportional,
    /// Priority-based allocation
    PriorityBased,
}

/// Resource budget constraints
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceBudgetConstraints {
    /// Memory budget in MB
    pub memory_budget_mb: usize,
    /// CPU budget as percentage
    pub cpu_budget_percent: f64,
    /// Time budget per operation
    pub time_budget: Duration,
    /// Enable strict budget enforcement
    pub strict_enforcement: bool,
    /// Budget violation penalty
    pub violation_penalty: f64,
}

impl Default for ResourceBudgetConstraints {
    fn default() -> Self {
        Self {
            memory_budget_mb: 1024,
            cpu_budget_percent: 60.0,
            time_budget: Duration::from_secs(60),
            strict_enforcement: false,
            violation_penalty: 0.1,
        }
    }
}

/// Meta-learning configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetaLearningConfig {
    /// Enable meta-learning
    pub enable_meta_learning: bool,
    /// Meta-learning algorithm
    pub algorithm: MetaAlgorithm,
    /// Experience buffer size
    pub experience_buffer_size: usize,
    /// Meta-learning update frequency
    pub update_frequency: usize,
    /// Learning rate for meta-learning
    pub meta_learning_rate: f64,
    /// Exploration rate for meta-learning
    pub exploration_rate: f64,
    /// Meta-model complexity
    pub model_complexity: MetaModelComplexity,
    /// Enable transfer learning
    pub enable_transfer_learning: bool,
    /// Experience replay configuration
    pub replay_config: ExperienceReplayConfig,
}

impl Default for MetaLearningConfig {
    fn default() -> Self {
        Self {
            enable_meta_learning: true,
            algorithm: MetaAlgorithm::ModelAgnosticMetaLearning,
            experience_buffer_size: 10000,
            update_frequency: 100,
            meta_learning_rate: 0.001,
            exploration_rate: 0.1,
            model_complexity: MetaModelComplexity::Medium,
            enable_transfer_learning: true,
            replay_config: ExperienceReplayConfig::default(),
        }
    }
}

/// Meta-learning algorithms
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MetaAlgorithm {
    /// Model-Agnostic Meta-Learning (MAML)
    ModelAgnosticMetaLearning,
    /// Learning to Learn by Gradient Descent by Gradient Descent
    LearningToLearn,
    /// Meta-SGD
    MetaSGD,
    /// Reptile
    Reptile,
    /// Online Meta-Learning
    OnlineMetaLearning,
    /// Continual Meta-Learning
    ContinualMetaLearning,
}

/// Meta-model complexity levels
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MetaModelComplexity {
    /// Low complexity (simple linear models)
    Low,
    /// Medium complexity (small neural networks)
    Medium,
    /// High complexity (large neural networks)
    High,
    /// Adaptive complexity based on performance
    Adaptive,
}

/// Experience replay configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExperienceReplayConfig {
    /// Enable prioritized experience replay
    pub enable_prioritized_replay: bool,
    /// Priority calculation method
    pub priority_method: PriorityMethod,
    /// Replay batch size
    pub batch_size: usize,
    /// Replay frequency
    pub replay_frequency: usize,
    /// Experience importance sampling
    pub importance_sampling: bool,
}

impl Default for ExperienceReplayConfig {
    fn default() -> Self {
        Self {
            enable_prioritized_replay: true,
            priority_method: PriorityMethod::TDError,
            batch_size: 32,
            replay_frequency: 10,
            importance_sampling: true,
        }
    }
}

/// Priority calculation methods for experience replay
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PriorityMethod {
    /// Temporal Difference error
    TDError,
    /// Surprise-based priority
    Surprise,
    /// Gradient magnitude
    GradientMagnitude,
    /// Loss improvement
    LossImprovement,
    /// Random priority
    Random,
}

/// Anomaly detection configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AnomalyConfig {
    /// Enable anomaly detection
    pub enable_detection: bool,
    /// Anomaly detection method
    pub detection_method: AnomalyDetectionMethod,
    /// Anomaly threshold
    pub threshold: f64,
    /// Window size for anomaly detection
    pub window_size: usize,
    /// Enable adaptive thresholding
    pub enable_adaptive_threshold: bool,
    /// False positive rate tolerance
    pub false_positive_rate: f64,
    /// Contamination rate assumption
    pub contamination_rate: f64,
    /// Response strategy for detected anomalies
    pub response_strategy: AnomalyResponseStrategy,
}

impl Default for AnomalyConfig {
    fn default() -> Self {
        Self {
            enable_detection: true,
            detection_method: AnomalyDetectionMethod::StatisticalOutlier,
            threshold: 2.0,
            window_size: 100,
            enable_adaptive_threshold: true,
            false_positive_rate: 0.05,
            contamination_rate: 0.1,
            response_strategy: AnomalyResponseStrategy::Adaptive,
        }
    }
}

/// Anomaly detection methods
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AnomalyDetectionMethod {
    /// Statistical outlier detection
    StatisticalOutlier,
    /// Isolation Forest
    IsolationForest,
    /// One-Class SVM
    OneClassSVM,
    /// Local Outlier Factor
    LocalOutlierFactor,
    /// Autoencoders
    Autoencoder,
    /// Ensemble methods
    Ensemble,
}

/// Response strategies for detected anomalies
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AnomalyResponseStrategy {
    /// Ignore anomalies
    Ignore,
    /// Filter out anomalous data
    Filter,
    /// Adapt model to handle anomalies
    Adaptive,
    /// Reset to safe state
    Reset,
    /// Custom response strategy
    Custom(String),
}

/// Learning rate adaptation configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LearningRateConfig {
    /// Initial learning rate
    pub initial_rate: f64,
    /// Minimum learning rate
    pub min_rate: f64,
    /// Maximum learning rate
    pub max_rate: f64,
    /// Learning rate adaptation strategy
    pub adaptation_strategy: LearningRateAdaptationStrategy,
    /// Adaptation frequency
    pub adaptation_frequency: usize,
    /// Performance sensitivity for adaptation
    pub performance_sensitivity: f64,
    /// Enable cyclical learning rates
    pub enable_cyclical_rates: bool,
    /// Cycle configuration
    pub cycle_config: CyclicalRateConfig,
}

impl Default for LearningRateConfig {
    fn default() -> Self {
        Self {
            initial_rate: 0.001,
            min_rate: 1e-6,
            max_rate: 0.1,
            adaptation_strategy: LearningRateAdaptationStrategy::PerformanceBased,
            adaptation_frequency: 10,
            performance_sensitivity: 0.1,
            enable_cyclical_rates: false,
            cycle_config: CyclicalRateConfig::default(),
        }
    }
}

/// Learning rate adaptation strategies
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum LearningRateAdaptationStrategy {
    /// Fixed learning rate
    Fixed,
    /// Step decay
    StepDecay { decay_rate: f64, decay_steps: usize },
    /// Exponential decay
    ExponentialDecay { decay_rate: f64 },
    /// Performance-based adaptation
    PerformanceBased,
    /// Gradient-based adaptation
    GradientBased,
    /// Adaptive learning rate (AdaGrad-style)
    Adaptive,
    /// Cosine annealing
    CosineAnnealing { t_max: usize },
}

/// Cyclical learning rate configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CyclicalRateConfig {
    /// Base learning rate
    pub base_rate: f64,
    /// Maximum learning rate in cycle
    pub max_rate: f64,
    /// Cycle length (number of steps)
    pub cycle_length: usize,
    /// Cycle mode
    pub cycle_mode: CycleMode,
    /// Scale function for cycle
    pub scale_function: ScaleFunction,
}

impl Default for CyclicalRateConfig {
    fn default() -> Self {
        Self {
            base_rate: 0.0001,
            max_rate: 0.001,
            cycle_length: 1000,
            cycle_mode: CycleMode::Triangular,
            scale_function: ScaleFunction::Linear,
        }
    }
}

/// Cyclical learning rate cycle modes
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CycleMode {
    /// Triangular cycle
    Triangular,
    /// Triangular2 (amplitude scales)
    Triangular2,
    /// Exponential range
    ExponentialRange,
    /// Custom cycle pattern
    Custom(String),
}

/// Scale functions for cyclical learning rates
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ScaleFunction {
    /// Linear scaling
    Linear,
    /// Exponential scaling
    Exponential { factor: f64 },
    /// Polynomial scaling
    Polynomial { power: f64 },
    /// Custom scaling function
    Custom(String),
}

/// Validation methods for configuration
impl StreamingConfig {
    /// Validates the configuration for consistency and feasibility
    pub fn validate(&self) -> Result<(), String> {
        // Validate buffer configuration
        if self.buffer_config.max_size < self.buffer_config.min_size {
            return Err("Buffer max_size must be >= min_size".to_string());
        }

        if self.buffer_config.initial_size < self.buffer_config.min_size
            || self.buffer_config.initial_size > self.buffer_config.max_size
        {
            return Err("Buffer initial_size must be between min_size and max_size".to_string());
        }

        // Validate drift configuration
        if self.drift_config.sensitivity <= 0.0 || self.drift_config.sensitivity > 1.0 {
            return Err("Drift sensitivity must be in (0, 1]".to_string());
        }

        if self.drift_config.warning_threshold >= self.drift_config.drift_threshold {
            return Err("Drift warning_threshold must be < drift_threshold".to_string());
        }

        // Validate learning rate configuration
        if self.learning_rate_config.min_rate >= self.learning_rate_config.max_rate {
            return Err("Learning rate min_rate must be < max_rate".to_string());
        }

        if self.learning_rate_config.initial_rate < self.learning_rate_config.min_rate
            || self.learning_rate_config.initial_rate > self.learning_rate_config.max_rate
        {
            return Err(
                "Learning rate initial_rate must be between min_rate and max_rate".to_string(),
            );
        }

        // Validate resource configuration
        if self.resource_config.max_cpu_percent <= 0.0
            || self.resource_config.max_cpu_percent > 100.0
        {
            return Err("Resource max_cpu_percent must be in (0, 100]".to_string());
        }

        // Validate meta-learning configuration
        if self.meta_learning_config.meta_learning_rate <= 0.0 {
            return Err("Meta-learning rate must be > 0".to_string());
        }

        if self.meta_learning_config.exploration_rate < 0.0
            || self.meta_learning_config.exploration_rate > 1.0
        {
            return Err("Meta-learning exploration_rate must be in [0, 1]".to_string());
        }

        Ok(())
    }

    /// Creates a configuration optimized for low-latency streaming
    pub fn low_latency() -> Self {
        let mut config = Self::default();
        config.buffer_config.initial_size = 100;
        config.buffer_config.max_size = 1000;
        config.buffer_config.processing_timeout = Duration::from_millis(100);
        config.performance_config.evaluation_frequency = 5;
        config.drift_config.min_samples = 10;
        config.resource_config.monitoring_frequency = Duration::from_secs(1);
        config
    }

    /// Creates a configuration optimized for high-throughput streaming
    pub fn high_throughput() -> Self {
        let mut config = Self::default();
        config.buffer_config.initial_size = 5000;
        config.buffer_config.max_size = 50000;
        config.buffer_config.memory_limit_mb = 2048;
        config.performance_config.evaluation_frequency = 100;
        config.drift_config.window_size = 5000;
        config.resource_config.max_memory_mb = 4096;
        config
    }

    /// Creates a configuration optimized for memory-constrained environments
    pub fn memory_efficient() -> Self {
        let mut config = Self::default();
        config.buffer_config.initial_size = 200;
        config.buffer_config.max_size = 2000;
        config.buffer_config.memory_limit_mb = 128;
        config.performance_config.history_size = 100;
        config.meta_learning_config.experience_buffer_size = 1000;
        config.resource_config.max_memory_mb = 256;
        config.drift_config.window_size = 500;
        config
    }
}