use std::time::Duration;
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum CoolingRate {
Fast,
#[default]
Normal,
Slow,
}
impl CoolingRate {
pub fn cluster_threshold(&self) -> f64 {
match self {
CoolingRate::Fast => 1.5,
CoolingRate::Normal => 2.5,
CoolingRate::Slow => 4.0,
}
}
pub fn correlation_threshold(&self) -> f64 {
match self {
CoolingRate::Fast => 0.5,
CoolingRate::Normal => 0.7,
CoolingRate::Slow => 0.9,
}
}
pub fn min_tasks_for_detection(&self) -> usize {
match self {
CoolingRate::Fast => 2,
CoolingRate::Normal => 3,
CoolingRate::Slow => 5,
}
}
pub fn phase_transition_sensitivity(&self) -> f64 {
match self {
CoolingRate::Fast => 0.3,
CoolingRate::Normal => 0.5,
CoolingRate::Slow => 0.8,
}
}
pub fn conservation_tolerance(&self) -> f64 {
match self {
CoolingRate::Fast => 0.5,
CoolingRate::Normal => 0.3,
CoolingRate::Slow => 0.1,
}
}
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ThermalProfile {
pub rate: CoolingRate,
pub max_cooling_duration: Duration,
pub detect_clustering: bool,
pub detect_phase_transitions: bool,
pub detect_conservation: bool,
pub detect_correlations: bool,
}
impl Default for ThermalProfile {
fn default() -> Self {
ThermalProfile {
rate: CoolingRate::Normal,
max_cooling_duration: Duration::from_secs(60),
detect_clustering: true,
detect_phase_transitions: true,
detect_conservation: true,
detect_correlations: true,
}
}
}
impl ThermalProfile {
pub fn fast_cooling() -> Self {
ThermalProfile {
rate: CoolingRate::Fast,
max_cooling_duration: Duration::from_secs(10),
..ThermalProfile::default()
}
}
pub fn slow_cooling() -> Self {
ThermalProfile {
rate: CoolingRate::Slow,
max_cooling_duration: Duration::from_secs(300),
..ThermalProfile::default()
}
}
pub fn no_detection() -> Self {
ThermalProfile {
detect_clustering: false,
detect_phase_transitions: false,
detect_conservation: false,
detect_correlations: false,
..ThermalProfile::default()
}
}
pub fn with_rate(mut self, rate: CoolingRate) -> Self {
self.rate = rate;
self
}
pub fn without_clustering(mut self) -> Self {
self.detect_clustering = false;
self
}
pub fn without_phase_transitions(mut self) -> Self {
self.detect_phase_transitions = false;
self
}
pub fn without_conservation(mut self) -> Self {
self.detect_conservation = false;
self
}
pub fn without_correlations(mut self) -> Self {
self.detect_correlations = false;
self
}
}