es.udc.gii.common.eaf.algorithm.parallel.migration
Class MigrationOperator

java.lang.Object
  extended by java.util.Observable
      extended by es.udc.gii.common.eaf.algorithm.operator.replace.ReplaceOperator
          extended by es.udc.gii.common.eaf.algorithm.parallel.migration.MigrationOperator
All Implemented Interfaces:
Operator, Configurable

public class MigrationOperator
extends ReplaceOperator

A migration operator is a replace operator that performs the exchange of genetic material between two islands in a parallel evolutionary algorithm, where this makes sense (i.e. in an island model).

A migration operator has a MigrationTopology of islands associated, which takes care of the underlying connections between the islands. A MigAcceptancePolicy says which individuals from those who have come from other islands are accepted. An example could be to accept only individuals from an older generation than the current island's generation. It also has a MigCullingStrategy, which is in charge of selecting the individuals to be removed from the the current population of the island, and a MigSelectionStrategy for selecting the individuals that migrate from the current population of the island to the neighbours islands.

Migration is controlled by a migration frequency. This frequency is an integer that states how often is migration applied. For example, if this frequency is set to 3, a migration will be performed every 3 generations.

Author:
Rafael Tedin Alvarez

Field Summary
static int ACCEPTED
           
static int CULLED
           
private  java.util.List<Individual> currentAccepted
           
private  java.util.List<Individual> currentCulled
           
private  MigrationObject currentMigrant
           
private  java.util.List<MigrationObject> currentMigrants
           
private  java.util.List<Individual> currentPopulation
           
private  MigAcceptancePolicy migAcceptancePolicy
          The policy for accepting the incommig individuals.
private  MigCullingStrategy migCullingStrategy
          The strategy to follow for culling individuals from the current population.
private  int migrationFrequecy
          The migration frequency [generations / migration].
private  MigSelectionStrategy migSelectionStrategy
          The strategy to follow for selecting those individuals to send to other islands.
static int NOT_INITIALIZED
           
static int RECEIVED
           
static int SENDING
           
private  int state
           
private  boolean synchronizedReceive
          Synchronize all processes before receiving.
private  MigrationTopology topology
          The topology that connects the islands.
 
Constructor Summary
MigrationOperator()
          Creates a new instance of MigrationOperator.
MigrationOperator(MigrationTopology topology, MigCullingStrategy migCullingStrategy, MigSelectionStrategy migSelectionStrategy, MigAcceptancePolicy migAcceptancePolicy, int migrationFrequecy)
          Creates a new instance of MigrationOperator.
 
Method Summary
protected  java.util.List<Individual> acceptIndividuals(EvolutionaryAlgorithm algorithm, java.util.List<Individual> toPopulation, java.util.List<MigrationObject> migrants)
          Returns the individuals that satisfy some criterion (see MigAcceptacePolicy) among those which are received from other nodes.
 void configure(org.apache.commons.configuration.Configuration conf)
          Configures this operator.
protected  java.util.List<Individual> cullIndividuals(EvolutionaryAlgorithm algorithm, java.util.List<Individual> acceptedIndividuals, java.util.List<Individual> toPopulation)
          Returns the individuals which are to be culled (removed) from the current population considering the individuals which are beeing received and accepted from other nodes.
 void finish()
          Terminates this migration operator correctly.
 java.util.List<Individual> getCurrentAccepted()
           
 java.util.List<Individual> getCurrentCulled()
           
 MigrationObject getCurrentMigrant()
           
 java.util.List<MigrationObject> getCurrentMigrants()
           
 java.util.List<Individual> getCurrentPopulation()
           
 MigAcceptancePolicy getMigAcceptancePolicy()
           
 MigCullingStrategy getMigCullingStrategy()
           
 int getMigrationFrequecy()
           
 MigrationTopology getMigrationTopology()
           
 MigSelectionStrategy getMigSelectionStrategy()
           
 int getState()
           
 boolean isSynchronized()
           
protected  java.util.List<Individual> migrate(EvolutionaryAlgorithm algorithm, java.util.List<Individual> toPopulation)
          Performs migration.
protected  java.lang.String myName()
          The name of this operator.
 void notifyObservers(int state)
           
protected  java.util.List<Individual> replace(EvolutionaryAlgorithm algorithm, java.util.List<Individual> toPopulation)
          The replace method of ReplaceOperator is overwritten and forced to be final so that no subclass can overwrite it.
protected  MigrationObject selectIndividualsForMigration(EvolutionaryAlgorithm algorithm, java.util.List<Individual> toPopulation)
          Selects the individuals that will be sent to other nodes.
 void setMigAcceptancePolicy(MigAcceptancePolicy migAcceptancePolicy)
           
 void setMigCullingStrategy(MigCullingStrategy migCullingStrategy)
           
 void setMigrationFrequecy(int migrationFrequecy)
           
 void setMigrationTopology(MigrationTopology topology)
           
 void setMigSelectionStrategy(MigSelectionStrategy migSelectionStrategy)
           
protected  void setState(int state)
           
 void setSynchronized(boolean synchronizedReceive)
          If set to true then before receiving the individuals a synchronization of all process within the topology is performed.
 java.lang.String toString()
           
 
Methods inherited from class es.udc.gii.common.eaf.algorithm.operator.replace.ReplaceOperator
operate
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOT_INITIALIZED

public static final int NOT_INITIALIZED
See Also:
Constant Field Values

SENDING

public static final int SENDING
See Also:
Constant Field Values

RECEIVED

public static final int RECEIVED
See Also:
Constant Field Values

ACCEPTED

public static final int ACCEPTED
See Also:
Constant Field Values

CULLED

public static final int CULLED
See Also:
Constant Field Values

