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.gp.impl;
11:
12: import org.jgap.gp.*;
13:
14: /**
15: * Fitness evaluator taking input as delta values. Thus a lower value is seen
16: * as fitter.
17: *
18: * @author Klaus Meffert
19: * @since 3.1
20: */
21: public class DeltaGPFitnessEvaluator implements IGPFitnessEvaluator {
22: /** String containing the CVS revision. Read out via reflection!*/
23: private final static String CVS_REVISION = "$Revision: 1.2 $";
24:
25: /**
26: * Compares the first given fitness value with the second and returns true
27: * if the first one is smaller than the second one. Otherwise returns false
28: * @param a_fitness_value1 first fitness value
29: * @param a_fitness_value2 second fitness value
30: * @return true: first fitness value greater than second
31: *
32: * @author Klaus Meffert
33: * @since 3.1
34: */
35: public boolean isFitter(final double a_fitness_value1,
36: final double a_fitness_value2) {
37: if (!Double.isNaN(a_fitness_value1)
38: && !Double.isNaN(a_fitness_value2)) {
39: return a_fitness_value1 < a_fitness_value2;
40: } else if (Double.isNaN(a_fitness_value1)) {
41: return false;
42: }
43: return true;
44: }
45:
46: /*
47: * @author Klaus Meffert
48: * @since 3.1
49: */
50: public boolean isFitter(IGPProgram a_prog1, IGPProgram a_prog2) {
51: return isFitter(a_prog1.getFitnessValue(), a_prog2
52: .getFitnessValue());
53: }
54:
55: /*
56: * @author Klaus Meffert
57: * @since 3.1
58: */
59: public boolean equals(Object a_object) {
60: DeltaGPFitnessEvaluator eval = (DeltaGPFitnessEvaluator) a_object;
61: return true;
62: }
63:
64: /*
65: * @author Klaus Meffert
66: * @since 3.1
67: */
68: public int compareTo(Object a_object) {
69: DeltaGPFitnessEvaluator eval = (DeltaGPFitnessEvaluator) a_object;
70: return 0;
71: }
72: }
|