quantrs2_device/ml_optimization/
online_learning.rs

1//! Online Learning Configuration Types
2
3use serde::{Deserialize, Serialize};
4use std::time::Duration;
5
6/// Online learning configuration
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct OnlineLearningConfig {
9    /// Enable online learning
10    pub enable_online_learning: bool,
11    /// Learning rate schedule
12    pub learning_rate_schedule: LearningRateSchedule,
13    /// Memory management
14    pub memory_management: MemoryManagementConfig,
15    /// Catastrophic forgetting prevention
16    pub forgetting_prevention: ForgettingPreventionConfig,
17    /// Incremental learning
18    pub incremental_learning: IncrementalLearningConfig,
19}
20
21/// Learning rate schedule
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
23pub enum LearningRateSchedule {
24    Constant,
25    ExponentialDecay,
26    StepDecay,
27    PolynomialDecay,
28    CosineAnnealing,
29    Adaptive,
30}
31
32/// Memory management configuration
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct MemoryManagementConfig {
35    /// Maximum memory buffer size
36    pub max_buffer_size: usize,
37    /// Memory eviction strategy
38    pub eviction_strategy: MemoryEvictionStrategy,
39    /// Replay buffer management
40    pub replay_buffer: bool,
41    /// Experience prioritization
42    pub experience_prioritization: bool,
43}
44
45/// Memory eviction strategies
46#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
47pub enum MemoryEvictionStrategy {
48    FIFO,
49    LRU,
50    LFU,
51    RandomEviction,
52    ImportanceBased,
53    RecentnessBased,
54}
55
56/// Forgetting prevention configuration
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub struct ForgettingPreventionConfig {
59    /// Enable elastic weight consolidation
60    pub elastic_weight_consolidation: bool,
61    /// Enable progressive neural networks
62    pub progressive_networks: bool,
63    /// Enable memory replay
64    pub memory_replay: bool,
65    /// Regularization strength
66    pub regularization_strength: f64,
67}
68
69/// Incremental learning configuration
70#[derive(Debug, Clone, Serialize, Deserialize)]
71pub struct IncrementalLearningConfig {
72    /// Batch size for incremental updates
73    pub incremental_batch_size: usize,
74    /// Update frequency
75    pub update_frequency: Duration,
76    /// Stability-plasticity balance
77    pub stability_plasticity_balance: f64,
78    /// Knowledge distillation
79    pub knowledge_distillation: bool,
80}