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:
54
include/fces/evolution.hpp
Normal file
54
include/fces/evolution.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file evolution.hpp
|
||||
* @brief EvolutionManager — orchestrates population dynamics.
|
||||
*
|
||||
* Port of: packages/fces/core/evolution_manager.py
|
||||
*/
|
||||
|
||||
#include "population.hpp"
|
||||
|
||||
namespace fces {
|
||||
|
||||
/**
|
||||
* EvolutionManager — controls the scheduling of evolutionary operations.
|
||||
*
|
||||
* Responsibilities:
|
||||
* - Controller rotation (sticky selection with interval)
|
||||
* - Population dynamics (auto-sizing, lockdown)
|
||||
* - Triggering evolution at intervals
|
||||
*/
|
||||
class EvolutionManager {
|
||||
public:
|
||||
explicit EvolutionManager(
|
||||
Population& population,
|
||||
int selection_interval = 50,
|
||||
bool auto_population = false,
|
||||
bool direct_construction = false
|
||||
);
|
||||
|
||||
/// Get the currently active controller
|
||||
FuzzyController& get_active_controller();
|
||||
|
||||
/// Update population dynamics based on current training state
|
||||
void update_population_dynamics(
|
||||
float loss_velocity,
|
||||
float ema_loss,
|
||||
int step_counter,
|
||||
int total_steps
|
||||
);
|
||||
|
||||
/// Steps the active controller has been in control
|
||||
int steps_active = 0;
|
||||
|
||||
/// Selection interval (how long a controller stays active)
|
||||
int selection_interval;
|
||||
|
||||
private:
|
||||
Population& population_;
|
||||
bool auto_population_;
|
||||
bool direct_construction_;
|
||||
};
|
||||
|
||||
} // namespace fces
|
||||
Reference in New Issue
Block a user