quantrs2_anneal/active_learning_decomposition/
config.rs

1//! Configuration types for active learning decomposition
2
3use std::time::Duration;
4
5/// Configuration for active learning decomposition
6#[derive(Debug, Clone)]
7pub struct ActiveLearningConfig {
8    /// Enable online learning
9    pub enable_online_learning: bool,
10    /// Maximum decomposition depth
11    pub max_decomposition_depth: usize,
12    /// Minimum subproblem size
13    pub min_subproblem_size: usize,
14    /// Maximum subproblem size
15    pub max_subproblem_size: usize,
16    /// Learning rate for strategy updates
17    pub learning_rate: f64,
18    /// Exploration rate for active learning
19    pub exploration_rate: f64,
20    /// Performance threshold for decomposition
21    pub performance_threshold: f64,
22    /// Enable transfer learning
23    pub enable_transfer_learning: bool,
24    /// Active learning query budget
25    pub query_budget: usize,
26    /// Decomposition overlap tolerance
27    pub overlap_tolerance: f64,
28}
29
30impl Default for ActiveLearningConfig {
31    fn default() -> Self {
32        Self {
33            enable_online_learning: true,
34            max_decomposition_depth: 3,
35            min_subproblem_size: 2,
36            max_subproblem_size: 100,
37            learning_rate: 0.01,
38            exploration_rate: 0.1,
39            performance_threshold: 0.7,
40            enable_transfer_learning: true,
41            query_budget: 100,
42            overlap_tolerance: 0.1,
43        }
44    }
45}
46
47/// Metric computation configuration
48#[derive(Debug, Clone)]
49pub struct MetricComputationConfig {
50    /// Enable expensive metrics
51    pub enable_expensive_metrics: bool,
52    /// Approximation algorithms enabled
53    pub enable_approximation: bool,
54    /// Sampling ratio for large graphs
55    pub sampling_ratio: f64,
56    /// Timeout for metric computation
57    pub computation_timeout: Duration,
58}
59
60impl Default for MetricComputationConfig {
61    fn default() -> Self {
62        Self {
63            enable_expensive_metrics: false,
64            enable_approximation: true,
65            sampling_ratio: 0.1,
66            computation_timeout: Duration::from_secs(60),
67        }
68    }
69}
70
71/// Size constraints
72#[derive(Debug, Clone)]
73pub struct SizeConstraints {
74    /// Minimum subproblem size
75    pub min_size: usize,
76    /// Maximum subproblem size
77    pub max_size: usize,
78    /// Target size
79    pub target_size: usize,
80    /// Size tolerance
81    pub size_tolerance: f64,
82}
83
84impl Default for SizeConstraints {
85    fn default() -> Self {
86        Self {
87            min_size: 2,
88            max_size: 100,
89            target_size: 20,
90            size_tolerance: 0.2,
91        }
92    }
93}
94
95/// Resource constraints
96#[derive(Debug, Clone)]
97pub struct ResourceConstraints {
98    /// Maximum computation time
99    pub max_computation_time: Duration,
100    /// Maximum memory usage
101    pub max_memory_usage: usize,
102    /// Number of available processors
103    pub num_processors: usize,
104    /// Communication bandwidth
105    pub communication_bandwidth: f64,
106}
107
108impl Default for ResourceConstraints {
109    fn default() -> Self {
110        Self {
111            max_computation_time: Duration::from_secs(300),
112            max_memory_usage: 1024 * 1024 * 1024, // 1 GB
113            num_processors: 4,
114            communication_bandwidth: 1000.0,
115        }
116    }
117}