1 10 package org.jgap.distr.grid; 11 12 import org.jgap.*; 13 14 20 public class DefaultGenotypeInitializer 21 implements IGenotypeInitializer, Comparable { 22 23 private final static String CVS_REVISION = "$Revision: 1.3 $"; 24 25 37 public Genotype setupGenotype(JGAPRequest a_req, Population a_initialPop) 38 throws Exception { 39 Genotype gen; 40 Configuration conf = a_req.getConfiguration(); 41 if (a_initialPop == null || a_initialPop.size() < 1) { 42 gen = Genotype.randomInitialGenotype(conf); 43 } 44 else { 45 gen = new Genotype(conf, a_initialPop); 48 int size = conf.getPopulationSize() - a_initialPop.size(); 51 gen.fillPopulation(size); 52 } 53 return gen; 54 } 55 56 63 public int compareTo(Object a_other) { 64 if (a_other.getClass().equals(getClass())) { 65 return 0; 66 } 67 else { 68 return getClass().getName().compareTo(a_other.getClass().getName()); 69 } 70 } 71 } 72 | Popular Tags |