|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectgeneticWedge.gp.AbstractPopulation
geneticWedge.gp.Population
public class Population
Population is the standard Population class. A Population contains a number of Individuals and holds information about the population as a whole such as average fitness. A Population may be evolved by calling the evolve() method.
Nested Class Summary | |
---|---|
static class |
Population.PerformanceFunction
PerformanceFunctions are used to create multi-objective evaluation functions. |
Nested classes/interfaces inherited from class geneticWedge.gp.AbstractPopulation |
---|
AbstractPopulation.FitnessFunction, AbstractPopulation.SelectionMethod |
Field Summary | |
---|---|
protected int |
evolutionNumber
|
protected boolean |
printInfo
|
Fields inherited from class geneticWedge.gp.AbstractPopulation |
---|
allFitnesses, aurocSampleSize, averageTrainFitness, averageValidationFitness, bestIndex, bestTrainFitness, bestTrainFitnessSoFar, bestValidationFitness, bestValidationFitnessSoFar, fitnessFunction, generationNumber, maxGenerations, popDescriptor, popSize, recFitnessFunction, startingPopSize, tournamentSize |
Constructor Summary | |
---|---|
Population(int populationSize,
PopulationDescriptor descriptor)
The Population constructor takes the population size and a PopulationDescriptor as variables. |
Method Summary | |
---|---|
void |
collectTransmissionInfo(boolean collect)
If set to true, information concerning the relationship between parents and offspring will be saved. |
boolean |
evolve(boolean steadyState,
AbstractPopulation.SelectionMethod selectMethod,
double[][] inputs,
double[] targetOutputs,
double[][] validationInputs,
double[] validationTargetOutputs,
StoppingCriterion stopCriterion)
If this method is called in steadyState mode with a selectMethod that uses roulette wheel selection (FITNESS_PROPORTIONAL, RANK or FUSS), elitist selection will not occur, even if an elite size has been set. |
boolean |
evolve(boolean steadyState,
double[][] inputs,
double[] targetOutputs,
double[][] validationInputs,
double[] validationTargetOutputs,
StoppingCriterion stopCriterion)
If this method is called, the selection method will be deduced from the value of steadyState. |
protected void |
evolveOneGeneration(boolean steadyState,
AbstractPopulation.SelectionMethod selectMethod,
double[][] inputs,
double[] targetOutputs)
|
java.util.Vector<double[]> |
getAllCutDepthCorrelations()
This method may be used if transmission information has been collected. |
double[][] |
getAllSquaredDistances(boolean recalculate)
Returns a 2-D array containing the 'distances' between pairs of Individuals, in the 'upper right' sector (above the leading diagonal). |
double |
getAverageComplexity()
Returns the average function complexity of all Individuals within the population. |
double[] |
getAverageCutDepthCorrelation()
This method may be used if transmission information has been collected. |
double |
getAverageFitness(double[][] inputs,
double[] targetOutputs,
boolean recalculateValues)
Returns the average fitness of all Individual on the data provided. |
double |
getAverageIndividualLength()
Returns the average length (number of nodes) of all Individuals in this Population. |
double |
getAverageSquaredDistance(Individual ind)
Obtains the average distance between ind and the Population's current members |
double |
getAverageSquaredDistance(int index)
Returns the average squared distance between the Individual denoted by index and all other members of the population. |
double |
getAverageSquaredDistance(int index,
Individual newInd)
Obtains the average distance that would occur if the new Individual were to replace the Individual currently at index index. |
double |
getAverageTrainingFitness()
Returns the average fitness of all Individuals on the training data. |
double |
getAverageValidationFitness()
Returns the average fitness of all Individuals on the validation data. |
Individual |
getBestIndividual()
Returns the best Individual on the training data. |
double |
getBestTrainingFitness()
Returns the fitness of the best Individual on the training data. |
Individual |
getBestValidatedIndividual()
This method will return null if no evolution has occurred (because no validation has been performed) or if a validation set was not provided or a validation criterion was not used. |
double |
getBestValidationFitness()
Returns the fitness of the best Individual on the validation data. |
boolean |
getBroodUse()
If set to true, brood recombination will be used during crossover |
Crossover |
getCrossover()
Returns the Crossover object to be used by this Population. |
double |
getDiversity()
getDiversity() counts the number of different Individuals in the Population, subtracts 1 and divides by (population size - 1). |
double[] |
getFitnesses()
This method should only be called after evolving the population. |
AbstractPopulation.FitnessFunction |
getFitnessFunction()
Returns the FitnessFunction used to evaluate Individuals within this Population. |
FitnessShare |
getFitnessShare()
Returns the fitness share object. |
Individual[] |
getIndividuals()
|
boolean |
getKeepDominated()
If set to true, the Population size will be maintained when using a multi-objective evaluation function (PerformanceFunctions). |
int |
getMaximumIndividualDepth()
Retruns the maximum depth of an Individual created by crossover or mutation. |
int |
getMaximumIndividualLength()
Returns the maximum length of an Individual created by crossover or mutation. |
boolean |
getMultiObjective()
If true, and PerformanceFunctions have been applied, multi-objective (Pareto-style) selection will occur. |
Mutation |
getMutation()
Returns the Mutation object to be used by this Population. |
Population.PerformanceFunction[] |
getPerformanceFunctions()
Returns an array of the PerformanceFunctions used in selecting Individuals. |
double |
getRankGradient()
Returns the rank gradient to be used during RANK selection. |
FitnessShare.ShareType |
getShareType()
Returns the fitness type. |
double[] |
getShareWeightings()
Returns the share weightings. |
double[][] |
getSquaredDistances(int[] indices,
boolean recalculate)
Returns the distances between selected Individuals in the Population, denoted by their indices, and all other members of the Population. |
java.util.Vector<java.util.Vector<double[]>> |
getTransmissionInfo()
Returns a vector containing transmission information concerning the relationships between parents and offspring |
boolean |
hasNoDiversity()
|
protected void |
removeDominatedIndividuals()
|
protected void |
removeDuplicatedIndividuals()
|
protected void |
savePopulation()
|
void |
setBroodUse(boolean useBrood)
If set to true, brood recombination will be used during crossover |
void |
setCrossover(Crossover newCross)
Sets the Crossover object to be used by this Population. |
void |
setFitnessFunction(AbstractPopulation.FitnessFunction func)
Sets the FitnessFunction used to evaluate Individuals within this Population. |
void |
setFitnessShare(FitnessShare fitnessShare,
FitnessShare.ShareType shareType)
Fitness sharing aims to prevent Individuals within a small niche from dominating the Population. |
void |
setKeepDominated(boolean keepDominated)
If set to true, the Population size will be maintained when using a multi-objective evaluation function (PerformanceFunctions). |
void |
setMaximumIndividualDepth(int maxDepth)
Setting a low maximumIndividualDepth is a way of controlling bloat. |
void |
setMaximumIndividualLength(int maxLength)
Setting a low maximumIndividualLength is a way of controlling bloat. |
void |
setMutation(Mutation newMut)
Sets the Mutation object to be used by this Population. |
void |
setPerformanceFunctions(Population.PerformanceFunction[] perfFuncs,
boolean isMultiObjective)
Sets the PerformanceFunctions used to evaluate Individuals within this Population. |
void |
setPrintStatus(boolean status)
If printInfo is set to true, Population will print information concerning it's current status to the 'out' stream during evolution. |
void |
setRankGradient(double gradient)
Sets the rank gradient to be used during RANK selection. |
void |
setShareWeightings(double[] weightings,
boolean isMultiObjectivelyShared)
Sets the share weightings. |
boolean |
setSingleObjectiveRatio(double[] ratio)
Sets the weightings of performanceFunctions. |
void |
setTransmissionWritingParameters(int frequency,
java.lang.String transmissionInfoFile)
Sets parameters for saving transmission information (if used). |
void |
setTruncationParameters(boolean includeParentsInPool,
int numberOfParents,
int numberOfOffspring)
Sets parameters to be used during TRUNCATION selection. |
java.lang.Object[] |
ShellSortIndividuals()
This method returns an Object array. |
java.lang.Object[] |
ShellSortIndividuals(double[] objectiveData,
boolean sortAscending)
This method returns an Object array. |
static java.lang.Object[] |
ShellSortIndividuals(Individual[] individuals,
double[] allFitnesses,
AbstractPopulation.FitnessFunction fitnessFunction)
This method uses the Shell sort algorithm to order an array of Individuals according to theoir fitness. |
static java.lang.Object[] |
ShellSortIndividuals(Individual[] individuals,
double[] allFitnesses,
boolean sortAscending)
This method uses the Shell sort algorithm to order an array of Individuals according to theoir fitness. |
Methods inherited from class geneticWedge.gp.AbstractPopulation |
---|
getAUROCSampleSize, getGenerationNumber, getInitialPopulationSize, getMaxGenerations, getPopulationDescriptor, getPopulationSize, getRECFitnessFunction, getTournamentSize, setAUROCSampleSize, setMaxGenerations, setRECFitnessFunction, setTournamentSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean printInfo
protected int evolutionNumber
Constructor Detail |
---|
public Population(int populationSize, PopulationDescriptor descriptor)
Method Detail |
---|
public void setPrintStatus(boolean status)
public Individual[] getIndividuals()
public boolean evolve(boolean steadyState, double[][] inputs, double[] targetOutputs, double[][] validationInputs, double[] validationTargetOutputs, StoppingCriterion stopCriterion)
public boolean evolve(boolean steadyState, AbstractPopulation.SelectionMethod selectMethod, double[][] inputs, double[] targetOutputs, double[][] validationInputs, double[] validationTargetOutputs, StoppingCriterion stopCriterion)
protected void evolveOneGeneration(boolean steadyState, AbstractPopulation.SelectionMethod selectMethod, double[][] inputs, double[] targetOutputs)
public void collectTransmissionInfo(boolean collect)
public void setTransmissionWritingParameters(int frequency, java.lang.String transmissionInfoFile)
frequency
- The frequency with which transmission information is saved (in number of evaluations)transmissionInfoFile
- A pathname describing the file to which transmission information should be writtenpublic java.util.Vector<java.util.Vector<double[]>> getTransmissionInfo()
public double[] getAverageCutDepthCorrelation()
public java.util.Vector<double[]> getAllCutDepthCorrelations()
public java.lang.Object[] ShellSortIndividuals()
public java.lang.Object[] ShellSortIndividuals(double[] objectiveData, boolean sortAscending)
public static java.lang.Object[] ShellSortIndividuals(Individual[] individuals, double[] allFitnesses, AbstractPopulation.FitnessFunction fitnessFunction)
public static java.lang.Object[] ShellSortIndividuals(Individual[] individuals, double[] allFitnesses, boolean sortAscending)
sortAscending
- If true, the Individuals will be sorted from low to high fitness, if false
they will be sorted from high to low. The value chosen for sortAscending may be different for different fitness functions:
for some fitness functions low fitnesses are preferrred; for others high fitnesses are preferred.public double getBestTrainingFitness()
getBestTrainingFitness
in class AbstractPopulation
public double getBestValidationFitness()
getBestValidationFitness
in class AbstractPopulation
public double getAverageTrainingFitness()
getAverageTrainingFitness
in class AbstractPopulation
public double getAverageValidationFitness()
getAverageValidationFitness
in class AbstractPopulation
public double getAverageFitness(double[][] inputs, double[] targetOutputs, boolean recalculateValues) throws InvalidInputSizeException
InvalidInputSizeException
public void setMaximumIndividualLength(int maxLength)
public int getMaximumIndividualLength()
public void setMaximumIndividualDepth(int maxDepth)
public int getMaximumIndividualDepth()
public double getAverageIndividualLength()
public double getDiversity()
public boolean hasNoDiversity()
public Individual getBestIndividual()
public Individual getBestValidatedIndividual()
public void setRankGradient(double gradient)
public double getRankGradient()
public void setBroodUse(boolean useBrood)
public boolean getBroodUse()
public void setKeepDominated(boolean keepDominated)
public boolean getKeepDominated()
public void setTruncationParameters(boolean includeParentsInPool, int numberOfParents, int numberOfOffspring)
public double[] getFitnesses()
public AbstractPopulation.FitnessFunction getFitnessFunction()
public void setFitnessFunction(AbstractPopulation.FitnessFunction func)
public void setPerformanceFunctions(Population.PerformanceFunction[] perfFuncs, boolean isMultiObjective)
public boolean setSingleObjectiveRatio(double[] ratio)
public Population.PerformanceFunction[] getPerformanceFunctions()
public boolean getMultiObjective()
public void setCrossover(Crossover newCross)
public Crossover getCrossover()
public void setMutation(Mutation newMut)
public Mutation getMutation()
public double getAverageComplexity()
public final double[][] getAllSquaredDistances(boolean recalculate)
public final double[][] getSquaredDistances(int[] indices, boolean recalculate)
public double getAverageSquaredDistance(int index)
public double getAverageSquaredDistance(int index, Individual newInd)
public double getAverageSquaredDistance(Individual ind)
public void setFitnessShare(FitnessShare fitnessShare, FitnessShare.ShareType shareType)
fitnessShare
- The FitnessSahre object that determines how fitness sharing will operate.shareType
- determines whether fitness sharing will occur over the genotype (tree structural similarity) or the phenotype (fitness)public FitnessShare getFitnessShare()
public FitnessShare.ShareType getShareType()
public void setShareWeightings(double[] weightings, boolean isMultiObjectivelyShared)
public double[] getShareWeightings()
protected void removeDominatedIndividuals()
protected void removeDuplicatedIndividuals()
protected void savePopulation()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |