UInt Segment::computeActivity(const CState &activities, Real permConnected, bool connectedSynapsesOnly) const { { NTA_ASSERT(invariants()); } UInt activity = 0; if (connectedSynapsesOnly) { for (UInt i = 0; i != size(); ++i) if (activities.isSet(_synapses[i].srcCellIdx()) && (_synapses[i].permanence() >= permConnected)) activity++; } else { for (UInt i = 0; i != size(); ++i) if (activities.isSet(_synapses[i].srcCellIdx())) activity++; } return activity; }
bool Segment::isActive(const CState &activities, Real permConnected, UInt activationThreshold) const { { NTA_ASSERT(invariants()); } UInt activity = 0; if (_nConnected < activationThreshold) return false; // TODO: maintain nPermConnected incrementally?? for (UInt i = 0; i != size() && activity < activationThreshold; ++i) if (_synapses[i].permanence() >= permConnected && activities.isSet(_synapses[i].srcCellIdx())) activity++; return activity >= activationThreshold; }