/** * @param aChromosome * @return true if chromosome is added, false if chromosome already is a member of this specie */ public boolean add(Chromosome aChromosome) { if (!match(aChromosome)) throw new IllegalArgumentException("chromosome does not match specie: " + aChromosome); if (chromosomes.contains(aChromosome)) return false; aChromosome.setSpecie(this); fittest = null; return chromosomes.add(aChromosome); }
/** * Create new specie from representative. Representative is first member of specie, and all other * members of specie are determined by compatibility with representative. Even if representative * dies from population, a reference is kept here to determine specie membership. * * @param aSpeciationParms * @param aRepresentative */ public Specie(SpeciationParms aSpeciationParms, Chromosome aRepresentative) { representative = aRepresentative; aRepresentative.setSpecie(this); chromosomes.add(aRepresentative); speciationParms = aSpeciationParms; }