KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > distr > grid > RequestSplitStrategy


1 package org.jgap.distr.grid;
2
3 import org.jgap.event.*;
4 import org.jgap.*;
5 import org.jgap.impl.*;
6
7 public class RequestSplitStrategy {
8
9   private Configuration m_config;
10
11   public RequestSplitStrategy(Configuration a_config) {
12     m_config = a_config;
13   }
14
15   public Configuration getConfiguration() {
16     return m_config;
17   }
18   /**
19    * Creates single requests to be sent to workers.
20    *
21    * @return single requests to be computed by workers
22    * @throws Exception
23    *
24    * @author Klaus Meffert
25    * @since 3.01
26    */

27   public JGAPRequest[] split(JGAPRequest a_request)
28       throws Exception JavaDoc {
29     final int runs = 20;
30     JGAPRequest[] result = new JGAPRequest[runs];
31     for (int i = 0; i < runs; i++) {
32       /**@todo support cloning of m_config*/
33       Configuration config = new DefaultConfiguration("config " + i, i + "");
34       config.setEventManager(new EventManager());
35       config.setPopulationSize(getConfiguration().getPopulationSize());
36       config.setFitnessFunction(getConfiguration().getFitnessFunction());
37 // IChromosome sample = new Chromosome(config, new BooleanGene(config), 16);
38
IChromosome sample = (IChromosome)getConfiguration().getSampleChromosome().clone();
39       config.setSampleChromosome(sample);
40       result[i] = (JGAPRequest)a_request.newInstance("JGAP-Grid Request " + i,i);
41 // new MyRequest("JGAP-Grid Request " + i, i, config);
42
}
43     return result;
44   }
45
46 }
47
Popular Tags