/// <summary> /// Returns signal to be delivered to target neuron. /// </summary> /// <param name="collectStatistics">Specifies whether to update internal statistics</param> public double GetSignal(bool collectStatistics) { //Weighted source neuron signal double weightedSignal = SourceNeuron.GetSignal(TargetNeuron.TypeOfActivation) * Weight;; if (_signalQueue == null) { return(weightedSignal); } else { //Signal to be delayed so use queue //Enqueue Signal sigObj = _signalQueue.GetElementOnEnqueuePosition(); if (sigObj != null) { sigObj._weightedSignal = weightedSignal; } else { sigObj = new Signal { _weightedSignal = weightedSignal }; } _signalQueue.Enqueue(sigObj); //Is there delayed signal to be delivered? if (_signalQueue.Full) { //Queue is full, so synapse is ready to deliver delayed signal sigObj = _signalQueue.Dequeue(); return(sigObj._weightedSignal); } else { //No signal to be delivered, signal is still "on the road" return(0); } } }
/// <summary> /// Returns signal to be delivered to target neuron. /// </summary> /// <param name="collectStatistics">Specifies whether to update internal statistics</param> public double GetSignal(bool collectStatistics) { //Source neuron signal double sourceSignal = SourceNeuron.GetSignal(TargetNeuron.TypeOfActivation); if (sourceSignal == 0) { return(0); } else { //Compute synapse efficacy double efficacy = ComputeEfficacy(); //Update statistics if necessary if (collectStatistics) { EfficacyStat.AddSampleValue(efficacy); } //Return resulting signal return(sourceSignal * Weight * efficacy); } }