public Hashtable getResults() { Hashtable hs = new Hashtable(); hs.put("runningTime", getRunTime()); hs.put("numberOfGenerations", getGenerations()); hs.put("intermediates", ga.getGenerationResults()); hs.put("finalWord", getEvolvedWord()); return hs; }
public void runEvolution(String target) { int ch; CHROMOSOME_SIZE = target.length(); Individual<BitwiseChromosome> sample = new Individual<BitwiseChromosome>( new BitwiseChromosome(CHROMOSOME_SIZE, new AlphaCoding())); Population<BitwiseChromosome> pop = new Population<BitwiseChromosome>(sample, POPULATION_SIZE); AbstractStage<BitwiseChromosome> selection = new TournamentSelector<BitwiseChromosome>(3); AbstractStage<BitwiseChromosome> crossover = new OnePointCrossover<BitwiseChromosome>(0.8); AbstractStage<BitwiseChromosome> mutation = new SimpleMutator<BitwiseChromosome>(0.2); ga = new WordGA(pop, GENERATION_LIMIT); ga.setTargetWord(target); ga.addStage(selection); ga.addStage(crossover); ga.addStage(mutation); ga.addGenerationEventListener(ga); ga.setBiggerIsBetter(true); ga.evolve(); }
public String getEvolvedWord() { return ga.getEvolvedWord(); }
public int getGenerations() { return ga.getRunGenerations(); }
public long getRunTime() { return ga.getRunTime(); }