Exemple #1
0
        public static Synapse Connect(Neuron n1, Neuron n2, float weight, int delay, ILearningRule learningRule)
        {
            Synapse syn = new Synapse(n1, n2, weight, delay, learningRule.GetCopy());

            n1.AddPostSynapse(syn);
            n2.AddPreSynapse(syn);
            return(syn);
        }
Exemple #2
0
 public static void MakeConnection(Group sourceGroup, Group destinationGroup, float weight, int delay,
                                   ConnectionPatternDelegate connectionPattern,
                                   ILearningRule learningRule)
 {
     for (int i = 0; i < sourceGroup.Count; i++)
     {
         for (int j = 0; j < destinationGroup.Count; j++)
         {
             if (connectionPattern(i, j))
             {
                 Synapse syn = new Synapse(sourceGroup[i], destinationGroup[j],
                                           weight, delay, learningRule.GetCopy());
                 sourceGroup[i].AddPostSynapse(syn);
                 destinationGroup[j].AddPreSynapse(syn);
             }
         }
     }
 }
Exemple #3
0
        public static void MakeRandomValueConnection(Group sourceGroup, Group destinationGroup,
                                                     float minWeight, float maxWeight, int minDelay, int maxDelay,
                                                     ConnectionPatternDelegate connectionPattern, ILearningRule learningRule)
        {
            float range = maxWeight - minWeight;

            for (int i = 0; i < sourceGroup.Count; i++)
            {
                for (int j = 0; j < destinationGroup.Count; j++)
                {
                    if (connectionPattern(i, j))
                    {
                        float   randWeight = (float)rand.NextDouble() * range + minWeight;
                        int     randDelay  = rand.Next(minDelay, maxDelay + 1);
                        Synapse syn        = new Synapse(sourceGroup[i], destinationGroup[j],
                                                         randWeight, randDelay, learningRule.GetCopy());
                        sourceGroup[i].AddPostSynapse(syn);
                        destinationGroup[j].AddPreSynapse(syn);
                    }
                }
            }
        }