public abstract class AbstractRepresentation extends AbstractComponent implements java.lang.Comparable<AbstractRepresentation>
Each representation must be evolvable meaning it has to implement the necessary mutation and recombination functions.
Constructor and Description |
---|
AbstractRepresentation(int numberOfInputs,
int numberOfOutputs,
NESRandom random,
java.util.Hashtable<java.lang.String,XMLFieldEntry> properties)
Constructs a new representation with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
AbstractRepresentation |
clone()
Returns a clone of this representation in a form of a deep copy.
|
int |
compareTo(AbstractRepresentation other)
Compares this representation to another one based on their fitness values.
|
abstract double |
diffTo(AbstractRepresentation representation)
Compares this representation to another one.
|
abstract void |
exportToFile(java.io.File saveFile)
Exports the content of this representation to a file.
|
abstract org.dom4j.Element |
exportToXmlElement(org.dom4j.Element element)
Exports this representation and all its necessary data to the provided XML element.
|
abstract java.util.Hashtable<java.lang.String,java.lang.String> |
getDetails()
Returns a table of key-value pairs that describes this representation.
|
double |
getFitness()
Returns the fitness value of this representation.
|
abstract int |
getNumberofMutationFunctions()
Returns the number of implemented mutation functions.
|
abstract int |
getNumberOfRecombinationFunctions()
Returns the number of implemented crossover functions.
|
abstract java.util.ArrayList<java.lang.Float> |
getOutput(java.util.ArrayList<java.lang.Float> input)
Processes the given list of inputs and returns the corresponding output values.
|
abstract java.lang.String |
getUniqueName()
Returns a unique name of this representation calculated by its parameters/structure.
|
boolean |
isEvaluated()
Returns the state if this representation has been already evaluated.
|
abstract AbstractRepresentation |
loadFromXML(org.dom4j.Node node)
Reconstructs this representation from the given XML node.
|
void |
mutate(float severity,
float probability,
int method)
Initiates a mutation on this representation with the given parameters.
|
abstract void |
reset()
Resets the representation to its base state.
|
void |
setFitness(double fitness)
Sets the fitness of this representation to the given value.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
void |
xOverWith(AbstractRepresentation other,
int method)
Modifies this representation based on the implemented recombination function and the provided parameters.
|
getProperties, getPropertyValue, getTypeOfProperty, getXMLData, setProperties, setXMLData
public AbstractRepresentation(int numberOfInputs, int numberOfOutputs, NESRandom random, java.util.Hashtable<java.lang.String,XMLFieldEntry> properties)
numberOfInputs
- Number of input connectorsnumberOfOutputs
- Number of output connectorsrandom
- The random generator object used to construct this representationproperties
- The set of properties as they are defined in the component's XML descriptor filepublic final boolean isEvaluated()
public final double getFitness() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if this representation has not been evaluated.AbstractRepresentation#isEvaluated isEvaluated} to check if a fitness value is already calculated.
public final void setFitness(double fitness)
fitness
- The new fitness value.public abstract void exportToFile(java.io.File saveFile)
saveFile
- The file to be saved topublic final void mutate(float severity, float probability, int method)
severity
- Should be between 0..1, interpreted by the representation.probability
- Should be between 0..1, probability for one genome to be mutated.method
- Selected mutation method. Use getNumberofMutationFunctions()
to obtain the number of implemented methods.public final void xOverWith(AbstractRepresentation other, int method)
other
- The other representation used for the recombination function.method
- Selected recombination method. Use getNumberOfRecombinationFunctions()
to obtain the number of implemented functions.public abstract int getNumberofMutationFunctions()
public abstract int getNumberOfRecombinationFunctions()
public abstract java.util.ArrayList<java.lang.Float> getOutput(java.util.ArrayList<java.lang.Float> input)
input
- The list of input values to be processed.public abstract void reset()
public abstract double diffTo(AbstractRepresentation representation)
representation
- The other representation to compare to.public final AbstractRepresentation clone()
clone
in class java.lang.Object
public abstract org.dom4j.Element exportToXmlElement(org.dom4j.Element element)
loadFromXML(Node)
.element
- The root element to be used for saving.public abstract AbstractRepresentation loadFromXML(org.dom4j.Node node)
node
- The root XML node to load the data from.public abstract java.util.Hashtable<java.lang.String,java.lang.String> getDetails()
public abstract java.lang.String getUniqueName()
public final int compareTo(AbstractRepresentation other)
compareTo
in interface java.lang.Comparable<AbstractRepresentation>
public final java.lang.String toString()
toString
in class java.lang.Object