示例#1
0
        public override bool Equals(object obj)
        {
            if (!this.GetType().Equals(obj.GetType()))
            {
                return(false);
            }

            if (base.Equals(obj))
            {
                return(true);
            }

            if (this.GetHashCode() != obj.GetHashCode())
            {
                return(false);
            }

            TestEvolvable other = (TestEvolvable)obj;

            if (this.chromosomes.Length != other.chromosomes.Length)
            {
                return(false);
            }
            for (int i = 0; i < this.chromosomes.Length; i++)
            {
                if (chromosomes[i] != other.chromosomes[i])
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        public IEvolvable Clone()
        {
            TestEvolvable result = new TestEvolvable(random, chromosomes.Length);

            for (int i = 0; i < chromosomes.Length; i++)
            {
                result.chromosomes[i] = this.chromosomes[i];
            }
            return(result);
        }
示例#3
0
        public IEvolvable Crossover(IEvolvable other)
        {
            TestEvolvable result = new TestEvolvable(random, chromosomes.Length);

            for (int i = 0; i < chromosomes.Length; i++)
            {
                result.chromosomes[i] = random.NextDouble() < 0.5 ? this.chromosomes[i] : (other as TestEvolvable).chromosomes[i];
            }
            return(result);
        }