/// <summary> /// Create a identical Genome with other memory address /// </summary> /// <returns>A copy of genome passed in the parameters</returns> public object Clone() { BinaryGenome newGenome = new BinaryGenome(genes.Count); for (int i = 0; i < genes.Count; i++) { newGenome[i] = genes[i]; } newGenome.fitnessFunction = this.fitnessFunction; return(newGenome); }
/// <summary> /// Compare if the value this genome is equal to other genome /// </summary> /// <param name="obj">The genome to compare with this</param> /// <returns>if the genomes are equal or not</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } BinaryGenome genome = obj as BinaryGenome; if ((System.Object)genome == null) { return(false); } for (int locus = 0; locus != genes.Count; locus++) { if (genes[locus] != genome.genes[locus]) { return(false); } } return(true); }
/// <summary> /// Builder a new genome from other Binary Genome /// </summary> /// <param name="binaryGenome">Binary Genome</param> public BinaryGenome(BinaryGenome binaryGenome) { this.genes = binaryGenome.genes; this.fitnessFunction = binaryGenome.fitnessFunction; }
/// <summary> /// Create a identical Genome with other memory address /// </summary> /// <returns>A copy of genome passed in the parameters</returns> public object Clone() { BinaryGenome newGenome = new BinaryGenome(genes.Count); for (int i = 0; i < genes.Count; i++) newGenome[i] = genes[i]; newGenome.fitnessFunction = this.fitnessFunction; return newGenome; }