ec.exchange
Class InterPopulationExchange

java.lang.Object
  |
  +--ec.Exchanger
        |
        +--ec.exchange.InterPopulationExchange
All Implemented Interfaces:
java.io.Serializable, Setup, Singleton

public class InterPopulationExchange
extends Exchanger

InterPopulationExchange is an Exchanger which implements a simple exchanger between subpopulations. IterPopulationExchange uses an arbitrary graph topology for migrating individuals from subpopulations. The assumption is that all subpopulations have the same representation and same task to solve, otherwise the exchange between subpopulations does not make much sense. The parameter file for the InterPopulationExchange for setting up the topology looks like this: exch.subpop.0.id = 0 exch.subpop.0.select = ec.select.TournamentSelection exch.subpop.0.mod = 2 exch.subpop.0.start = 0 exch.subpop.0.size = 3 exch.subpop.0.nr-dest = 2 exch.subpop.0.dest.0 = 1 exch.subpop.0.dest.1 = 2 exch.subpop.1.id = 1 exch.subpop.1.select = ec.select.TournamentSelection exch.subpop.1.mod = 2 exch.subpop.1.start = 0 exch.subpop.1.size = 3 exch.subpop.1.nr-dest = 1 exch.subpop.1.dest.0 = 2 exch.subpop.2.id = 2 exch.subpop.2.select = ec.select.TournamentSelection exch.subpop.2.mod = 2 exch.subpop.2.start = 0 exch.subpop.2.size = 3 exch.subpop.2.nr-dest = 1 exch.subpop.2.dest.0 = 0

See Also:
Serialized Form

Field Summary
 Parameter base
          My parameter base -- I need to keep this in order to help the server reinitialize contacts
static java.lang.String P_DEST
          The prefix for destinations
static java.lang.String P_DEST_FOR_SUBPOP
          The number of destinations from current island
static java.lang.String P_ID_SUBPOP
          The id of the current source subpopulation
static java.lang.String P_MODULO
          The parameter for the modulo (how many generations should pass between consecutive sendings of individuals
static java.lang.String P_OFFSET
          How many generations to pass at the beginning of the evolution before the first emigration from the current subpopulation
static java.lang.String P_SELECT_METHOD
          The selection method for sending individuals to other islands
static java.lang.String P_SIZE
          The number of emigrants to be sent
static java.lang.String P_SUBPOP
          The subpopulation delimiter
 
Constructor Summary
InterPopulationExchange()
           
 
Method Summary
 void closeContacts(EvolutionState state, int result)
          Closes contacts with other processes, if that's what you're doing.
 void initializeContacts(EvolutionState state)
          Initializes contacts with other processes, if that's what you're doing.
 Population postBreedingExchangePopulation(EvolutionState state)
          Performs exchanges after the population has been bred but before it has been evaluated, once every generation (or pseudogeneration).
 Population preBreedingExchangePopulation(EvolutionState state)
          Performs exchanges after the population has been evaluated but before it has been bred, once every generation (or pseudogeneration).
 void reinitializeContacts(EvolutionState state)
          Initializes contacts with other processes, if that's what you're doing.
 java.lang.String runComplete(EvolutionState state)
          Called after preBreedingExchangePopulation(...) to evaluate whether or not the exchanger wishes the run to shut down (with ec.EvolutionState.R_FAILURE).
 void setup(EvolutionState state, Parameter _base)
          Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_SUBPOP

public static final java.lang.String P_SUBPOP
The subpopulation delimiter

P_ID_SUBPOP

public static final java.lang.String P_ID_SUBPOP
The id of the current source subpopulation

P_MODULO

public static final java.lang.String P_MODULO
The parameter for the modulo (how many generations should pass between consecutive sendings of individuals

P_SIZE

public static final java.lang.String P_SIZE
The number of emigrants to be sent

P_OFFSET

public static final java.lang.String P_OFFSET
How many generations to pass at the beginning of the evolution before the first emigration from the current subpopulation

P_DEST_FOR_SUBPOP

public static final java.lang.String P_DEST_FOR_SUBPOP
The number of destinations from current island

P_DEST

public static final java.lang.String P_DEST
The prefix for destinations

P_SELECT_METHOD

public static final java.lang.String P_SELECT_METHOD
The selection method for sending individuals to other islands

base

public Parameter base
My parameter base -- I need to keep this in order to help the server reinitialize contacts
Constructor Detail

InterPopulationExchange

public InterPopulationExchange()
Method Detail

setup

public void setup(EvolutionState state,
                  Parameter _base)
Description copied from interface: Setup
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.

initializeContacts

public void initializeContacts(EvolutionState state)
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. It doesn't do anything, as this exchanger works on only 1 computer.
Overrides:
initializeContacts in class Exchanger

reinitializeContacts

public void reinitializeContacts(EvolutionState state)
Initializes contacts with other processes, if that's what you're doing. Called after restarting from a checkpoint. It doesn't do anything, as this exchanger works on only 1 computer.
Overrides:
reinitializeContacts in class Exchanger

preBreedingExchangePopulation

public Population preBreedingExchangePopulation(EvolutionState state)
Description copied from class: Exchanger
Performs exchanges after the population has been evaluated but before it has been bred, once every generation (or pseudogeneration).
Overrides:
preBreedingExchangePopulation in class Exchanger

postBreedingExchangePopulation

public Population postBreedingExchangePopulation(EvolutionState state)
Description copied from class: Exchanger
Performs exchanges after the population has been bred but before it has been evaluated, once every generation (or pseudogeneration).
Overrides:
postBreedingExchangePopulation in class Exchanger

runComplete

public java.lang.String runComplete(EvolutionState state)
Called after preBreedingExchangePopulation(...) to evaluate whether or not the exchanger wishes the run to shut down (with ec.EvolutionState.R_FAILURE). This would happen for two reasons. First, another process might have found an ideal individual and the global run is now over. Second, some network or operating system error may have occurred and the system needs to be shut down gracefully. This function does not return a String as soon as it wants to exit (another island found the perfect individual, or couldn't connect to the server). Instead, it sets a flag, called message, to remember next time to exit. This is due to a need for a graceful shutdown, where checkpoints are working properly and save all needed information.
Overrides:
runComplete in class Exchanger

closeContacts

public void closeContacts(EvolutionState state,
                          int result)
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.
Overrides:
closeContacts in class Exchanger