TemporalMemory cluster_storage START START n0 0| create new empty storages START->n0 END END loop1start START1 for each winning column winningColumn winning column loop1start->winningColumn n1 1| find the cells in this column that are in a 'predicting state' loop1start->n1 loop1end END1 for each winning column loop1end->loop1start not finished loop2start START2 for each learning segment loop1end->loop2start finished loop3start START3 for each synapse loop2start->loop3start learningSegment learning segment loop2start->learningSegment loop2end END2 for each learning segment loop2end->loop2start not finished loopColumnsStart START for each column loop2end->loopColumnsStart finished learningSynapse learning synapse loop3start->learningSynapse ifActiveSynapse is this synapse active? loop3start->ifActiveSynapse loop3end END3 for each synapse loop3end->loop2end finished loop3end->loop3start not finished loopCellsStart START for each cell in this column loopColumnsStart->loopCellsStart column column loopColumnsStart->column loopColumnsEnd END for each column loopColumnsEnd->loopColumnsStart not finished n12 12| replace old STORAGES with new ones loopColumnsEnd->n12 finished loopSegmentsStart START for each segment in this cell loopCellsStart->loopSegmentsStart cell cell loopCellsStart->cell loopCellsEnd END for each cell in this column loopCellsEnd->loopColumnsEnd finished loopCellsEnd->loopCellsStart not finished segment segment loopSegmentsStart->segment n10 10| count how many connected synapses correspond to currently active cells loopSegmentsStart->n10 loopSegmentsEnd END for each segment in this cell loopSegmentsEnd->loopCellsEnd finished loopSegmentsEnd->loopSegmentsStart not finished ifFound search a segment that has some active synapses at any permanence level. FOUND? winningColumn->ifFound winningColumn->n1 n3 3| 'activate' (burst) all cells in the column winningColumn->n3 predictingCells predicting cells if1 is the number of cells > 0? predictingCells->if1 n2 2| 'activate' these cells predictingCells->n2 n4 4| get a list of learning segments from these cells and add these to learning segments list predictingCells->n4 learningSegments learning segments learningSegments->loop2start learningSegment->loop3start learningSynapse->ifActiveSynapse column->loopCellsStart cell->loopSegmentsStart n11 11| mark this cell as predicting cell->n11 segment->n10 SDRresult SDR result output RETURN SDR result SDRresult->output newActiveCellsStorage STORAGE new active cells newActiveCellsStorage->n10 newActiveCellsStorage->n12 n13 13| create output SDR prediction newActiveCellsStorage->n13 newPredictingCellsStorage STORAGE new predicting cells newPredictingCellsStorage->n12 oldActiveCellsStorage STORAGE old active cells n7 7| grow new synapses to active cells in t-1 oldActiveCellsStorage->n7 oldPredictingCellsStorage STORAGE old predicting cells oldPredictingCellsStorage->n1 if1->n2 yes if1->n3 no ifLearning1 learning? ifLearning1->loop1end no ifLearning1->n4 yes ifLearning2 learning? ifLearning2->loop1end no ifLearning2->ifFound yes n5 5| INCREASE synapse permanence ifActiveSynapse->n5 yes n6 6| DECREASE synapse permanence ifActiveSynapse->n6 no n8 8| add this segment to the learning segments ifFound->n8 yes n9 9| grow a new segment on the cell with the fewest segments, breaking ties randomly ifFound->n9 no ifExceedThreshold threshold exceeded? ifExceedThreshold->loopSegmentsEnd no ifExceedThreshold->n11 yes input INPUT winning columns SDR input->START output->END n0->loop1start n0->newActiveCellsStorage n0->newPredictingCellsStorage n1->predictingCells n1->if1 n2->newActiveCellsStorage n2->ifLearning1 n3->newActiveCellsStorage n3->ifLearning2 n4->loop1end n4->learningSegments n5->n7 n6->n7 n7->loop3end n8->loop1end n8->learningSegments n9->n8 n10->ifExceedThreshold n11->loopCellsEnd exit segments loop n11->newPredictingCellsStorage n12->oldActiveCellsStorage n12->oldPredictingCellsStorage n12->n13 n13->SDRresult n13->output