Package com.trimga

Examples of com.trimga.Chromosome


  }
 
  public static void randomlyAddGeneratedChromosomes(List<Chromosome> chromosomeList) {
    int numChromosomesToAdd = (int)Math.round(Math.sqrt(chromosomeList.size()) * Math.random() * Math.random());
    if(chromosomeList.size() > 0) {
      Chromosome aChromosome = chromosomeList.get(0);
      for(int i=0; i<numChromosomesToAdd; i++) {
        try {
          int insertionIndex = (int) (Math.random() * chromosomeList.size());
          chromosomeList.add(insertionIndex, aChromosome.generateRandomChromosome());
        } catch(RuntimeException ignore) {}
      }
    }
  }
View Full Code Here


  public static void randomlyMutateChromosomes(List<Chromosome> chromosomeList) {
    int numChromosomesToMutate = (int)Math.round(Math.sqrt(chromosomeList.size()) * Math.random() * Math.random());
      for(int i=0; i<numChromosomesToMutate; i++) {
        try {
          int randomIndex = (int)Math.round(chromosomeList.size() * Math.random());
        Chromosome chromosomeToMutate = chromosomeList.remove(randomIndex);
          chromosomeList.add(chromosomeToMutate.generateMutation());
        } catch(RuntimeException ignore) {}
      }
  }
View Full Code Here

TOP

Related Classes of com.trimga.Chromosome

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.