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 licencing 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: import java.util.Random;
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 extends FitnessFunction {
23:
24: /** String containing the CVS revision. Read out via reflection!*/
25: private final static String CVS_REVISION = "$Revision: 1.6 $";
26:
27: private Random m_rand;
28:
29: public RandomFitnessFunction() {
30: m_rand = new Random();
31: }
32:
33: /**
34: * @param a_chrom ignored: the Chromosome to evaluate
35: * @return randomized fitness value
36: * @since 2.0 (until 1.1: return type int)
37: */
38: public double evaluate(IChromosome a_chrom) {
39: double result;
40: result = m_rand.nextDouble();
41: return result;
42: }
43: }
|