Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/Exchanger.java @ 8279

Last change on this file since 8279 was 6152, checked in by bfarka, 14 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 2.8 KB
Line 
1/*
2  Copyright 2006 by Sean Luke
3  Licensed under the Academic Free License version 3.0
4  See the file "LICENSE" for more information
5*/
6
7
8package ec;
9
10/*
11 * Exchanger.java
12 *
13 * Created: Tue Aug 10 21:59:17 1999
14 * By: Sean Luke
15 */
16
17/**
18 * The Exchanger is a singleton object whose job is to (optionally)
19 * perform individual exchanges between subpopulations in the run,
20 * or exchange individuals with other concurrent evolutionary run processes,
21 * using sockets or whatever.  Keep in mind that other processes may go down,
22 * or be started up from checkpoints, etc.
23 *
24 * @author Sean Luke
25 * @version 1.0
26 */
27
28public abstract class Exchanger implements Singleton
29    {
30    /** Initializes contacts with other processes, if that's what you're doing. Called at the beginning of an evolutionary run, before a population is set up. */
31    public void initializeContacts(EvolutionState state) { }
32
33    /** Initializes contacts with other processes, if that's what you're doing.  Called after restarting from a checkpoint. */
34    public void reinitializeContacts(EvolutionState state) { }
35
36    /** Performs exchanges after the population has been evaluated but before it has been bred,
37        once every generation (or pseudogeneration). */
38    public abstract Population preBreedingExchangePopulation(EvolutionState state);
39
40    /** Performs exchanges after the population has been bred but before it has been evaluated,
41        once every generation (or pseudogeneration). */
42    public abstract Population postBreedingExchangePopulation(EvolutionState state);
43
44    /** Called after preBreedingExchangePopulation(...) to evaluate whether or not
45        the exchanger wishes the run to shut down (with ec.EvolutionState.R_FAILURE) --
46        returns a String (which will be printed out as a message) if the exchanger
47        wants to shut down, else returns null if the exchanger does NOT want to shut down.
48        Why would you want to shut down?
49        This would happen for two reasons.  First, another process might have found
50        an ideal individual and the global run is now over.  Second, some network
51        or operating system error may have occurred and the system needs to be shut
52        down gracefully.  Note that if the exchanger wants to shut down, the system
53        will shut down REGARDLESS of whether or not the user stated
54        ec.EvolutionState.quitOnRunComplete. */
55    public abstract String runComplete(EvolutionState state);
56
57    /** Closes contacts with other processes, if that's what you're doing.  Called at the end of an evolutionary run. result is either ec.EvolutionState.R_SUCCESS or ec.EvolutionState.R_FAILURE, indicating whether or not an ideal individual was found. */
58    public void closeContacts(EvolutionState state, int result) { }
59    }
Note: See TracBrowser for help on using the repository browser.