state

private int state

topology

private MigrationTopology topology
The topology that connects the islands.


migCullingStrategy

private MigCullingStrategy migCullingStrategy
The strategy to follow for culling individuals from the current population.


migSelectionStrategy

private MigSelectionStrategy migSelectionStrategy
The strategy to follow for selecting those individuals to send to other islands.


migAcceptancePolicy

private MigAcceptancePolicy migAcceptancePolicy
The policy for accepting the incommig individuals.


migrationFrequecy

private int migrationFrequecy
The migration frequency [generations / migration].


synchronizedReceive

private boolean synchronizedReceive
Synchronize all processes before receiving.


currentAccepted

private java.util.List<Individual> currentAccepted

currentCulled

private java.util.List<Individual> currentCulled

currentMigrants

private java.util.List<MigrationObject> currentMigrants

currentMigrant

private MigrationObject currentMigrant

currentPopulation

private java.util.List<Individual> currentPopulation
Constructor Detail

MigrationOperator

public MigrationOperator()
Creates a new instance of MigrationOperator.


MigrationOperator

public MigrationOperator(MigrationTopology topology,
                         MigCullingStrategy migCullingStrategy,
                         MigSelectionStrategy migSelectionStrategy,
                         MigAcceptancePolicy migAcceptancePolicy,
                         int migrationFrequecy)
Creates a new instance of MigrationOperator.

Method Detail

replace

protected final java.util.List<Individual> replace(EvolutionaryAlgorithm algorithm,
                                                   java.util.List<Individual> toPopulation)
The replace method of ReplaceOperator is overwritten and forced to be final so that no subclass can overwrite it. The migration is forced to be implemented by the migrate(es.udc.gii.common.eaf.algorithm.EvolutionaryAlgorithm, java.util.List) method.

Specified by:
replace in class ReplaceOperator

configure

public void configure(org.apache.commons.configuration.Configuration conf)
Configures this operator.

Configuration example:

  <Operator>
      <Class>...parallel.migration.MigrationOperator</Class>

      <MigrationFrequency>2</MigrationFrequency>

      <CullingStrategy>
          <Class>...</Class>
          ...
      </CullingStrategy>

      <SelectionStrategy>
          <Class>...</Class>
          ...
      </SelectionStrategy>

      <AcceptancePolicy>
          <Class>...</Class>
          ...
      </AcceptancePolicy>

      <Topology>
          <Class>...</Class>
          ...
      </Topology>

      <Synchronized/>
  </Operator>
  

Migration will be performed every 2 generations and, before receiving, all nodes are synchronized. If no synchronization is needed, simply remove the <Synchronized/> tag.

Specified by:
configure in interface Configurable
Overrides:
configure in class ReplaceOperator
Parameters:
conf - Configuration.

migrate

protected java.util.List<Individual> migrate(EvolutionaryAlgorithm algorithm,
                                             java.util.List<Individual> toPopulation)
Performs migration.


notifyObservers

public void notifyObservers(int state)

selectIndividualsForMigration

protected MigrationObject selectIndividualsForMigration(EvolutionaryAlgorithm algorithm,
                                                        java.util.List<Individual> toPopulation)
Selects the individuals that will be sent to other nodes.


acceptIndividuals

protected java.util.List<Individual> acceptIndividuals(EvolutionaryAlgorithm algorithm,
                                                       java.util.List<Individual> toPopulation,
                                                       java.util.List<MigrationObject> migrants)
Returns the individuals that satisfy some criterion (see MigAcceptacePolicy) among those which are received from other nodes.


cullIndividuals

protected java.util.List<Individual> cullIndividuals(EvolutionaryAlgorithm algorithm,
                                                     java.util.List<Individual> acceptedIndividuals,
                                                     java.util.List<Individual> toPopulation)
Returns the individuals which are to be culled (removed) from the current population considering the individuals which are beeing received and accepted from other nodes.


myName

protected java.lang.String myName()
The name of this operator.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

finish

public void finish()
Terminates this migration operator correctly.


isSynchronized

public boolean isSynchronized()

getMigrationFrequecy

public int getMigrationFrequecy()

setMigrationFrequecy

public void setMigrationFrequecy(int migrationFrequecy)

getMigrationTopology

public MigrationTopology getMigrationTopology()

setMigrationTopology

public void setMigrationTopology(MigrationTopology topology)

getMigCullingStrategy

public MigCullingStrategy getMigCullingStrategy()

setMigCullingStrategy

public void setMigCullingStrategy(MigCullingStrategy migCullingStrategy)

getMigSelectionStrategy

public MigSelectionStrategy getMigSelectionStrategy()

setMigSelectionStrategy

public void setMigSelectionStrategy(MigSelectionStrategy migSelectionStrategy)

setSynchronized

public void setSynchronized(boolean synchronizedReceive)
If set to true then before receiving the individuals a synchronization of all process within the topology is performed. This is usefull for ensuring that each process has sent its data when accepting individuals from only the same generation and that all processes will hence receive data in the same generation.

The default is false.


getMigAcceptancePolicy

public MigAcceptancePolicy getMigAcceptancePolicy()

setMigAcceptancePolicy

public void setMigAcceptancePolicy(MigAcceptancePolicy migAcceptancePolicy)

getState

public int getState()

setState

protected void setState(int state)

getCurrentAccepted

public java.util.List<Individual> getCurrentAccepted()

getCurrentCulled

public java.util.List<Individual> getCurrentCulled()

getCurrentMigrant

public MigrationObject getCurrentMigrant()

getCurrentMigrants

public java.util.List<MigrationObject> getCurrentMigrants()

getCurrentPopulation

public java.util.List<Individual> getCurrentPopulation()