Exemplo n.º 1
0
        public void ImprintGene(SpNeuronGene gene)
        {
            Name   = gene.Name;
            GeneID = gene.ID;

            Bias = gene.Threshold.Value;
            ExcitationDecayRate = MaxExcitationDecayRate * gene.ExcitationDecayRate.Value;

            AbsoluteRefactoryPeriod = (int)Math.Round(gene.AbsoluteRefactoryPeriod.Value * MaxAbsouluteRefactoryPeriod, 0);
            RelativeRefactoryPeriod = (int)Math.Round(gene.RelativeRefactoryPeriod.Value * MaxRelativeRefactoryPeriod, 0);
        }
Exemplo n.º 2
0
        public override Gene Clone()
        {
            var gene = new SpNeuronGene(Name, GeneHeritage);

            gene.Threshold               = Threshold;
            gene.ExcitationDecayRate     = ExcitationDecayRate;
            gene.AbsoluteRefactoryPeriod = AbsoluteRefactoryPeriod;
            gene.RelativeRefactoryPeriod = RelativeRefactoryPeriod;
            gene.RefactoryPenalty        = RefactoryPenalty;

            foreach (var connection in Connections)
            {
                gene.Connections.Add(connection.Clone());
            }

            return(gene);
        }
Exemplo n.º 3
0
        public SpNeuronGene GetRandomNeuronGene(string name)
        {
            var gene = new SpNeuronGene(name);

            gene.Threshold.Value =
                Pseudo.Random.NextDouble(gene.Threshold.Min, gene.Threshold.Max);
            gene.ExcitationDecayRate.Value =
                Pseudo.Random.NextDouble(gene.ExcitationDecayRate.Min, gene.ExcitationDecayRate.Max);
            gene.AbsoluteRefactoryPeriod.Value =
                Pseudo.Random.NextDouble(gene.AbsoluteRefactoryPeriod.Min, gene.AbsoluteRefactoryPeriod.Max);
            gene.RelativeRefactoryPeriod.Value =
                Pseudo.Random.NextDouble(gene.RelativeRefactoryPeriod.Min, gene.RelativeRefactoryPeriod.Max);
            gene.RefactoryPenalty.Value =
                Pseudo.Random.NextDouble(gene.RefactoryPenalty.Min, gene.RefactoryPenalty.Max);

            return(gene);
        }
Exemplo n.º 4
0
        public void ConnectRandomly(SpNeuronGene gene, bool isInputNeuron)
        {
            int connectionCount;

            if (isInputNeuron)
            {
                connectionCount = HiddenNeuronGenes.Count;
            }
            else
            {
                connectionCount = HiddenNeuronGenes.Count + OutputNeuronGenes.Count;
            }

            int connectionAmount = Pseudo.Random.Next(connectionCount);

            for (int i = 0; i < connectionAmount; i++)
            {
                int  targetIndex;
                bool unique;

                do
                {
                    targetIndex = Pseudo.Random.Next(connectionCount);

                    unique = true;
                    foreach (SpConnectionGene connectionGene in gene.Connections)
                    {
                        if (connectionGene.Target == targetIndex)
                        {
                            unique = false;
                        }
                    }
                } while (!unique);

                if (targetIndex < HiddenNeuronGenes.Count)
                {
                    gene.Connections.Add(GetRandomConnection(targetIndex, false));
                }
                else
                {
                    gene.Connections.Add(GetRandomConnection(targetIndex - HiddenNeuronGenes.Count, true));
                }
            }
        }