diff --git a/src/htm/algorithms/Connections.cpp b/src/htm/algorithms/Connections.cpp index cf36716743..0be71f4bf8 100644 --- a/src/htm/algorithms/Connections.cpp +++ b/src/htm/algorithms/Connections.cpp @@ -53,6 +53,8 @@ void Connections::initialize(CellIdx numCells, Permanence connectedThreshold, bo connectedThreshold_ = connectedThreshold - htm::Epsilon; iteration_ = 0; + rng_ = Random(42); //TODO set the seed + nextEventToken_ = 0; timeseries_ = timeseries; @@ -476,7 +478,8 @@ void Connections::adaptSegment(const Segment segment, } //balance synapses using competition on dendrite - synapseCompetition(segment, 4, 10); //FIXME derive these numbers + if(rng_.getReal64() < 0.01f) //1% chance //TODO set the probability? + synapseCompetition(segment, 4, 10); //FIXME derive these numbers //destroy segment if it has too few synapses left -> will never be able to connect again if(pruneZeroSynapses and synapses.size() < connectedThreshold_) { diff --git a/src/htm/algorithms/Connections.hpp b/src/htm/algorithms/Connections.hpp index 746d0edc5a..df9bc1cb67 100644 --- a/src/htm/algorithms/Connections.hpp +++ b/src/htm/algorithms/Connections.hpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace htm { @@ -715,9 +716,9 @@ class Connections : public Serializable std::vector destroyedSynapses_; Permanence connectedThreshold_; //TODO make const UInt32 iteration_ = 0; + Random rng_; // Extra bookkeeping for faster computing of segment activity. - struct identity { constexpr size_t operator()( const CellIdx t ) const noexcept { return t; }; }; //TODO in c++20 use std::identity std::unordered_map, identity> potentialSynapsesForPresynapticCell_;