Beispiel #1
0
 //Methods
 /// <summary>
 /// Resets synapse.
 /// </summary>
 /// <param name="statistics">Specifies whether to reset also internal statistics</param>
 public void Reset(bool statistics)
 {
     _facilitation = _restingEfficacy;
     _depression   = 1d;
     if (statistics)
     {
         EfficacyStat.Reset();
     }
     return;
 }
Beispiel #2
0
 //Constructor
 /// <summary>
 /// Creates initialized instance
 /// </summary>
 /// <param name="sourceNeuron">Source neuron</param>
 /// <param name="targetNeuron">Target neuron</param>
 /// <param name="weight">Synapse weight</param>
 public StaticSynapse(INeuron sourceNeuron,
                      INeuron targetNeuron,
                      double weight
                      )
     : base(sourceNeuron, targetNeuron, weight)
 {
     _signalQueue = null;
     //Initialize efficacy stat to constant 1 (static synapse has always efficacy 1)
     EfficacyStat.AddSampleValue(1d);
     return;
 }
Beispiel #3
0
 //Methods
 /// <summary>
 /// Resets synapse.
 /// </summary>
 /// <param name="statistics">Specifies whether to reset also internal statistics</param>
 public void Reset(bool statistics)
 {
     //Reset queue if it is instantiated
     _signalQueue?.Reset();
     if (statistics)
     {
         EfficacyStat.Reset();
         EfficacyStat.AddSampleValue(1d);
     }
     return;
 }
Beispiel #4
0
 //Methods
 /// <summary>
 /// Resets synapse.
 /// </summary>
 /// <param name="statistics">Specifies whether to reset also internal statistics</param>
 public void Reset(bool statistics)
 {
     //Reset queue if it is instantiated
     _signalQueue?.Reset();
     _efficacyUtilization       = _restingEfficacy;
     _efficacyAvailableFraction = 1;
     if (statistics)
     {
         EfficacyStat.Reset();
     }
     return;
 }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Returns signal to be delivered to target neuron.
        /// Note that this function has to be invoked only once per reservoir cycle !!!
        /// </summary>
        /// <param name="collectStatistics">Specifies whether to update internal statistics</param>
        public double GetSignal(bool collectStatistics)
        {
            //Source neuron signal
            double sourceSignal = SourceNeuron.OutputSignal;

            if (_signalQueue == null)
            {
                //No delay of the signal - do not use queue
                if (sourceSignal == 0)
                {
                    //No source signal so simply return 0
                    return(0);
                }
                else
                {
                    //Compute synapse efficacy
                    double efficacy = GetPreSynapticEfficacy() * GetPostSynapticEfficacy();
                    //Update statistics if necessary
                    if (collectStatistics)
                    {
                        EfficacyStat.AddSampleValue(efficacy);
                    }
                    //Return resulting signal
                    return(sourceSignal * Weight * efficacy);
                }
            }
            else
            {
                //Signal to be delayed so use queue
                if (sourceSignal == 0)
                {
                    //No signal adjustments
                    Signal sigObj = _signalQueue.GetElementOnEnqueuePosition();
                    if (sigObj != null)
                    {
                        sigObj._weightedSignal      = 0d;
                        sigObj._preSynapticEfficacy = 1d;
                    }
                    else
                    {
                        sigObj = new Signal {
                            _weightedSignal = 0d, _preSynapticEfficacy = 1d
                        };
                    }
                    _signalQueue.Enqueue(sigObj);
                }
                else
                {
                    //Signal to be delayed
                    Signal sigObj = _signalQueue.GetElementOnEnqueuePosition();
                    //Compute pre-synaptic efficacy
                    double preSynapticEfficacy = GetPreSynapticEfficacy();
                    //Compute constantly weighted signal and pre-synaptic part of efficacy and put them into the queue simulating the signal traveling
                    if (sigObj != null)
                    {
                        sigObj._weightedSignal      = ((SourceNeuron.OutputSignal + _add) / _div) * Weight;
                        sigObj._preSynapticEfficacy = preSynapticEfficacy;
                    }
                    else
                    {
                        sigObj = new Signal {
                            _weightedSignal = ((SourceNeuron.OutputSignal + _add) / _div) * Weight, _preSynapticEfficacy = preSynapticEfficacy
                        };
                    }
                    _signalQueue.Enqueue(sigObj);
                }
                //Is there delayed signal to be delivered?
                if (_signalQueue.Full)
                {
                    //Queue is full, so synapse is ready to deliver delayed signal
                    //Pick up source signal and pre-synaptic part of efficacy
                    Signal sigObj = _signalQueue.Dequeue();
                    if (sigObj._weightedSignal == 0)
                    {
                        //No need of signal adjustment
                        return(0);
                    }
                    else
                    {
                        //Compute resulting efficacy
                        double efficacy = sigObj._preSynapticEfficacy * GetPostSynapticEfficacy();
                        //Update statistics if required
                        if (collectStatistics)
                        {
                            EfficacyStat.AddSampleValue(efficacy);
                        }
                        //Deliver the resulting signal
                        return(sigObj._weightedSignal * efficacy);
                    }
                }
                else
                {
                    //No signal to be delivered, signal is still "on the road"
                    return(0);
                }
            }
        }