KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > gp > impl > DeltaGPFitnessEvaluator


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

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
22     implements IGPFitnessEvaluator {
23   /** String containing the CVS revision. Read out via reflection!*/
24   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
25
26   /**
27    * Compares the first given fitness value with the second and returns true
28    * if the first one is smaller 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 3.1
35    */

36   public boolean isFitter(final double a_fitness_value1,
37                           final double a_fitness_value2) {
38     if (!Double.isNaN(a_fitness_value1) &&
39         !Double.isNaN(a_fitness_value2)) {
40       return a_fitness_value1 < a_fitness_value2;
41     }
42     else if (Double.isNaN(a_fitness_value1)) {
43       return false;
44     }
45     return true;
46   }
47
48   /*
49    * @author Klaus Meffert
50    * @since 3.1
51    */

52   public boolean isFitter(IGPProgram a_prog1, IGPProgram a_prog2) {
53     return isFitter(a_prog1.getFitnessValue(), a_prog2.getFitnessValue());
54   }
55
56   /*
57    * @author Klaus Meffert
58    * @since 3.1
59    */

60   public boolean equals(Object JavaDoc a_object) {
61     DeltaGPFitnessEvaluator eval = (DeltaGPFitnessEvaluator) a_object;
62     return true;
63   }
64
65   /*
66    * @author Klaus Meffert
67    * @since 3.1
68    */

69   public int compareTo(Object JavaDoc a_object) {
70     DeltaGPFitnessEvaluator eval = (DeltaGPFitnessEvaluator) a_object;
71     return 0;
72   }
73 }
74
Popular Tags