01: /*
02: * This file is part of JGAP.
03: *
04: * JGAP offers a dual license model containing the LGPL as well as the MPL.
05: *
06: * For licensing information please see the file license.txt included with JGAP
07: * or have a look at the top of class org.jgap.Chromosome which representatively
08: * includes the JGAP license policy applicable for any file delivered with JGAP.
09: */
10: package org.jgap.impl;
11:
12: import org.jgap.*;
13:
14: /**
15: * Default implementation of a dynamic CrossoverRateCalculator.
16: *
17: * @author Chris Knowles
18: * @since 2.0
19: */
20: public class DefaultCrossoverRateCalculator extends BaseRateCalculator {
21: /** String containing the CVS revision. Read out via reflection!*/
22: private static final String CVS_REVISION = "$Revision: 1.9 $";
23:
24: /**
25: *
26: * @param a_config the configuration to use
27: * @throws InvalidConfigurationException
28: */
29: public DefaultCrossoverRateCalculator(Configuration a_config)
30: throws InvalidConfigurationException {
31: super (a_config);
32: }
33:
34: /**
35: * Calculates the dynamic crossover rate. This is chosen to be the chromosome
36: * size. As the chromosome gets larger we assume that it is less likely to
37: * reproduce.
38: *
39: * @return calculated divisor of crossover rate
40: *
41: * @author Chris Knowles
42: * @since 2.0
43: */
44: public int calculateCurrentRate() {
45: int size = getConfiguration().getChromosomeSize();
46: if (size < 1) {
47: size = 1;
48: }
49: return size;
50: }
51:
52: /**
53: * Determines whether crossover is to be carried out for a given population.
54: *
55: * @param a_chrom ignored
56: * @param a_geneIndex ignored
57: *
58: * @return true: the DefaultCrossoverRateCalculator always returns a finite
59: * rate
60: *
61: * @author Chris Knowles
62: * @since 2.0
63: */
64: public boolean toBePermutated(IChromosome a_chrom, int a_geneIndex) {
65: return true;
66: }
67: }
|