- CMakeLists.txt with libtorch, GoogleTest, GoogleBenchmark, OpenMP, pybind11 - Header files: config, controller, population, fitness, evolution, spectral, oscillation, telemetry, optimizer - Source implementations: controller (full micro-MLP forward pass, mutation, crossover), fitness (Welford's algorithm), oscillation (DFT), spectral (SVD rank), optimizer (sign-SGD stub) - Tests: controller, population, fitness, optimizer (Google Test) - Benchmarks: evolve throughput, optimizer step (Google Benchmark) - Examples: simple optimization, PyTorch/libtorch integration - Python extension: pybind11 bindings with setup.py - README with architecture diagram and build instructions
30 lines
640 B
C++
30 lines
640 B
C++
#pragma once
|
|
|
|
/**
|
|
* @file oscillation.hpp
|
|
* @brief FFT-based oscillation detection (Phase 25).
|
|
*/
|
|
|
|
#include <vector>
|
|
|
|
namespace fces {
|
|
|
|
class OscillationDetector {
|
|
public:
|
|
static constexpr int WINDOW_SIZE = 64;
|
|
static constexpr float POWER_THRESHOLD = 0.5f;
|
|
|
|
void update(float loss);
|
|
bool detect() const;
|
|
float get_score() const;
|
|
float get_variance_50() const;
|
|
void reset();
|
|
|
|
private:
|
|
std::vector<float> loss_history_;
|
|
static std::vector<float> detrend(const std::vector<float>& signal);
|
|
static std::vector<float> compute_power_spectrum(const std::vector<float>& signal);
|
|
};
|
|
|
|
} // namespace fces
|