weka.filters.supervised.attribute.gpattributegeneration
Class Population

java.lang.Object
  extended by weka.filters.supervised.attribute.gpattributegeneration.Population

public class Population
extends java.lang.Object

Population class to store a list of individuals in an ArrayList as well as other fields

Author:
Colin Noakes

Constructor Summary
Population()
          Create an empty population
Population(java.util.ArrayList<Genome<Gene>> popList)
          Copy (SHALLOW) the given ArrayList into a new population
Population(EnumGenerationMethod genMethod, java.util.Random rand, java.util.ArrayList<java.lang.String> funcSet, int popSize, int maxDepth, int[] validAttributes)
          Generates a population with the specified generation method and size, using the specified Random object and funcSet.
Population(Population popClonee)
          Clones the given population in the process creating a new one.
 
Method Summary
 void addAll(Population pop)
          Appends all of the given individuals in the ArrayList to this population.
 void calculateFitness(EnumFitnessEvaluationMethod evalMethod, Instances data, Classifier classifier)
          Calculates this population's fitness using the specified Classifier and fitness evaluation method.
 void calculateNsgaii()
          Calculates NSGA-II fronts for this population and updates genomes with domination rank and crowding distance
 Genome<Gene> get(int index)
          Returns the genome in the population at that index.
 java.util.ArrayList<java.lang.String> getFittestIndividuals()
          Return the fittest individuals (as a string) in an ArrayList
 int getMaxLength()
          Max length of the genomes in the population
 double getMaxTreeAccuracy()
          Return the tree accuracy of the best individual(s) in the population.
 int getMaxTreeSize()
          Return max tree size
 double getMaxVectorFitness()
          Return max tree size
 int getMinLength()
          Min length of the genomes in the population
 double getMinTreeAccuracy()
          Return the tree accuracy of the worst individual(s) in the population.
 int getMinTreeSize()
          Return min tree size
 double getMinVectorFitness()
          Return min tree size
 java.util.ArrayList<java.util.ArrayList<Genome<Gene>>> getNonDomFronts()
          Return the non dominated fronts (calculateNsgaii() must have been run beforehand)
 void removeRange(int fromIndex, int toIndex)
          Removes from the population all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
 int size()
          Returns the size of the population
 void sort(EnumSortingCriteria sortBy)
          Sorts the elements of the population list by the specified sorting criteria.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Population

public Population()
Create an empty population


Population

public Population(Population popClonee)
Clones the given population in the process creating a new one. This is a DEEP CLONE, and copies all array list elements.

Parameters:
popClonee - Population object to clone

Population

public Population(java.util.ArrayList<Genome<Gene>> popList)
Copy (SHALLOW) the given ArrayList into a new population

Parameters:
popList - Population list to copy into the new population

Population

public Population(EnumGenerationMethod genMethod,
                  java.util.Random rand,
                  java.util.ArrayList<java.lang.String> funcSet,
                  int popSize,
                  int maxDepth,
                  int[] validAttributes)
Generates a population with the specified generation method and size, using the specified Random object and funcSet.

Parameters:
genMethod - Generation method to use to create the population
rand - Random object to create pseudo-random numbers
funcSet - Function set to use for initialising the population
popSize - The size to make the population
validAttributes - the valid numeric attributes that can be used as part of equations
Method Detail

addAll

public void addAll(Population pop)
Appends all of the given individuals in the ArrayList to this population. Updates Min/Max fitness and length fields

Parameters:
pop - Individuals to combine with this population

getFittestIndividuals

public java.util.ArrayList<java.lang.String> getFittestIndividuals()
Return the fittest individuals (as a string) in an ArrayList

Returns:
The fittest genomes in an ArrayList

getMaxTreeAccuracy

public double getMaxTreeAccuracy()
Return the tree accuracy of the best individual(s) in the population.

Returns:
The maximum tree accuracy of the population

getMinTreeAccuracy

public double getMinTreeAccuracy()
Return the tree accuracy of the worst individual(s) in the population.

Returns:
The minimum tree accuracy of the population

getMaxLength

public int getMaxLength()
Max length of the genomes in the population

Returns:
the maxLength

getMinLength

public int getMinLength()
Min length of the genomes in the population

Returns:
the minLength

getMaxTreeSize

public int getMaxTreeSize()
Return max tree size

Returns:
max tree size

getMinTreeSize

public int getMinTreeSize()
Return min tree size

Returns:
min tree size

getMaxVectorFitness

public double getMaxVectorFitness()
Return max tree size

Returns:
max tree size

getMinVectorFitness

public double getMinVectorFitness()
Return min tree size

Returns:
min tree size

size

public int size()
Returns the size of the population

Returns:
Size of the population

get

public Genome<Gene> get(int index)
Returns the genome in the population at that index.

Parameters:
index - Index of the element to return
Returns:
Genome currently stored at index

removeRange

public void removeRange(int fromIndex,
                        int toIndex)
Removes from the population all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding individuals to the left (reduces their index). This call shortens the list by (toIndex - fromIndex) individuals. (If toIndex==fromIndex, this operation has no effect.)

Parameters:
fromIndex - index of the first individual to be removed
toIndex - index after the last individual to be removed

sort

public void sort(EnumSortingCriteria sortBy)
Sorts the elements of the population list by the specified sorting criteria. Uses QuickSort. Updates relevant max/min fields after a sort is complete.

Parameters:
sortBy - Sorting Criteria to use when sorting

calculateFitness

public void calculateFitness(EnumFitnessEvaluationMethod evalMethod,
                             Instances data,
                             Classifier classifier)
Calculates this population's fitness using the specified Classifier and fitness evaluation method. Also sorts the population in fitness order. Uses standardised fitness value, where 0 is the best fitness.

Parameters:
evalMethod - Fitness evaluation method to use
data - Data to use when calculating fitness
classifier - Classifier to use for fitness evaluation

calculateNsgaii

public void calculateNsgaii()
Calculates NSGA-II fronts for this population and updates genomes with domination rank and crowding distance


getNonDomFronts

public java.util.ArrayList<java.util.ArrayList<Genome<Gene>>> getNonDomFronts()
Return the non dominated fronts (calculateNsgaii() must have been run beforehand)

Returns:
non dominated fronts