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.homedns.dade.jcgrid.*;
13: import org.homedns.dade.jcgrid.worker.*;
14: import org.jgap.distr.grid.*;
15:
16: /**
17: * Listener called on worker events.
18: *
19: * @author Klaus Meffert
20: * @since 3.01
21: */
22: public class MyWorkerFeedback implements GridWorkerFeedback {
23: /** String containing the CVS revision. Read out via reflection!*/
24: private final static String CVS_REVISION = "$Revision: 1.3 $";
25:
26: private String m_sessionName;
27:
28: /**
29: * Called when listener is started.
30: */
31: public void start() {
32: }
33:
34: public void beginWorkingFor(String a_sessionName, WorkRequest req) {
35: m_sessionName = a_sessionName;
36: System.out.println("Begin work for request " + req.getRID()
37: + ", session " + m_sessionName);
38: }
39:
40: public void endWorkingFor(WorkResult res) {
41: System.out.println("Result computed (req " + res.getRID()
42: + ", session " + m_sessionName + "): "
43: + ((JGAPResult) res).getPopulation().getChromosome(0));
44: }
45:
46: /**
47: * Called when listener is stopped.
48: */
49: public void stop() {
50: System.out
51: .println("MyWorkerFeedback: listener stopped (session "
52: + m_sessionName + ")");
53: }
54: }
|