Esempio n. 1
0
        /// <summary>
        /// Determins if two axons share similar topology. That is, if the axons have
        /// the same inputs and outputs. It dose not consider the weight of the axons.
        /// </summary>
        /// <param name="other">An axon to compare</param>
        /// <returns>True if the axons share the same topology</returns>
        public bool IsSimilar(AxonComp other)
        {
            if (this.Input != other.Input)
            {
                return(false);
            }
            if (this.Output != other.Output)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public double Compare(NetworkComp genome)
        {
            //calculates the maximum number of nurons and axons
            //this is nessary incase the genomes have diffrent numbers
            int nmax = Math.Min(this.NuronCount, genome.NuronCount);
            int amax = Math.Min(this.AxonCount, genome.AxonCount);

            //used in computing the distance
            int    disjoint = 0;
            double wbar     = 0.0;

            for (int i = 0; i < amax; i++)
            {
                AxonComp source = this.axons[i];
                AxonComp target = genome.axons[i];

                if (source.IsSimilar(target))
                {
                    //computes the distance between the weights
                    double w1 = source.Weight;
                    double w2 = target.Weight;

                    wbar += Math.Abs(w1 - w2);
                }
                else
                {
                    //counts the number of disjoint axons
                    disjoint++;
                }
            }

            //computes the number of matches
            double match = amax - disjoint;

            //couputes the distance for specisation
            double dist = (C0 * disjoint) / (double)amax;

            dist += C1 * (wbar / (double)match);

            return(dist);
        }
Esempio n. 3
0
        public void Crossover(VRandom rng, NetworkComp genome)
        {
            //determins the rate of crossover
            double rate = rng.RandDouble(0.25, 0.75);

            //calculates the maximum number of nurons and axons
            //this is nessary incase the genomes have diffrent numbers
            int nmax = Math.Min(this.NuronCount, genome.NuronCount);
            int amax = Math.Min(this.AxonCount, genome.AxonCount);

            for (int i = 0; i < nmax; i++)
            {
                if (rng.NextDouble() > rate)
                {
                    continue;
                }

                NuronComp copy = genome.nurons[i];
                nurons[i].Funciton = copy.Funciton;
            }

            for (int i = 0; i < amax; i++)
            {
                if (rng.NextDouble() > rate)
                {
                    continue;
                }

                //NOTE: should we copy the entier axon or just the weight?

                AxonComp copy = genome.axons[i];
                axons[i].Weight  = copy.Weight;
                axons[i].Enabled = copy.Enabled;

                axons[i].Input  = copy.Input;
                axons[i].Output = copy.Output;
            }

            throw new NotImplementedException();
        }