1 10 package org.jgap.impl; 11 12 import org.jgap.*; 13 14 20 public class DefaultMutationRateCalculator 21 extends BaseRateCalculator { 22 23 private final static String CVS_REVISION = "$Revision: 1.16 $"; 24 25 32 public DefaultMutationRateCalculator(Configuration a_config) 33 throws InvalidConfigurationException { 34 super(a_config); 35 } 36 37 45 public int calculateCurrentRate() { 46 int size = getConfiguration().getChromosomeSize(); 47 if (size < 1) { 48 size = 1; 49 } 50 return size; 51 } 52 53 65 public boolean toBePermutated(IChromosome a_chrom, int a_geneIndex) { 66 RandomGenerator generator = getConfiguration().getRandomGenerator(); 67 return (generator.nextInt(calculateCurrentRate()) == 0); 68 } 69 } 70 | Popular Tags |