feat: scaffold FCES-native C++ project with libtorch integration

- 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
This commit is contained in:
AI-anonymous
2026-05-19 16:05:15 +02:00
commit 9bbe253810
32 changed files with 2182 additions and 0 deletions

33
tests/test_fitness.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include <gtest/gtest.h>
#include "fces/fitness.hpp"
using namespace fces;
TEST(RunningStatsTest, BasicUpdate) {
RunningStats stats;
stats.update(1.0f);
stats.update(2.0f);
stats.update(3.0f);
EXPECT_NEAR(stats.get_mean(), 2.0f, 1e-5f);
EXPECT_GT(stats.get_std(), 0.0f);
}
TEST(RunningStatsTest, ZScore) {
RunningStats stats;
for (int i = 0; i < 100; ++i) stats.update(static_cast<float>(i));
float z = stats.z_score(50.0f);
EXPECT_NEAR(z, 0.0f, 0.1f);
}
TEST(FitnessEngineTest, LossSignal) {
FitnessEngine engine;
float sig = engine.calculate_loss_signal(1.0f, 2.0f, "relative");
EXPECT_LT(sig, 0.0f); // Improving
}
TEST(FitnessEngineTest, KZMDamping) {
FitnessEngine engine(0.1f);
float d = engine.compute_kzm_damping(5.0f);
EXPECT_GT(d, 0.0f);
EXPECT_LT(d, 1.0f);
}