cellular encoding

This commit is contained in:
2016-05-18 22:57:06 +02:00
parent 86def08f41
commit 237c7741d2
11 changed files with 1032 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
#include <NeuralNetwork/ConstructiveAlgorithms/CelularEncoding/Cell.h>
#include <NeuralNetwork/ConstructiveAlgorithms/CelularEncoding/CelularEncoding.h>
void NeuralNetworks::ConstructiveAlgorithms::CelularEncoding::Cell::step(CelularEncoding &c) {
if(isAlive()) {
reinterpret_cast<Instruction::Instruction *>(codePtr->instruction.lock().get())->run(*this, c, codePtr->parameters);
}
if(codePtr == nullptr) {
die();
}
}

View File

@@ -0,0 +1,20 @@
#include <NeuralNetwork/ConstructiveAlgorithms/CelularEncoding/CelularEncoding.h>
std::size_t NeuralNetworks::ConstructiveAlgorithms::CelularEncoding::CelularEncoding::step() {
std::size_t activeCellCount = 0;
std::vector<std::size_t> processingOrder(_processingOrder);
for(std::size_t i = 0; i < processingOrder.size(); i++) {
std::size_t cell = processingOrder[i];
if(cells[cell]->isAlive()) {
currentID = cells[cell]->getID();
cells[cell]->step(*this);
activeCellCount++;
} else {
auto iter = std::find(_processingOrder.begin(), _processingOrder.end(), cell);
if(iter != _processingOrder.end()) {
_processingOrder.erase(iter);
}
}
}
return activeCellCount;
}