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 examples.grid.fitnessDistributed;
11:
12: import org.jgap.*;
13: import org.jgap.distr.grid.*;
14:
15: /**
16: * Just compute the fitness value in our example, where only fitness value
17: * computation is dirtibuted.
18: *
19: * @author Klaus Meffert
20: * @since 3.2
21: */
22: public class MyWorkerReturnStrategy implements IWorkerReturnStrategy {
23: /** String containing the CVS revision. Read out via reflection!*/
24: private final static String CVS_REVISION = "$Revision: 1.1 $";
25:
26: /**
27: * Computes fitness of one chromosome and returns it.
28: *
29: * @param a_req JGAPRequest
30: * @param a_genotype Genotype
31: * @return JGAPResult
32: * @throws Exception in case of any error
33: *
34: * @author Klaus Meffert
35: * @since 3.2
36: */
37: public JGAPResult assembleResult(JGAPRequest a_req,
38: Genotype a_genotype) throws Exception {
39: IChromosome chrom = a_req.getPopulation().getChromosome(0);
40: // Do the actual fitness computation here.
41: // ---------------------------------------
42: chrom.getFitnessValue();
43: Population pop = new Population(a_req.getConfiguration(), chrom);
44: MyResult result = new MyResult(a_req.getSessionName(), a_req
45: .getRID(), pop, 1);
46: return result;
47: }
48: }
|