gpalta.core
Class FitnessClassic

java.lang.Object
  extended by gpalta.core.FitnessClassic
All Implemented Interfaces:
Fitness, java.io.Serializable, java.lang.Cloneable

public class FitnessClassic
extends java.lang.Object
implements Fitness, java.io.Serializable, java.lang.Cloneable

Implementation of the classic fitness used in GP (MSE)

See Also:
Serialized Form

Constructor Summary
FitnessClassic()
           
 
Method Summary
 void assign(Individual ind, double[] fit)
           
 double[] calculate(Output outputs, Individual ind, ProblemData problemData, int[] wSamples)
          Calculate the fitness for an Individual, given its outputs (the Individual is already evaluated).
 java.lang.Object clone()
          Make a copy This method must be implemented cloned instances must be independent.
 Output getProcessedOutput(Output raw, ProblemData problemData)
          Take the output of an Individual and add anything the fitness might need to add, like statistics or aditional calculations related to the fitness.
 void init(Config config, ProblemData problemData, Output desiredOutputs, double[] weights)
          Initializes the Fitness, receiving the desired outputs and the wheights (importance) for each sample.
 void init(Config config, ProblemData problemData, java.lang.String fileName)
          Initializes the Fitness, reading desired outputs from file
 void setCallingThread(int wThread)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FitnessClassic

public FitnessClassic()
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Fitness
Make a copy This method must be implemented cloned instances must be independent.

Specified by:
clone in interface Fitness
Overrides:
clone in class java.lang.Object
Returns:
Throws:
java.lang.CloneNotSupportedException

setCallingThread

public void setCallingThread(int wThread)
Specified by:
setCallingThread in interface Fitness

init

public void init(Config config,
                 ProblemData problemData,
                 java.lang.String fileName)
Description copied from interface: Fitness
Initializes the Fitness, reading desired outputs from file

Specified by:
init in interface Fitness
Parameters:
config - The evolution config, might be needed inside the Fitness
problemData - The current problem's data, might also be needed (for instance to know the numer of samples used)
fileName - The file to read

init

public void init(Config config,
                 ProblemData problemData,
                 Output desiredOutputs,
                 double[] weights)
Description copied from interface: Fitness
Initializes the Fitness, receiving the desired outputs and the wheights (importance) for each sample.

Specified by:
init in interface Fitness
Parameters:
config - The evolution config, might be needed inside the Fitness
problemData - The current problem's data, might also be needed (for instance to know the number of samples used)
desiredOutputs - The desired outputs
weights - The weight (importance) of each sample

calculate

public double[] calculate(Output outputs,
                          Individual ind,
                          ProblemData problemData,
                          int[] wSamples)
Description copied from interface: Fitness
Calculate the fitness for an Individual, given its outputs (the Individual is already evaluated). The fitness value is stored in the individual

Specified by:
calculate in interface Fitness
Parameters:
outputs - The output of the Individual
ind - The Individual.
problemData - The problem's data (might be needed to calculate the fitness)

assign

public void assign(Individual ind,
                   double[] fit)
Specified by:
assign in interface Fitness

getProcessedOutput

public Output getProcessedOutput(Output raw,
                                 ProblemData problemData)
Description copied from interface: Fitness
Take the output of an Individual and add anything the fitness might need to add, like statistics or aditional calculations related to the fitness.

Specified by:
getProcessedOutput in interface Fitness
Parameters:
raw - The "raw" output of the individual
problemData - The data to evaluate on
Returns:
A specialized output for the problem