Beispiel #1
0
        public virtual Neuron Clone(InnovationNumber otherInnov)
        {
            var clone = Clone();

            clone.InnovationNb = otherInnov;
            return(clone);
        }
Beispiel #2
0
        public override Neuron Clone(InnovationNumber otherInnov)
        {
            var clone = this.Clone();

            clone.InnovationNb = otherInnov;
            return(clone);
        }
Beispiel #3
0
 public MemoryNeuron(
     InnovationNumber innovationNumber,
     InnovationNumber targetNeuron
     ) : base(innovationNumber, null)
 {
     this.TargetNeuron = targetNeuron;
 }
Beispiel #4
0
 /// <summary>
 /// Check equality between two <see cref="NodeGene"/>s
 /// </summary>
 /// <param name="obj">Another <see cref="NodeGene"/></param>
 /// <returns>a boolean that confirm or not the equality</returns>
 public override bool Equals(object obj)
 {
     if (obj is NodeGene n)
     {
         return(InnovationNumber.Equals(n.InnovationNumber));
     }
     return(false);
 }
        /// <summary>
        /// Gets the hash code.
        /// </summary>
        /// <returns>Returns the hash code.</returns>
        public override int GetHashCode()
        {
            int hashCode = 1721005899;

            hashCode = hashCode * -1521134295 + InId.GetHashCode();
            hashCode = hashCode * -1521134295 + OutId.GetHashCode();
            hashCode = hashCode * -1521134295 + InnovationNumber.GetHashCode();
            hashCode = hashCode * -1521134295 + Weight.GetHashCode();
            hashCode = hashCode * -1521134295 + Enabled.GetHashCode();
            return(hashCode);
        }
Beispiel #6
0
        public Synapse AddConnection(
            InnovationNumber startNeuron,
            InnovationNumber endNeuron,
            WeightInitializer weightInitializer = null)
        {
            if (!Neurons.ContainsKey(startNeuron) || !Neurons.ContainsKey(endNeuron))
            {
                throw new Exception("The given neurons are not yer registered.");
            }

            var innov  = synapseInnovNbTracker.GetHystoricalMark(startNeuron, endNeuron);
            var result = new Synapse(innov, 0, startNeuron, endNeuron)
            {
                weightConstraints = this.WeightConstraints
            };

            if (weightInitializer == null)
            {
                weightInitializer = defaultWeightInitializer;
            }
            Synapses.Add(result, weightInitializer);

            return(result);
        }
Beispiel #7
0
 public IEnumerable <NeuralGene> GetGenesOutOfNeuron(InnovationNumber target)
 {
     return(NeuralGenes.Where(x => x.Synapse.incoming == target));
 }
Beispiel #8
0
 public IEnumerable <NeuralGene> GetGenesToNeuron(InnovationNumber target)
 {
     return(NeuralGenes.Where(x => x.Synapse.outgoing == target));
 }