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;
11:
12: import org.jgap.util.*;
13:
14: /**
15: * A default implementation of a fitness evaluator. This implementation is
16: * straight forward: a higher fitness value is seen as fitter.
17: *
18: * @author Klaus Meffert
19: * @since 1.1
20: */
21: public class DefaultFitnessEvaluator implements FitnessEvaluator,
22: ICloneable, Comparable {
23: /** String containing the CVS revision. Read out via reflection!*/
24: private final static String CVS_REVISION = "$Revision: 1.13 $";
25:
26: /**
27: * Compares the first given fitness value with the second and returns true
28: * if the first one is greater than the second one. Otherwise returns false
29: * @param a_fitness_value1 first fitness value
30: * @param a_fitness_value2 second fitness value
31: * @return true: first fitness value greater than second
32: *
33: * @author Klaus Meffert
34: * @since 2.0 (until 1.1: input types int)
35: */
36: public boolean isFitter(final double a_fitness_value1,
37: final double a_fitness_value2) {
38: return a_fitness_value1 > a_fitness_value2;
39: }
40:
41: public boolean isFitter(IChromosome a_chrom1, IChromosome a_chrom2) {
42: return isFitter(a_chrom1.getFitnessValue(), a_chrom2
43: .getFitnessValue());
44: }
45:
46: /**
47: * @return deep clone of this instance
48: *
49: * @author Klaus Meffert
50: * @since 3.2
51: */
52: public Object clone() {
53: return new DefaultFitnessEvaluator();
54: }
55:
56: /**
57: * @param a_other sic
58: * @return as always
59: *
60: * @author Klaus Meffert
61: * @since 3.2
62: */
63: public int compareTo(Object a_other) {
64: if (a_other.getClass().equals(getClass())) {
65: return 0;
66: } else {
67: return getClass().getName().compareTo(
68: a_other.getClass().getName());
69: }
70: }
71: }
|