/** * <p> * Creates and returns a newly created {@link Synapse} with the specified * source cell, permanence, and index. * </p><p> * IMPORTANT: <b>This method is only called for Proximal Synapses.</b> For ProximalDendrites, * there are many synapses within a pool, and in that case, the index * specifies the synapse's sequence order within the pool object, and may * be referenced by that index. * </p> * @param c the connections state of the temporal memory * @param sourceCell the source cell which will activate the new {@code Synapse} * @param pool the new {@link Synapse}'s pool for bound variables. * @param index the new {@link Synapse}'s index. * @param inputIndex the index of this {@link Synapse}'s input (source object); be it a Cell or InputVector bit. * * @return the newly created {@code Synapse} * @see Connections#createSynapse(DistalDendrite, Cell, double) */ public virtual Synapse CreateSynapse(Connections c, List <Synapse> syns, Cell sourceCell, Pool pool, int index, int inputIndex) { Synapse s = new Synapse(c, sourceCell, this, pool, index, inputIndex); syns.Add(s); return(s); }
/** * Destroys any references this {@code Pool} maintains on behalf * of the specified {@link Synapse} * * @param synapse */ public void DestroySynapse(Synapse synapse) { _synapseConnections.Remove(synapse.GetInputIndex()); _synapsesBySourceIndex.Remove(synapse.GetInputIndex()); if (synapse.GetSegment() is DistalDendrite) { Destroy(); } }
/** * Updates this {@code Pool}'s store of permanences for the specified {@link Synapse} * @param c the connections memory * @param s the synapse who's permanence is recorded * @param permanence the permanence value to record */ public void UpdatePool(Connections c, Synapse s, double permanence) { int inputIndex = s.GetInputIndex(); //Synapse foundSynapse; lock (_synapsesBySourceIndex) { if (!_synapsesBySourceIndex.ContainsKey(inputIndex)) // TryGetValue(inputIndex, out foundSynapse) { _synapsesBySourceIndex.Add(inputIndex, s); } } lock (_synapseConnections) { if (permanence >= c.GetSynPermConnected()) { _synapseConnections.Add(inputIndex); } else { if (_synapseConnections.Count > inputIndex) { _synapseConnections.RemoveAt(inputIndex); } } } //int inputIndex = s.GetInputIndex(); //if (_synapsesBySourceIndex.Get(inputIndex) == null) //{ // _synapsesBySourceIndex[inputIndex] = s; //} //if (permanence >= c.GetSynPermConnected()) //{ // _synapseConnections.Add(inputIndex); //} //else //{ // _synapseConnections.Remove(inputIndex); //} }
/** * Sets the specified permanence value for the specified {@link Synapse} * @param s * @param permanence */ public void SetPermanence(Connections c, Synapse s, double permanence) { s.SetPermanence(c, permanence); }
/** * Returns the permanence value for the {@link Synapse} specified. * * @param s the Synapse * @return the permanence */ public double GetPermanence(Synapse s) { return(_synapsesBySourceIndex.Get(s.GetInputIndex()).GetPermanence()); }