Class InterPopulationExchange
- java.lang.Object
-
- ec.Exchanger
-
- ec.exchange.InterPopulationExchange
-
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.InterPopulationExchange has a topology which is similar to the one used by IslandExchange. Every few generations, a subpopulation will send some number of individuals to other subpopulations. Since all subpopulations evolve at the same generational speed, this is a synchronous procedure (IslandExchange instead is asynchronous by default, though you can change it to synchronous).
Individuals are sent from a subpopulation prior to breeding. They are stored in a waiting area until after all subpopulations have bred; thereafter they are added into the new subpopulation. This means that the subpopulation order doesn't matter. Also note that it means that some individuals will be created during breeding, and immediately killed to make way for the migrants. A little wasteful, we know, but it's simpler that way.
Parameters
base.chatty
boolean, default = trueShould we be verbose or silent about our exchanges? Note: For each subpopulation in your population, there must be one exch.subpop... declaration set.
base.subpop.n.select
classname, inherits and != ec.SelectionMethodThe selection method used by subpopulation #n for picking migrants to emigrate to other subpopulations. If not set, uses the default parameter below. base.select
classname, inherits and != ec.SelectionMethodserver: Default parameter: the selection method used by a given subpopulation for picking migrants to emigrate to other subpopulations. base.subpop.n.select-to-die
classname, inherits and != ec.SelectionMethod (Default is random selection)The selection method used by subpopulation #n for picking individuals to be replaced by migrants. If not set, uses the default parameter below. base.select-to-die
classname, inherits and != ec.SelectionMethod (Default is random selection)server: Default parameter: the selection method used by a given subpopulation for picking individuals to be replaced by migrants. base.subpop.n.mod
int >= 1The number of generations that subpopulation #n waits between sending emigrants. If not set, uses the default parameter below. base.mod
int >= 1server: Default parameter: the number of generations that a given subpopulation waits between sending emigrants. base.subpop.n.start
int >= 0The generation when subpopulation #n begins sending emigrants. If not set, uses the default parameter below. base.start
int >= 0server: Default parameter: the generation when a given subpopulation begins sending emigrants. base.subpop.n.size
int >= 0The number of emigrants sent at one time by generation #n. If not set, uses the default parameter below. base.subpop.n.num-dest
int >= 0The number of destination subpopulations for this subpopulation. base.subpop.n.dest.m
int >= 0Subpopulation #n's destination #m is this subpopulation. Parameter bases
base.subpop.n.select
selection method for subpopulation #n's migrants - See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description ParameterbaseMy parameter base -- I need to keep this in order to help the server reinitialize contactsbooleanchattystatic java.lang.StringP_CHATTYWhether or not we're chattystatic java.lang.StringP_DESTThe prefix for destinationsstatic java.lang.StringP_DEST_FOR_SUBPOPThe number of destinations from current islandstatic java.lang.StringP_MODULOThe parameter for the modulo (how many generations should pass between consecutive sendings of individualsstatic java.lang.StringP_OFFSETHow many generations to pass at the beginning of the evolution before the first emigration from the current subpopulationstatic java.lang.StringP_SELECT_METHODThe selection method for sending individuals to other islandsstatic java.lang.StringP_SELECT_TO_DIE_METHODThe selection method for deciding individuals to be replaced by immigrantsstatic java.lang.StringP_SIZEThe number of emigrants to be sentstatic java.lang.StringP_SUBPOPThe subpopulation delimiter
-
Constructor Summary
Constructors Constructor and Description InterPopulationExchange()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcloseContacts(EvolutionState state, int result)Closes contacts with other processes, if that's what you're doing.voidinitializeContacts(EvolutionState state)Initializes contacts with other processes, if that's what you're doing.PopulationpostBreedingExchangePopulation(EvolutionState state)Performs exchanges after the population has been bred but before it has been evaluated, once every generation (or pseudogeneration).PopulationpreBreedingExchangePopulation(EvolutionState state)Performs exchanges after the population has been evaluated but before it has been bred, once every generation (or pseudogeneration).voidreinitializeContacts(EvolutionState state)Initializes contacts with other processes, if that's what you're doing.java.lang.StringrunComplete(EvolutionState state)Called after preBreedingExchangePopulation(...) to evaluate whether or not the exchanger wishes the run to shut down (with ec.EvolutionState.R_FAILURE).voidsetup(EvolutionState state, Parameter _base)Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
-
-
-
Field Detail
-
P_SUBPOP
public static final java.lang.String P_SUBPOP
The subpopulation delimiter- See Also:
- Constant Field Values
-
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- See Also:
- Constant Field Values
-
P_SIZE
public static final java.lang.String P_SIZE
The number of emigrants to be sent- See Also:
- Constant Field Values
-
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- See Also:
- Constant Field Values
-
P_DEST_FOR_SUBPOP
public static final java.lang.String P_DEST_FOR_SUBPOP
The number of destinations from current island- See Also:
- Constant Field Values
-
P_DEST
public static final java.lang.String P_DEST
The prefix for destinations- See Also:
- Constant Field Values
-
P_SELECT_METHOD
public static final java.lang.String P_SELECT_METHOD
The selection method for sending individuals to other islands- See Also:
- Constant Field Values
-
P_SELECT_TO_DIE_METHOD
public static final java.lang.String P_SELECT_TO_DIE_METHOD
The selection method for deciding individuals to be replaced by immigrants- See Also:
- Constant Field Values
-
P_CHATTY
public static final java.lang.String P_CHATTY
Whether or not we're chatty- See Also:
- Constant Field Values
-
base
public Parameter base
My parameter base -- I need to keep this in order to help the server reinitialize contacts
-
chatty
public boolean chatty
-
-
Method Detail
-
setup
public void setup(EvolutionState state, Parameter _base)
Description copied from interface:SetupSets 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:
initializeContactsin classExchanger
-
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:
reinitializeContactsin classExchanger
-
preBreedingExchangePopulation
public Population preBreedingExchangePopulation(EvolutionState state)
Description copied from class:ExchangerPerforms exchanges after the population has been evaluated but before it has been bred, once every generation (or pseudogeneration).- Specified by:
preBreedingExchangePopulationin classExchanger
-
postBreedingExchangePopulation
public Population postBreedingExchangePopulation(EvolutionState state)
Description copied from class:ExchangerPerforms exchanges after the population has been bred but before it has been evaluated, once every generation (or pseudogeneration).- Specified by:
postBreedingExchangePopulationin classExchanger
-
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.- Specified by:
runCompletein classExchanger
-
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:
closeContactsin classExchanger
-
-
DMelt 3.0 © DataMelt by jWork.ORG