scirs2_integrate/analysis/ml_prediction/forecasting.rs
1//! Time Series Forecasting for Bifurcation Prediction
2//!
3//! This module contains structures and configurations for time series forecasting,
4//! anomaly detection, and trend analysis in dynamical systems.
5
6/// Time series forecasting for bifurcation prediction
7#[derive(Debug, Clone)]
8pub struct TimeSeriesBifurcationForecaster {
9 /// Base time series model
10 pub base_model: TimeSeriesModel,
11 /// Bifurcation detection threshold
12 pub detection_threshold: f64,
13 /// Forecast horizon
14 pub forecast_horizon: usize,
15 /// Multi-step forecasting strategy
16 pub multistep_strategy: MultiStepStrategy,
17 /// Anomaly detection configuration
18 pub anomaly_detection: AnomalyDetectionConfig,
19 /// Trend analysis configuration
20 pub trend_analysis: TrendAnalysisConfig,
21}
22
23/// Time series model types
24#[derive(Debug, Clone)]
25pub enum TimeSeriesModel {
26 /// LSTM-based model
27 LSTM {
28 hidden_size: usize,
29 num_layers: usize,
30 bidirectional: bool,
31 },
32 /// GRU-based model
33 GRU {
34 hidden_size: usize,
35 num_layers: usize,
36 bidirectional: bool,
37 },
38 /// Transformer-based model
39 Transformer {
40 d_model: usize,
41 nhead: usize,
42 num_layers: usize,
43 positional_encoding: bool,
44 },
45 /// Conv1D-based model
46 Conv1D {
47 channels: Vec<usize>,
48 kernel_sizes: Vec<usize>,
49 dilations: Vec<usize>,
50 },
51 /// Hybrid CNN-RNN model
52 HybridCNNRNN {
53 cnn_channels: Vec<usize>,
54 rnn_hidden_size: usize,
55 rnn_layers: usize,
56 },
57}
58
59/// Multi-step forecasting strategies
60#[derive(Debug, Clone, Copy)]
61pub enum MultiStepStrategy {
62 /// Recursive one-step ahead
63 Recursive,
64 /// Direct multi-step
65 Direct,
66 /// Multi-input multi-output
67 MIMO,
68 /// Ensemble of strategies
69 Ensemble,
70}
71
72/// Anomaly detection configuration
73#[derive(Debug, Clone)]
74pub struct AnomalyDetectionConfig {
75 /// Anomaly detection method
76 pub method: AnomalyDetectionMethod,
77 /// Threshold for anomaly detection
78 pub threshold: f64,
79 /// Window size for anomaly detection
80 pub window_size: usize,
81 /// Minimum anomaly duration
82 pub min_duration: usize,
83}
84
85/// Anomaly detection methods
86#[derive(Debug, Clone, Copy)]
87pub enum AnomalyDetectionMethod {
88 /// Statistical outlier detection
89 StatisticalOutlier,
90 /// Isolation forest
91 IsolationForest,
92 /// One-class SVM
93 OneClassSVM,
94 /// Autoencoder-based detection
95 Autoencoder,
96 /// LSTM-based prediction error
97 LSTMPredictionError,
98}
99
100/// Trend analysis configuration
101#[derive(Debug, Clone)]
102pub struct TrendAnalysisConfig {
103 /// Trend detection method
104 pub method: TrendDetectionMethod,
105 /// Trend analysis window size
106 pub window_size: usize,
107 /// Significance level for trend tests
108 pub significance_level: f64,
109 /// Change point detection
110 pub change_point_detection: bool,
111}
112
113/// Trend detection methods
114#[derive(Debug, Clone, Copy)]
115pub enum TrendDetectionMethod {
116 /// Linear regression slope
117 LinearRegression,
118 /// Mann-Kendall test
119 MannKendall,
120 /// Sen's slope estimator
121 SensSlope,
122 /// Seasonal Mann-Kendall
123 SeasonalMannKendall,
124 /// CUSUM test
125 CUSUM,
126}