lio.replacement
Class ElitistReplacement

java.lang.Object
  extended by lio.replacement.ElitistReplacement
All Implemented Interfaces:
LiOResource, Replacement

public class ElitistReplacement
extends java.lang.Object
implements Replacement

This class produces a new population by preserving the best individuals in the former population. By default it keeps only one individual from the former population.


Constructor Summary
ElitistReplacement()
           
 
Method Summary
 LiOResourceDefinition getDefinition()
          Return a LiOResDescription object with the information of each object.
 boolean getKeepIndividuals()
          Returns true if a fix number of individuals from the former population must be choosen to form the new one.
 int getMaxPreserved()
          Returns the maximum number of individuals preserved from the former population.
static void main(java.lang.String[] args)
          Main method to test the task.
 Individual[] replace(Population current, Population former)
          Generates a new population from the current and the former one.
 void setKeepIndividuals(boolean pKeepIndividuals)
          Determines if as many individuals from the former population as indicated with maxPreserved must be preserved even if they don't improve fitness of the worst in the current population.
 void setMaxPreserved(int pMaxPreserved)
          Sets the maximum number of individuals kept from the former population.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElitistReplacement

public ElitistReplacement()
Method Detail

replace

public Individual[] replace(Population current,
                            Population former)
Generates a new population from the current and the former one. The returned population can have either fixed or variable size depending on the value of the variable varSize

Specified by:
replace in interface Replacement
Parameters:
former - The former population.
current - The current population.

setMaxPreserved

public void setMaxPreserved(int pMaxPreserved)
Sets the maximum number of individuals kept from the former population.

Parameters:
pMaxPreserved - Maximum number of individuals kept from the former population.

getMaxPreserved

public int getMaxPreserved()
Returns the maximum number of individuals preserved from the former population.

Returns:
Maximum number of individuals preserved from the former population.

setKeepIndividuals

public void setKeepIndividuals(boolean pKeepIndividuals)
Determines if as many individuals from the former population as indicated with maxPreserved must be preserved even if they don't improve fitness of the worst in the current population.

Parameters:
pKeepIndividuals - Whether selection must taka a number of individuals from the former population.

getKeepIndividuals

public boolean getKeepIndividuals()
Returns true if a fix number of individuals from the former population must be choosen to form the new one.

Returns:
True if it always keep a certain number of individuals.

getDefinition

public LiOResourceDefinition getDefinition()
Return a LiOResDescription object with the information of each object. That object holds the name and all parameters that describe the object

Specified by:
getDefinition in interface LiOResource
Returns:
A definition of the object.

main

public static void main(java.lang.String[] args)
Main method to test the task.