|
| 1 | +# Real-Time Adaptive Signal Processing Algorithm Evolution |
| 2 | + |
| 3 | +This example demonstrates how to use OpenEvolve to automatically discover and optimize real-time signal processing algorithms for non-stationary time series data. The challenge involves developing algorithms that can filter volatile signals while preserving important dynamics and minimizing computational latency. |
| 4 | + |
| 5 | +## Problem Overview |
| 6 | + |
| 7 | +### The Challenge |
| 8 | +We need to develop a real-time signal processing algorithm that can: |
| 9 | + |
| 10 | +1. **Filter noise** from volatile, non-stationary time series data |
| 11 | +2. **Preserve genuine signal dynamics** and trend changes |
| 12 | +3. **Minimize spurious directional reversals** caused by noise |
| 13 | +4. **Achieve near-zero phase delay** for real-time applications |
| 14 | +5. **Operate efficiently** within computational constraints |
| 15 | + |
| 16 | +### Input Signal Characteristics |
| 17 | +- **Type**: Univariate time series (1D array of real-valued samples) |
| 18 | +- **Properties**: |
| 19 | + - Non-linear dynamics |
| 20 | + - Non-stationary statistical properties |
| 21 | + - Aperiodic (non-seasonal) behavior |
| 22 | + - High frequency variability and volatility |
| 23 | + - Rapidly changing spectral characteristics |
| 24 | + |
| 25 | +### Technical Constraints |
| 26 | +- **Causal Processing**: Must use finite-length sliding window |
| 27 | +- **Fixed Latency**: Output length = Input length - Window size |
| 28 | +- **Real-time Capability**: Process samples as they arrive |
| 29 | +- **Memory Efficiency**: Bounded memory usage |
| 30 | + |
| 31 | +## Multi-Objective Optimization Framework |
| 32 | + |
| 33 | +The algorithm performance is evaluated using a composite metric based on the research specification: |
| 34 | + |
| 35 | +### Optimization Function |
| 36 | +``` |
| 37 | +J(θ) = α₁·S(θ) + α₂·L_recent(θ) + α₃·L_avg(θ) + α₄·R(θ) |
| 38 | +``` |
| 39 | + |
| 40 | +Where: |
| 41 | +- **S(θ)**: **Slope Change Penalty** - Counts directional reversals in the filtered signal |
| 42 | +- **L_recent(θ)**: **Instantaneous Lag Error** - |y[n] - x[n]| at the most recent sample |
| 43 | +- **L_avg(θ)**: **Average Tracking Error** - Mean absolute error over the processing window |
| 44 | +- **R(θ)**: **False Reversal Penalty** - Trend changes that don't match the clean signal |
| 45 | +- **Weighting coefficients**: α₁=0.3, α₂=α₃=0.2, α₄=0.3 |
| 46 | + |
| 47 | +### Additional Evaluation Metrics |
| 48 | +- **Signal Fidelity**: Correlation with ground truth clean signal |
| 49 | +- **Noise Reduction**: Improvement in signal-to-noise ratio |
| 50 | +- **Computational Efficiency**: Processing time per sample |
| 51 | +- **Robustness**: Consistent performance across diverse signal types |
| 52 | + |
| 53 | +## Proposed Algorithmic Approaches |
| 54 | + |
| 55 | +The initial implementation provides a foundation that evolution can improve upon: |
| 56 | + |
| 57 | +### 1. Baseline Implementation |
| 58 | +- Simple moving average filter |
| 59 | +- Weighted exponential moving average |
| 60 | + |
| 61 | +### 2. Potential Advanced Techniques (for evolution to discover) |
| 62 | +- **Adaptive Filtering**: Kalman filters, particle filters, adaptive weights |
| 63 | +- **Multi-Scale Processing**: Wavelet decomposition, empirical mode decomposition |
| 64 | +- **Predictive Enhancement**: Local polynomial fitting, neural network prediction |
| 65 | +- **Trend Detection**: Change point detection, momentum indicators |
| 66 | +- **Hybrid Approaches**: Ensemble methods combining multiple techniques |
| 67 | + |
| 68 | +## File Structure |
| 69 | + |
| 70 | +``` |
| 71 | +signal_processing/ |
| 72 | +├── README.md # This documentation |
| 73 | +├── config.yaml # OpenEvolve configuration |
| 74 | +├── initial_program.py # Initial signal processing implementation |
| 75 | +├── evaluator.py # Multi-objective evaluation system |
| 76 | +├── requirements.txt # Python dependencies |
| 77 | +└── results/ # Generated results (after running) |
| 78 | +``` |
| 79 | + |
| 80 | +## How to Run |
| 81 | + |
| 82 | +### Prerequisites |
| 83 | +1. Install OpenEvolve and its dependencies |
| 84 | +2. Install example-specific requirements: |
| 85 | + ```bash |
| 86 | + pip install -r requirements.txt |
| 87 | + ``` |
| 88 | +3. Set up your LLM API key (e.g., `OPENAI_API_KEY` environment variable) |
| 89 | + |
| 90 | +### Testing the Setup (Recommended) |
| 91 | +First, validate that everything is working correctly: |
| 92 | +```bash |
| 93 | +cd examples/signal_processing |
| 94 | +python test_setup.py |
| 95 | +``` |
| 96 | + |
| 97 | +This will test the initial implementation and evaluator to ensure everything is ready for evolution. |
| 98 | + |
| 99 | +### Running the Evolution |
| 100 | +From the OpenEvolve root directory: |
| 101 | +```bash |
| 102 | +python openevolve-run.py examples/signal_processing/config.yaml |
| 103 | +``` |
| 104 | + |
| 105 | +Or from the signal_processing directory: |
| 106 | +```bash |
| 107 | +python ../../openevolve-run.py config.yaml |
| 108 | +``` |
| 109 | + |
| 110 | +### Monitoring Progress |
| 111 | +The evolution will create an `openevolve_output` directory containing: |
| 112 | +- **Checkpoints**: Saved population states at regular intervals |
| 113 | +- **Logs**: Detailed evolution progress and metrics |
| 114 | +- **Best Programs**: Top-performing algorithm implementations |
| 115 | + |
| 116 | +## Understanding the Results |
| 117 | + |
| 118 | +### Key Metrics to Watch |
| 119 | +1. **Overall Score**: Primary selection metric (higher is better) |
| 120 | +2. **Composite Score**: The main J(θ) optimization function |
| 121 | +3. **Correlation**: How well the filtered signal matches the clean ground truth |
| 122 | +4. **Noise Reduction**: Improvement in signal quality |
| 123 | +5. **Slope Changes**: Number of directional reversals (lower is better) |
| 124 | +6. **Success Rate**: Fraction of test signals processed successfully |
| 125 | + |
| 126 | +### Expected Evolution Patterns |
| 127 | +- **Early iterations**: Basic filtering improvements, parameter tuning |
| 128 | +- **Mid evolution**: Discovery of adaptive techniques, trend preservation |
| 129 | +- **Advanced stages**: Sophisticated multi-scale approaches, ensemble methods |
| 130 | + |
| 131 | +## Test Signal Characteristics |
| 132 | + |
| 133 | +The evaluator uses 5 different synthetic test signals to ensure robustness: |
| 134 | + |
| 135 | +1. **Smooth Sinusoidal**: Basic sinusoid with linear trend |
| 136 | +2. **Multi-Frequency**: Multiple frequency components combined |
| 137 | +3. **Non-Stationary**: Frequency-modulated signal |
| 138 | +4. **Step Changes**: Sudden level changes to test responsiveness |
| 139 | +5. **Random Walk**: Stochastic process with trend |
| 140 | + |
| 141 | +Each signal has different noise levels and lengths to test algorithm adaptability. |
| 142 | + |
| 143 | +## Initial Algorithm Analysis |
| 144 | + |
| 145 | +The starting point includes: |
| 146 | +- **Basic moving average**: Simple but may over-smooth |
| 147 | +- **Weighted moving average**: Emphasizes recent samples |
| 148 | +- **Exponential weighting**: Exponentially decaying weights for trend preservation |
| 149 | + |
| 150 | +This provides a baseline that evolution can significantly improve upon by discovering: |
| 151 | +- Advanced filtering techniques |
| 152 | +- Adaptive parameter adjustment |
| 153 | +- Multi-scale processing |
| 154 | +- Predictive elements |
| 155 | +- Robust trend detection |
| 156 | + |
| 157 | +## Interpreting Evolution Results |
| 158 | + |
| 159 | +### Successful Evolution Indicators |
| 160 | +- **Decreasing slope changes**: Algorithm learns to reduce noise-induced reversals |
| 161 | +- **Improving correlation**: Better preservation of true signal structure |
| 162 | +- **Balanced metrics**: Good performance across all test signals |
| 163 | +- **Stable improvements**: Consistent gains over multiple iterations |
| 164 | + |
| 165 | +### Common Evolution Discoveries |
| 166 | +- **Adaptive window sizing**: Dynamic adjustment based on signal characteristics |
| 167 | +- **Multi-pass filtering**: Combining multiple filtering stages |
| 168 | +- **Outlier detection**: Identifying and handling anomalous samples |
| 169 | +- **Frequency analysis**: Spectral-based filtering decisions |
| 170 | +- **Predictive elements**: Using future sample prediction to reduce lag |
| 171 | + |
| 172 | +## Configuration Options |
| 173 | + |
| 174 | +Key parameters in `config.yaml`: |
| 175 | +- **max_iterations**: Total evolution steps (200 recommended) |
| 176 | +- **population_size**: Number of candidate algorithms (80) |
| 177 | +- **cascade_thresholds**: Quality gates for evaluation stages |
| 178 | +- **system_message**: Guides LLM toward signal processing expertise |
| 179 | + |
| 180 | +## Extending the Example |
| 181 | + |
| 182 | +### Adding New Test Signals |
| 183 | +Modify `generate_test_signals()` in `evaluator.py` to include: |
| 184 | +- Real-world datasets (financial, sensor, biomedical) |
| 185 | +- Domain-specific signal characteristics |
| 186 | +- Different noise models and intensities |
| 187 | + |
| 188 | +### Customizing Evaluation Metrics |
| 189 | +Adjust weights in the composite function or add new metrics: |
| 190 | +- Phase delay measurement |
| 191 | +- Spectral preservation |
| 192 | +- Computational complexity analysis |
| 193 | +- Memory usage optimization |
| 194 | + |
| 195 | +### Advanced Algorithmic Constraints |
| 196 | +Modify the evolution block to explore: |
| 197 | +- Specific filtering architectures |
| 198 | +- Hardware-optimized implementations |
| 199 | +- Online learning capabilities |
| 200 | +- Multi-channel processing |
| 201 | + |
| 202 | +## Research Applications |
| 203 | + |
| 204 | +This framework can be adapted for various domains: |
| 205 | +- **Financial Markets**: High-frequency trading signal processing |
| 206 | +- **Biomedical Engineering**: Real-time biosignal filtering |
| 207 | +- **Sensor Networks**: Environmental monitoring and noise reduction |
| 208 | +- **Control Systems**: Real-time feedback signal conditioning |
| 209 | +- **Communications**: Adaptive signal processing for wireless systems |
| 210 | + |
| 211 | +## Expected Outcomes |
| 212 | + |
| 213 | +After evolution, the best algorithms should demonstrate: |
| 214 | +- **Superior noise reduction** while preserving signal dynamics |
| 215 | +- **Minimal phase delay** approaching real-time performance |
| 216 | +- **Robust performance** across diverse signal types |
| 217 | +- **Computational efficiency** suitable for real-time applications |
| 218 | +- **Adaptive behavior** that adjusts to signal characteristics |
| 219 | + |
| 220 | +The evolved solutions often discover sophisticated combinations of techniques that would be difficult to design manually, showcasing the power of automated algorithm discovery for complex signal processing challenges. |
0 commit comments