Пример #1
0
 //Constructor
 /// <summary>
 /// Creates an initialized instance
 /// </summary>
 /// <param name="sourceNeuron">Source neuron</param>
 /// <param name="dynamicsCfg">Dynamics configuration</param>
 public LinearEfficacy(INeuron sourceNeuron, LinearDynamicsSettings dynamicsCfg)
 {
     _sourceNeuronOutputData = sourceNeuron.OutputData;
     _dynamicsCfg            = (LinearDynamicsSettings)dynamicsCfg.DeepClone();
     Reset();
     return;
 }
Пример #2
0
 //Constructor
 /// <summary>
 /// Creates an initialized instance.
 /// </summary>
 /// <param name="presynapticNeuron">The presynaptic neuron.</param>
 /// <param name="dynamicsCfg">The configuration of the dynamics.</param>
 public NonlinearEfficacy(INeuron presynapticNeuron, NonlinearDynamicsSettings dynamicsCfg)
 {
     _presynapticNeuronOutputData = presynapticNeuron.OutputData;
     _dynamicsCfg = (NonlinearDynamicsSettings)dynamicsCfg.DeepClone();
     Reset();
     return;
 }
Пример #3
0
 //Constructor
 /// <summary>
 /// Creates initialized instance
 /// </summary>
 /// <param name="sourceNeuron">Source neuron</param>
 /// <param name="targetNeuron">Target neuron</param>
 /// <param name="role">Synapse role</param>
 /// <param name="synapseCfg">Synapse general configuration</param>
 /// <param name="rand">Random object</param>
 public Synapse(INeuron sourceNeuron,
                INeuron targetNeuron,
                SynRole role,
                SynapseSettings synapseCfg,
                Random rand
                )
 {
     //Neurons to be connected
     SourceNeuron = sourceNeuron;
     TargetNeuron = targetNeuron;
     //Synapse role
     Role = role;
     //Euclidean distance
     Distance = EuclideanDistance.Compute(SourceNeuron.Location.ReservoirCoordinates, TargetNeuron.Location.ReservoirCoordinates);
     //The rest
     _efficacyComputer = null;
     if (TargetNeuron.TypeOfActivation == ActivationType.Spiking)
     {
         //Spiking target
         if (Role == SynRole.Input)
         {
             DelayMethod = synapseCfg.SpikingTargetCfg.InputSynCfg.DelayMethod;
             _maxDelay   = synapseCfg.SpikingTargetCfg.InputSynCfg.MaxDelay;
             if (SourceNeuron.TypeOfActivation == ActivationType.Analog)
             {
                 //Analog source
                 Weight = rand.NextDouble(synapseCfg.SpikingTargetCfg.InputSynCfg.AnalogSourceCfg.WeightCfg);
             }
             else
             {
                 //Spiking source
                 Weight            = rand.NextDouble(synapseCfg.SpikingTargetCfg.InputSynCfg.SpikingSourceCfg.WeightCfg);
                 _efficacyComputer = PlasticityCommon.GetEfficacyComputer(SourceNeuron,
                                                                          synapseCfg.SpikingTargetCfg.InputSynCfg.SpikingSourceCfg.PlasticityCfg.DynamicsCfg
                                                                          );
             }
         }
         else if (Role == SynRole.Excitatory)
         {
             DelayMethod = synapseCfg.SpikingTargetCfg.ExcitatorySynCfg.DelayMethod;
             _maxDelay   = synapseCfg.SpikingTargetCfg.ExcitatorySynCfg.MaxDelay;
             if (SourceNeuron.TypeOfActivation == ActivationType.Analog)
             {
                 //Analog source
                 Weight = rand.NextDouble(synapseCfg.SpikingTargetCfg.ExcitatorySynCfg.AnalogSourceCfg.WeightCfg);
             }
             else
             {
                 //Spiking source
                 Weight            = rand.NextDouble(synapseCfg.SpikingTargetCfg.ExcitatorySynCfg.SpikingSourceCfg.WeightCfg);
                 _efficacyComputer = PlasticityCommon.GetEfficacyComputer(SourceNeuron,
                                                                          synapseCfg.SpikingTargetCfg.ExcitatorySynCfg.SpikingSourceCfg.PlasticityCfg.DynamicsCfg
                                                                          );
             }
         }
         else if (Role == SynRole.Inhibitory)
         {
             DelayMethod = synapseCfg.SpikingTargetCfg.InhibitorySynCfg.DelayMethod;
             _maxDelay   = synapseCfg.SpikingTargetCfg.InhibitorySynCfg.MaxDelay;
             if (SourceNeuron.TypeOfActivation == ActivationType.Analog)
             {
                 //Analog source
                 Weight = -rand.NextDouble(synapseCfg.SpikingTargetCfg.InhibitorySynCfg.AnalogSourceCfg.WeightCfg);
             }
             else
             {
                 //Spiking source
                 Weight            = -rand.NextDouble(synapseCfg.SpikingTargetCfg.InhibitorySynCfg.SpikingSourceCfg.WeightCfg);
                 _efficacyComputer = PlasticityCommon.GetEfficacyComputer(SourceNeuron,
                                                                          synapseCfg.SpikingTargetCfg.InhibitorySynCfg.SpikingSourceCfg.PlasticityCfg.DynamicsCfg
                                                                          );
             }
         }
         else
         {
             throw new ArgumentException($"Invalid synapse role {role}.", "role");
         }
     }
     else
     {
         //Analog target
         if (Role == SynRole.Input)
         {
             DelayMethod = synapseCfg.AnalogTargetCfg.InputSynCfg.DelayMethod;
             _maxDelay   = synapseCfg.AnalogTargetCfg.InputSynCfg.MaxDelay;
             if (SourceNeuron.TypeOfActivation == ActivationType.Analog)
             {
                 //Analog source
                 Weight = rand.NextDouble(synapseCfg.AnalogTargetCfg.InputSynCfg.AnalogSourceCfg.WeightCfg);
             }
             else
             {
                 //Spiking source
                 Weight            = rand.NextSign() * rand.NextDouble(synapseCfg.AnalogTargetCfg.InputSynCfg.SpikingSourceCfg.WeightCfg);
                 _efficacyComputer = PlasticityCommon.GetEfficacyComputer(SourceNeuron,
                                                                          synapseCfg.AnalogTargetCfg.InputSynCfg.SpikingSourceCfg.PlasticityCfg.DynamicsCfg
                                                                          );
             }
         }
         else if (Role == SynRole.Indifferent)
         {
             DelayMethod = synapseCfg.AnalogTargetCfg.IndifferentSynCfg.DelayMethod;
             _maxDelay   = synapseCfg.AnalogTargetCfg.IndifferentSynCfg.MaxDelay;
             if (SourceNeuron.TypeOfActivation == ActivationType.Analog)
             {
                 //Analog source
                 Weight = rand.NextSign() * rand.NextDouble(synapseCfg.AnalogTargetCfg.IndifferentSynCfg.AnalogSourceCfg.WeightCfg);
             }
             else
             {
                 //Spiking source
                 Weight            = rand.NextSign() * rand.NextDouble(synapseCfg.AnalogTargetCfg.IndifferentSynCfg.SpikingSourceCfg.WeightCfg);
                 _efficacyComputer = PlasticityCommon.GetEfficacyComputer(SourceNeuron,
                                                                          synapseCfg.AnalogTargetCfg.IndifferentSynCfg.SpikingSourceCfg.PlasticityCfg.DynamicsCfg
                                                                          );
             }
         }
         else
         {
             throw new ArgumentException($"Invalid synapse role {role}.", "role");
         }
     }
     //Source neuron - output data and signal index
     _sourceNeuronOutputData = SourceNeuron.OutputData;
     _analogSourceSignal     = TargetNeuron.TypeOfActivation == ActivationType.Analog;
     //Efficacy statistics
     EfficacyStat = new BasicStat(false);
     Reset(true);
     return;
 }