crackle_runtime/
profile.rs1use std::time::Duration;
2
3#[derive(Debug, Clone, Copy, PartialEq, Default)]
10pub enum CoolingRate {
11 Fast,
14 #[default]
16 Normal,
17 Slow,
21}
22
23impl CoolingRate {
24 pub fn cluster_threshold(&self) -> f64 {
26 match self {
27 CoolingRate::Fast => 1.5,
28 CoolingRate::Normal => 2.5,
29 CoolingRate::Slow => 4.0,
30 }
31 }
32
33 pub fn correlation_threshold(&self) -> f64 {
35 match self {
36 CoolingRate::Fast => 0.5,
37 CoolingRate::Normal => 0.7,
38 CoolingRate::Slow => 0.9,
39 }
40 }
41
42 pub fn min_tasks_for_detection(&self) -> usize {
44 match self {
45 CoolingRate::Fast => 2,
46 CoolingRate::Normal => 3,
47 CoolingRate::Slow => 5,
48 }
49 }
50
51 pub fn phase_transition_sensitivity(&self) -> f64 {
53 match self {
54 CoolingRate::Fast => 0.3,
55 CoolingRate::Normal => 0.5,
56 CoolingRate::Slow => 0.8,
57 }
58 }
59
60 pub fn conservation_tolerance(&self) -> f64 {
62 match self {
63 CoolingRate::Fast => 0.5,
64 CoolingRate::Normal => 0.3,
65 CoolingRate::Slow => 0.1,
66 }
67 }
68}
69
70#[derive(Debug, Clone)]
75pub struct ThermalProfile {
76 pub rate: CoolingRate,
78 pub max_cooling_duration: Duration,
80 pub detect_clustering: bool,
82 pub detect_phase_transitions: bool,
84 pub detect_conservation: bool,
86 pub detect_correlations: bool,
88}
89
90impl Default for ThermalProfile {
91 fn default() -> Self {
92 ThermalProfile {
93 rate: CoolingRate::Normal,
94 max_cooling_duration: Duration::from_secs(60),
95 detect_clustering: true,
96 detect_phase_transitions: true,
97 detect_conservation: true,
98 detect_correlations: true,
99 }
100 }
101}
102
103impl ThermalProfile {
104 pub fn fast_cooling() -> Self {
106 ThermalProfile {
107 rate: CoolingRate::Fast,
108 max_cooling_duration: Duration::from_secs(10),
109 ..ThermalProfile::default()
110 }
111 }
112
113 pub fn slow_cooling() -> Self {
115 ThermalProfile {
116 rate: CoolingRate::Slow,
117 max_cooling_duration: Duration::from_secs(300),
118 ..ThermalProfile::default()
119 }
120 }
121
122 pub fn no_detection() -> Self {
124 ThermalProfile {
125 detect_clustering: false,
126 detect_phase_transitions: false,
127 detect_conservation: false,
128 detect_correlations: false,
129 ..ThermalProfile::default()
130 }
131 }
132
133 pub fn with_rate(mut self, rate: CoolingRate) -> Self {
135 self.rate = rate;
136 self
137 }
138
139 pub fn without_clustering(mut self) -> Self {
141 self.detect_clustering = false;
142 self
143 }
144
145 pub fn without_phase_transitions(mut self) -> Self {
147 self.detect_phase_transitions = false;
148 self
149 }
150
151 pub fn without_conservation(mut self) -> Self {
153 self.detect_conservation = false;
154 self
155 }
156
157 pub fn without_correlations(mut self) -> Self {
159 self.detect_correlations = false;
160 self
161 }
162}