KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > grid > evolutionDistributed > MyGenotypeInitializer


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 examples.grid.evolutionDistributed;
11
12 import org.jgap.distr.grid.*;
13 import org.jgap.*;
14
15 public class MyGenotypeInitializer
16     implements IGenotypeInitializer {
17   /** String containing the CVS revision. Read out via reflection!*/
18   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
19
20   public Genotype setupGenotype(JGAPRequest a_req, Population a_initialPop)
21       throws Exception JavaDoc {
22     Configuration conf = a_req.getConfiguration();
23     Population pop;
24     if (a_initialPop == null) {
25       pop = new Population(conf);
26     }
27     else {
28       pop = a_initialPop;
29     }
30     int size = conf.getPopulationSize() - pop.size();
31     Genotype result = new Genotype(conf, pop);
32     result.fillPopulation(size);
33     return result;
34   }
35 }
36
Popular Tags