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); }
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); }
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); }