Skip to main content

optirs_nas/evaluation/
types.rs

1//! Common types for evaluation system
2//!
3//! Contains shared enums and small structs used across multiple modules.
4//!
5//! Two families of types were removed from this module rather than left as a
6//! public vocabulary for subsystems that do not exist:
7//!
8//! * `ScheduleType`, `FeatureExtractionMethod`, `NormalizationMethod`,
9//!   `ScalingMethod`, `FeatureSelectionMethod` and `UncertaintyEstimationMethod`
10//!   described a neural-network performance predictor with a feature-engineering
11//!   pipeline that was never built. Their only occurrences were one initialiser
12//!   each inside [`super::predictor`], whose value nothing then read; the
13//!   predictor is a linear ridge model and now says so.
14//!   ([`crate::nas_engine::config::ScheduleType`], which *is* consulted, is a
15//!   different type and is unaffected.)
16//! * `ProblemType`, `CorrelationStructure`, `DistributionType`, `MetricType`,
17//!   `EvaluatorType`, `DataFormat`, `DataCharacteristics`, `SuccessMetrics`,
18//!   `TerminationConditions`, `EarlyStoppingCriteria`, `EvaluationCriterion`,
19//!   `IOSpecification` and `ValidationCriteria` described caller-supplied custom
20//!   benchmarks. [`super::benchmark::BenchmarkSuite`] could neither register nor
21//!   run one — see that module's notes.
22
23use scirs2_core::numeric::Float;
24use serde::{Deserialize, Serialize};
25use std::collections::HashMap;
26use std::fmt::Debug;
27
28/// Benchmark types
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
30pub enum BenchmarkType {
31    /// Convergence speed test
32    ConvergenceSpeed,
33
34    /// Final performance test
35    FinalPerformance,
36
37    /// Robustness test
38    Robustness,
39
40    /// Generalization test
41    Generalization,
42
43    /// Efficiency test
44    Efficiency,
45
46    /// Scalability test
47    Scalability,
48
49    /// Transfer learning test
50    TransferLearning,
51
52    /// Multi-task test
53    MultiTask,
54
55    /// Noisy optimization test
56    NoisyOptimization,
57
58    /// Non-convex optimization test
59    NonConvexOptimization,
60}
61
62/// Types of test functions
63#[derive(Debug, Clone, PartialEq, Eq, Hash)]
64pub enum TestFunctionType {
65    /// Quadratic bowl
66    Quadratic,
67
68    /// Rosenbrock function
69    Rosenbrock,
70
71    /// Rastrigin function
72    Rastrigin,
73
74    /// Ackley function
75    Ackley,
76
77    /// Sphere function
78    Sphere,
79
80    /// Beale function
81    Beale,
82
83    /// Neural network training
84    NeuralNetworkTraining,
85
86    /// Linear regression
87    LinearRegression,
88
89    /// Logistic regression
90    LogisticRegression,
91
92    /// Custom function
93    Custom(String),
94}
95
96/// Difficulty levels
97#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
98pub enum DifficultyLevel {
99    Easy,
100    Medium,
101    Hard,
102    Expert,
103    Extreme,
104}
105
106/// Resource requirements
107#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct ResourceRequirements {
109    /// Memory requirement (MB)
110    pub memory_mb: usize,
111
112    /// CPU cores required
113    pub cpu_cores: usize,
114
115    /// GPU memory (MB, if needed)
116    pub gpu_memory_mb: Option<usize>,
117
118    /// Maximum runtime (seconds)
119    pub max_runtime_seconds: u64,
120
121    /// Storage requirement (MB)
122    pub storage_mb: usize,
123}
124
125/// Activation functions
126#[derive(Debug, Clone, PartialEq, Eq)]
127pub enum ActivationFunction {
128    ReLU,
129    Sigmoid,
130    Tanh,
131    GELU,
132    Swish,
133    ELU,
134    LeakyReLU,
135}
136
137/// Cache eviction policies
138#[derive(Debug, Clone, PartialEq, Eq)]
139pub enum CacheEvictionPolicy {
140    LRU,
141    LFU,
142    FIFO,
143    Random,
144}
145
146/// Predictor model types
147#[derive(Debug, Clone, PartialEq, Eq)]
148pub enum PredictorModelType {
149    LinearRegression,
150    RandomForest,
151    GradientBoosting,
152    NeuralNetwork,
153    GaussianProcess,
154    SupportVectorMachine,
155    Ensemble,
156}
157
158/// Statistical test types
159#[derive(Debug, Clone, PartialEq, Eq)]
160pub enum StatisticalTestType {
161    TTest,
162    WilcoxonSignedRank,
163    MannWhitneyU,
164    KruskalWallis,
165    FriedmanTest,
166    ChiSquare,
167    FisherExact,
168    ANOVA,
169}
170
171/// Analysis methods
172#[derive(Debug, Clone, PartialEq, Eq)]
173pub enum AnalysisMethod {
174    DescriptiveStatistics,
175    CorrelationAnalysis,
176    RegressionAnalysis,
177    ClusterAnalysis,
178    FactorAnalysis,
179    PrincipalComponentAnalysis,
180    SurvivalAnalysis,
181}
182
183/// Multiple comparison correction methods
184#[derive(Debug, Clone, PartialEq, Eq)]
185pub enum MultipleComparisonCorrection {
186    None,
187    Bonferroni,
188    HolmBonferroni,
189    BenjaminiHochberg,
190    BenjaminiYekutieli,
191    Sidak,
192}
193
194/// Performance ranking
195#[derive(Debug, Clone)]
196pub struct PerformanceRanking {
197    /// Overall rank
198    pub overall_rank: usize,
199
200    /// Category ranks
201    pub category_ranks: HashMap<BenchmarkType, usize>,
202
203    /// Percentile scores
204    pub percentile_scores: HashMap<BenchmarkType, f64>,
205
206    /// Relative performance
207    pub relative_performance: f64,
208}
209
210/// Statistical summary
211#[derive(Debug, Clone)]
212pub struct StatisticalSummary<T: Float + Debug + Send + Sync + 'static> {
213    /// Mean score
214    pub mean: T,
215
216    /// Median score
217    pub median: T,
218
219    /// Standard deviation
220    pub std_dev: T,
221
222    /// Minimum score
223    pub min: T,
224
225    /// Maximum score
226    pub max: T,
227
228    /// Quartiles
229    pub quartiles: (T, T, T),
230
231    /// Confidence intervals
232    pub confidence_intervals: HashMap<String, (T, T)>,
233}
234
235/// Resource usage summary
236#[derive(Debug, Clone)]
237pub struct ResourceSummary<T: Float + Debug + Send + Sync + 'static> {
238    /// Total memory usage
239    pub total_memory_mb: T,
240
241    /// Peak memory usage
242    pub peak_memory_mb: T,
243
244    /// Total CPU time
245    pub total_cpu_seconds: T,
246
247    /// Total GPU time
248    pub total_gpu_seconds: T,
249
250    /// Energy consumption
251    pub energy_consumption_kwh: T,
252
253    /// Cost estimate
254    pub cost_estimate_usd: T,
255}