es.udc.gii.common.eaf.algorithm.parallel.migration.acceptance
Class GenerationBasedAcceptance

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.parallel.migration.acceptance.GenerationBasedAcceptance
All Implemented Interfaces:
MigAcceptancePolicy, Configurable

public class GenerationBasedAcceptance
extends java.lang.Object
implements MigAcceptancePolicy

Accepts the individuals that come in a MigrationObject based on the generation of the sending node.

Author:
Rafael Tedin Alvarez

Field Summary
private  int acceptIndividualsFrom
          Generation from which individuals are accepted.
static int ANY_GENERATION
          States that individuals from other processes in the any generation are going to be considered for inmigration.
static int NEWER_GENERATION
          States that only individuals from other processes in a newer generation or in the same generation are going to be considered for inmigration.
static int OLDER_GENERATION
          States that only individuals from other processes in an older generation or in the same generation are going to be considered for inmigration.
private  java.util.List<MigrationObject> pendingMigrants
          Individuals that have not been yet accepted but that might be accepted in the future.
static int SAME_GENERATION
          States that only individuals from other processes in the same generation are going to be considered for inmigration.
 
Constructor Summary
GenerationBasedAcceptance()
          Creates a new instance of GenerationBasedAcceptance
GenerationBasedAcceptance(int acceptIndividualsFrom)
          Creates a new instance of GenerationBasedAcceptance
 
Method Summary
 java.util.List<Individual> accept(MigrationObject migrant, EvolutionaryAlgorithm algorithm, java.util.List<Individual> currentPopulation)
          Accepts the individuals that come in a MigrationObject based on the generation of the sending node.
 void configure(org.apache.commons.configuration.Configuration conf)
          Configures this class with a given Configuration.
 int getAcceptIndividualsFrom()
           
 java.util.List<MigrationObject> getPendingMigrants()
           
 void setAcceptIndividualsFrom(int acceptIndividualsFrom)
          Configures the way individuals are accepted.
 void setPendingMigrants(java.util.List<MigrationObject> pendingMigrants)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SAME_GENERATION

public static final int SAME_GENERATION
States that only individuals from other processes in the same generation are going to be considered for inmigration.

See Also:
Constant Field Values

ANY_GENERATION

public static final int ANY_GENERATION
States that individuals from other processes in the any generation are going to be considered for inmigration.

See Also:
Constant Field Values

OLDER_GENERATION

public static final int OLDER_GENERATION
States that only individuals from other processes in an older generation or in the same generation are going to be considered for inmigration.

See Also:
Constant Field Values

NEWER_GENERATION

public static final int NEWER_GENERATION
States that only individuals from other processes in a newer generation or in the same generation are going to be considered for inmigration.

See Also:
Constant Field Values

acceptIndividualsFrom

private int acceptIndividualsFrom
Generation from which individuals are accepted.


pendingMigrants

private java.util.List<MigrationObject> pendingMigrants
Individuals that have not been yet accepted but that might be accepted in the future.

Constructor Detail

GenerationBasedAcceptance

public GenerationBasedAcceptance()
Creates a new instance of GenerationBasedAcceptance


GenerationBasedAcceptance

public GenerationBasedAcceptance(int acceptIndividualsFrom)
Creates a new instance of GenerationBasedAcceptance

Method Detail

accept

public java.util.List<Individual> accept(MigrationObject migrant,
                                         EvolutionaryAlgorithm algorithm,
                                         java.util.List<Individual> currentPopulation)
Accepts the individuals that come in a MigrationObject based on the generation of the sending node.

Specified by:
accept in interface MigAcceptancePolicy
Returns:
A list of the accepted individuals. If no individual is accepted, then an empty list is returned.

configure

public void configure(org.apache.commons.configuration.Configuration conf)
Configures this class with a given Configuration.

Configuration example:

 ...
 <AcceptancePolicy>
     <Class>...parallel.migration.GenerationBasedAcceptance</Class>
     <AcceptIndividualsFrom>ANY_GENERATION</AcceptIndividualsFrom>
 </AcceptancePolicy>
 ...
 

This configures this class for accepting any individual from any generation. The following values are allowed for AcceptIndividualsFrom:

    ANY_GENERATION
    OLDER_GENERATION
    NEWER_GENERATION
    SAME_GENERATION
 

Specified by:
configure in interface Configurable

toString

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

getAcceptIndividualsFrom

public int getAcceptIndividualsFrom()

setAcceptIndividualsFrom

public void setAcceptIndividualsFrom(int acceptIndividualsFrom)
Configures the way individuals are accepted. The following values are correct:

The default is ANY_GENERATION. A runtime exception is thrown if an invalid value is passed.


getPendingMigrants

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

setPendingMigrants

public void setPendingMigrants(java.util.List<MigrationObject> pendingMigrants)