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.evolutionDistributed;
11:
12: import java.util.*;
13: import org.jgap.*;
14: import org.jgap.distr.grid.*;
15:
16: /**
17: * Return the top 10 results to the client.
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.2 $";
25:
26: /**
27: * Determines the top 10 chromosomes and returns them.
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: List top = a_genotype.getPopulation()
40: .determineFittestChromosomes(10);
41: Population pop = new Population(a_req.getConfiguration());
42: for (int i = 0; i < top.size(); i++) {
43: pop.addChromosome((IChromosome) top.get(i));
44: }
45: JGAPResult result = new JGAPResult(a_req.getSessionName(),
46: a_req.getRID(), pop, 1);
47: return result;
48: }
49: }
|