/// <summary>
        /// getActiveSegment(c, i, t, state)
        /// For the given column c cell i, return a segment index such that
        /// segmentActive(s,t, state) is true. If multiple segments are active, sequence
        /// segments are given preference. Otherwise, segments with most activity
        /// are given preference.
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="time"> </param>
        /// <returns></returns>
        public HtmSegment GetActiveSegment(HtmCellState cell, HtmTime time)
        {
            var activeSegments = cell.Segments.Where(segment => segment.IsActive(time)).ToList();

            if (activeSegments.Count == 0)
            {
                return(null);
            }

            activeSegments.Sort(new SegmentComparer(time));
            return(activeSegments.First());
        }
Example #2
0
        public HtmCellState GetByTime(HtmTime time)
        {
            switch (time)
            {
            case HtmTime.Before:
                return(_oldState);

            case HtmTime.Now:
                return(_newState);

            default:
                throw new ArgumentOutOfRangeException("time");
            }
        }
Example #3
0
        /// <summary>
        /// This routine returns true if the number of
        /// connected synapses on segment s that are active due to the given state at
        /// time t is greater than activationThreshold. The parameter state can be
        /// activeState, or learnState.
        /// </summary>
        public bool IsActive(HtmTime time)
        {
            var ammountConnected = Synapses.Count(synapse => synapse.IsConnected() && synapse.InputCell.GetByTime(time).ActiveState);

            return(ammountConnected > _activationTreshold);
        }
 public SegmentComparer(HtmTime time)
 {
     _time = time;
 }