KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > impl > RandomFitnessFunction


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.impl;
11
12 import org.jgap.*;
13 import java.util.Random JavaDoc;
14
15 /**
16  * Fitness function returning random values
17  * Only for testing purposes
18  *
19  * @author Klaus Meffert
20  * @since 1.1
21  */

22 public class RandomFitnessFunction
23     extends FitnessFunction {
24
25   /** String containing the CVS revision. Read out via reflection!*/
26   private final static String JavaDoc CVS_REVISION = "$Revision: 1.6 $";
27
28   private Random JavaDoc m_rand;
29
30   public RandomFitnessFunction() {
31     m_rand = new Random JavaDoc();
32   }
33
34   /**
35    * @param a_chrom ignored: the Chromosome to evaluate
36    * @return randomized fitness value
37    * @since 2.0 (until 1.1: return type int)
38    */

39   public double evaluate(IChromosome a_chrom) {
40     double result;
41     result = m_rand.nextDouble();
42     return result;
43   }
44 }
45
Popular Tags