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 org.jgap.distr.grid.*;
13: import org.jgap.*;
14:
15: /**
16: * Initializes the genotype on behalf of the workers in a grid.
17: *
18: * @author Klaus Meffert
19: * @since 3.2
20: */
21: public class MyGenotypeInitializer implements IGenotypeInitializer {
22: /** String containing the CVS revision. Read out via reflection!*/
23: private final static String CVS_REVISION = "$Revision: 1.2 $";
24:
25: public Genotype setupGenotype(JGAPRequest a_req,
26: Population a_initialPop) throws Exception {
27: Configuration conf = a_req.getConfiguration();
28: Population pop;
29: if (a_initialPop == null) {
30: pop = new Population(conf);
31: } else {
32: pop = a_initialPop;
33: }
34: int size = conf.getPopulationSize() - pop.size();
35: Genotype result = new Genotype(conf, pop);
36: result.fillPopulation(size);
37: return result;
38: }
39: }
|