public virtual ComputeCycle Compute(Connections cnx, int[] activeColumns, string sequenceLabel, bool learn) { // Append last cycle's predictiveCells to *predicTEDCells* trace ((IndicesTrace)getTraceMap().Get("predictedCells")).items.Add( new HashSet <int>(Connections.AsCellIndexes(cnx.GetPredictiveCells()))); ComputeCycle cycle = getMonitor().Compute(cnx, activeColumns, learn); // Append this cycle's predictiveCells to *predicTIVECells* trace ((IndicesTrace)getTraceMap().Get("predictiveCells")).items.Add( new HashSet <int>(Connections.AsCellIndexes(cnx.GetPredictiveCells()))); ((IndicesTrace)getTraceMap().Get("activeCells")).items.Add( new HashSet <int>(Connections.AsCellIndexes(cnx.GetActiveCells()))); ((IndicesTrace)getTraceMap().Get("activeColumns")).items.Add(new HashSet <int>(activeColumns)); //Arrays.stream(activeColumns).boxed().collect(Collectors.toCollection(HashSet::new))); ((CountsTrace)getTraceMap().Get("numSegments")).items.Add(cnx.GetNumSegments()); ((CountsTrace)getTraceMap().Get("numSynapses")).items.Add((int)(cnx.GetNumSynapses() ^ (cnx.GetNumSynapses() >> 32))); ((StringsTrace)getTraceMap().Get("sequenceLabels")).items.Add(sequenceLabel); ((BoolsTrace)getTraceMap().Get("resets")).items.Add(resetActive()); setResetActive(false); setTransitionTracesStale(true); return(cycle); }
public void TestAsCellIndexes() { TemporalMemory tm = new TemporalMemory(); Connections cn = new Connections(); cn.SetColumnDimensions(new[] { 64, 64 }); cn.SetCellsPerColumn(4); TemporalMemory.Init(cn); int[] expectedIndexes = { 0, 3, 4, 16383 }; HashSet <Cell> cells = cn.GetCellSet(expectedIndexes); List <int> cellIdxList = Connections.AsCellIndexes(cells); // Unordered test of equality HashSet <int> cellIdxSet = new HashSet <int>(cellIdxList); HashSet <int> expectedIdxSet = new HashSet <int>(expectedIndexes); Assert.IsTrue(Arrays.AreEqual(cellIdxSet, expectedIdxSet)); }