geneticWedge.gp
Class FitnessShare

java.lang.Object
  extended by geneticWedge.gp.FitnessShare

public class FitnessShare
extends java.lang.Object

The use of a FitnessShare object encourages diversity within a population. It 'shares' the fitness of Individuals that are close together, either genotypically (similar tree structure) or phenotypically (similar fitness), making them less fit. This aims to prevents premature convergence to a small niche.


Nested Class Summary
static class FitnessShare.FitnessShareFunction
          FitnessShareFunction determines the shape of the fitness sharing within a niche.
static class FitnessShare.ShareType
          ShareType determines the function over which sharing is performed
 
Constructor Summary
FitnessShare(double nicheSize, FitnessShare.FitnessShareFunction shareFunction)
          Creates a FitnessShare with a niche size and a FitnessShareFunction.
 
Method Summary
 double getNicheSize()
          Returns the niche size (radius).
 double[] getShareValuesFromMultipleObjectives(double[][] data, double[] weighting)
          This method takes weightings for a multi-objective function as the second input.
 double[] getShareValuesFromSingleObjective(double[] data)
          Returns the share values (degree of sharing) for the data provided.
 double getShareValuesFromSingleObjective(double[] data, int index)
          Returns the share value (degree of sharing) for the particular datum identified by index.
 double[] getShareValuesFromSquaredDistances(double[][] squaredDistances)
          Returns the share values (degree of sharing) for the squared distances provided.
 double getShareValuesFromSquaredDistances(double[][] squaredDistances, int index)
          Returns the share value (degree of sharing) for the particular datum identified by index.
 void setNicheSize(double nicheSize)
          Sets the niche size (radius).
 java.lang.String toString()
          Returns a String representation of this FitnessShare object, identifying its niche size and share function (niche shape)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FitnessShare

public FitnessShare(double nicheSize,
                    FitnessShare.FitnessShareFunction shareFunction)
Creates a FitnessShare with a niche size and a FitnessShareFunction.

Parameters:
shareFunction - This determines the shape of the sharing function.
Method Detail

getShareValuesFromSingleObjective

public double[] getShareValuesFromSingleObjective(double[] data)
Returns the share values (degree of sharing) for the data provided.

Parameters:
data - data should be either fitnesses or average squared genotypic distances, depending whether the ShareType is OBJECTIVE_FUNCTION or GENE_DISTANCE

getShareValuesFromSingleObjective

public double getShareValuesFromSingleObjective(double[] data,
                                                int index)
Returns the share value (degree of sharing) for the particular datum identified by index.

Parameters:
data - data should be either fitnesses or average squared genotypic distances, depending whether the ShareType is OBJECTIVE_FUNCTION or GENE_DISTANCE
index - The index of the target datum within the array data.

setNicheSize

public void setNicheSize(double nicheSize)
Sets the niche size (radius). Only other Individuals within the niche size will affect sharing.


getNicheSize

public double getNicheSize()
Returns the niche size (radius). Only other Individuals within the niche size will affect sharing.


getShareValuesFromMultipleObjectives

public double[] getShareValuesFromMultipleObjectives(double[][] data,
                                                     double[] weighting)
This method takes weightings for a multi-objective function as the second input. The weights are applied by multiplying the components of the distances along each axis. Dimensions that have a small data range should therefore be assigned a large weighting and vice versa.

Weightings may be adjusted dynamically by calling this method. For example, a Population may adjust the weightings to the current ranges of the objectives.


getShareValuesFromSquaredDistances

public double[] getShareValuesFromSquaredDistances(double[][] squaredDistances)
Returns the share values (degree of sharing) for the squared distances provided.

Parameters:
squaredDistances - The distances between all pairs of Individuals. Only the values above the diagonal (2nd dimension greater than 1st dimension) are used.

getShareValuesFromSquaredDistances

public double getShareValuesFromSquaredDistances(double[][] squaredDistances,
                                                 int index)
Returns the share value (degree of sharing) for the particular datum identified by index.

Parameters:
squaredDistances - The distances between all pairs of Individuals
index - The index of the target datum within the array data.

toString

public java.lang.String toString()
Returns a String representation of this FitnessShare object, identifying its niche size and share function (niche shape)

Overrides:
toString in class java.lang.Object