/// <summary> /// Creates a new collumn with specified number of cells and a single proximal dendtrite segment. /// </summary> /// <param name="numCells">Number of cells in the column.</param> /// <param name="colIndx">Column index.</param> /// <param name="synapsePermConnected">Permanence threshold value to declare synapse as connected.</param> /// <param name="numInputs">Number of input neorn cells.</param> public Column(int numCells, int colIndx, double synapsePermConnected, int numInputs) { this.Index = colIndx; this.hashcode = GetHashCode(); Cells = new Cell[numCells]; for (int i = 0; i < numCells; i++) { Cells[i] = new Cell(this.Index, i, this.GetNumCellsPerColumn(), this.CellId, CellActivity.ActiveCell); } // We keep tracking of this column only this.connectedInputCounter = new SparseBinaryMatrix(new int[] { 1, numInputs }); ProximalDendrite = new ProximalDendrite(colIndx, synapsePermConnected, numInputs); this.ConnectedInputCounterMatrix = new SparseBinaryMatrix(new int[] { 1, numInputs }); }
public static ProximalDendrite Deserialize(StreamReader sr) { ProximalDendrite proximal = new ProximalDendrite(); HtmSerializer2 ser = new HtmSerializer2(); while (sr.Peek() >= 0) { string data = sr.ReadLine(); if (data == String.Empty || data == ser.ReadBegin(nameof(ProximalDendrite)) || (data.ToCharArray()[0] == HtmSerializer2.ElementsDelimiter && data.ToCharArray()[1] == HtmSerializer2.ParameterDelimiter) || data.ToCharArray()[1] == HtmSerializer2.ParameterDelimiter) { continue; } else if (data == ser.ReadBegin(nameof(Pool))) { proximal.RFPool = Pool.Deserialize(sr); } //else if (data == ser.ReadBegin(nameof(Integer))) //{ // proximal.boxedIndex = Integer.Deserialize(sr); //} else if (data == ser.ReadBegin(nameof(Synapse))) { proximal.Synapses.Add(Synapse.Deserialize(sr)); } else if (data == ser.ReadEnd(nameof(ProximalDendrite))) { break; } else { string[] str = data.Split(HtmSerializer2.ParameterDelimiter); for (int i = 0; i < str.Length; i++) { switch (i) { case 0: { proximal.SegmentIndex = ser.ReadIntValue(str[i]); break; } case 1: { proximal.SynapsePermConnected = ser.ReadDoubleValue(str[i]); break; } case 2: { proximal.NumInputs = ser.ReadIntValue(str[i]); break; } default: { break; } } } } } return(proximal); }
public bool Equals(ProximalDendrite obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } ProximalDendrite other = (ProximalDendrite)obj; if (RFPool == null) { if (other.RFPool != null) { return(false); } } else if (!RFPool.Equals(other.RFPool)) { return(false); } if (SegmentIndex != other.SegmentIndex) { return(false); } if (Synapses == null) { if (other.Synapses != null) { return(false); } } else if (!Synapses.SequenceEqual(other.Synapses)) { return(false); } //if (boxedIndex == null) //{ // if (other.boxedIndex != null) // return false; //} //else if (!boxedIndex.Equals(other.boxedIndex)) // return false; if (SynapsePermConnected != other.SynapsePermConnected) { return(false); } if (NumInputs != other.NumInputs) { return(false); } return(true); }
public static Column Deserialize(StreamReader sr) { Column column = new Column(); HtmSerializer2 ser = new HtmSerializer2(); while (!sr.EndOfStream) { string data = sr.ReadLine(); if (data == String.Empty || data == ser.ReadBegin(nameof(Column)) || data == ser.ValueDelimiter) { continue; } else if (data == ser.ReadBegin(nameof(SparseBinaryMatrix))) { column.connectedInputCounter = SparseBinaryMatrix.Deserialize(sr); } //else if (data == ser.ReadBegin(nameof(SparseBinaryMatrix))) //{ // column.ConnectedInputCounterMatrix = SparseBinaryMatrix.Deserialize(sr); //} else if (data == ser.ReadBegin(nameof(ProximalDendrite))) { column.ProximalDendrite = ProximalDendrite.Deserialize(sr); } else if (data == ser.ReadBegin(nameof(Cell))) { column.Cells = ser.DeserializeCellArray(data, sr); } else if (data == ser.ReadEnd(nameof(Column))) { break; } else { string[] str = data.Split(HtmSerializer2.ParameterDelimiter); for (int i = 0; i < str.Length; i++) { switch (i) { case 0: { column.CellId = ser.ReadIntValue(str[i]); break; } case 1: { column.Index = ser.ReadIntValue(str[i]); break; } default: { break; } } } } } return(column); }
public bool Equals(Column obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (connectedInputCounter == null) { if (obj.connectedInputCounter != null) { return(false); } } else if (!connectedInputCounter.Equals(obj.connectedInputCounter)) { return(false); } if (ConnectedInputCounterMatrix == null) { if (obj.ConnectedInputCounterMatrix != null) { return(false); } } else if (!ConnectedInputCounterMatrix.Equals(obj.ConnectedInputCounterMatrix)) { return(false); } if (ProximalDendrite == null) { if (obj.ProximalDendrite != null) { return(false); } } else if (!ProximalDendrite.Equals(obj.ProximalDendrite)) { return(false); } if (obj.Cells != null && Cells != null) { if (!obj.Cells.SequenceEqual(Cells)) { return(false); } } if (Index != obj.Index) { return(false); } if (CellId != obj.CellId) { return(false); } return(true); }