org.jgap.distr
Class Culture
- java.lang.Object
-
- org.jgap.distr.Culture
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable
public class Culture extends java.lang.Object implements java.io.Serializable, java.lang.ComparableCulture is a memory not being bound to a generation, but possibly persistent during the whole history of a genotype (over all generations). See GPConfiguration for current support of culture with Genetic Programming.Also see http://cs.gmu.edu/~sean/papers/culture-gp96.pdf
- Since:
- 2.3
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Culture(int a_size)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()Clears the memory.intcompareTo(java.lang.Object a_other)The compareTo-method.booleancontains(java.lang.String a_name)Checks if a memory cell with the given name exists.booleanequals(java.lang.Object a_other)The equals-method.CultureMemoryCellget(int a_index)Retrieves the memory cell at the given index.CultureMemoryCellget(java.lang.String a_name)Retrieves the memory cell at the given index.CultureMemoryCellgetMatrix(int a_x, int a_y)Reads a value from the matrix memory that was previously stored with setMatrix(...).java.util.ListgetMemoryNames()CultureMemoryCellset(int a_index, double a_value, int a_historySize, java.lang.String a_name)Sets a memory cell with a given value.CultureMemoryCellset(int a_index, java.lang.Object a_value, int a_historySize, java.lang.String a_infotext)Sets a memory cell with a given value.CultureMemoryCellset(java.lang.String a_name, java.lang.Object a_value, int a_historySize)Sets a memory cell with a given value.CultureMemoryCellsetMatrix(int a_x, int a_y, java.lang.Object a_value)Stores a value in the matrix memory.voidsetMatrixWidth(int a_width)Sets the width of the matrix memory.intsize()java.lang.StringtoString()
-
-
-
Constructor Detail
-
Culture
public Culture(int a_size)
Constructor.- Parameters:
a_size- the size of the memory in cells (CultureMemoryCell instances)- Since:
- 2.3
-
-
Method Detail
-
set
public CultureMemoryCell set(int a_index, double a_value, int a_historySize, java.lang.String a_name)
Sets a memory cell with a given value. The memory cell will be newly created for that.- Parameters:
a_index- index of the memory cella_value- value to set in the memorya_historySize- size of history to use, or less than 1 for turning history offa_name- informative name of the memory cell- Returns:
- newly created memory cell set with the given value
- Since:
- 2.3
-
set
public CultureMemoryCell set(int a_index, java.lang.Object a_value, int a_historySize, java.lang.String a_infotext)
Sets a memory cell with a given value. The memory cell will be newly created for that.- Parameters:
a_index- index of the memory cella_value- value to set in the memorya_historySize- size of history to use, or less than 1 for turning history offa_infotext- informative name of the memory cell- Returns:
- newly created memory cell set with the given value
- Since:
- 3.0
-
set
public CultureMemoryCell set(java.lang.String a_name, java.lang.Object a_value, int a_historySize)
Sets a memory cell with a given value. The memory cell will be newly created for that.- Parameters:
a_name- named index of the memory cella_value- value to set in the memorya_historySize- size of history to use, or less than 1 for turning history off- Returns:
- newly created memory cell set with the given value
- Since:
- 3.0
-
get
public CultureMemoryCell get(int a_index)
Retrieves the memory cell at the given index.- Parameters:
a_index- index of the memory cell to read out- Returns:
- stored memory cell at given index
- Since:
- 2.3
-
get
public CultureMemoryCell get(java.lang.String a_name)
Retrieves the memory cell at the given index.- Parameters:
a_name- name of the memory cell to read out- Returns:
- stored memory cell for given name, or null if name unknown
- Since:
- 3.0
-
contains
public boolean contains(java.lang.String a_name)
Checks if a memory cell with the given name exists.- Parameters:
a_name- the name of the cell to check- Returns:
- true: cell excists
- Since:
- 3.2
-
size
public int size()
- Returns:
- size of the memory
- Since:
- 2.3
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- String representation of the cultural memory
- Since:
- 2.3
-
clear
public void clear()
Clears the memory.- Since:
- 3.0
-
getMemoryNames
public java.util.List getMemoryNames()
- Returns:
- cloned list of symbolic memory names
- Since:
- 3.0
-
equals
public boolean equals(java.lang.Object a_other)
The equals-method.- Overrides:
equalsin classjava.lang.Object- Parameters:
a_other- the other object to compare- Returns:
- true if the objects are regarded as equal
- Since:
- 3.0
-
compareTo
public int compareTo(java.lang.Object a_other)
The compareTo-method.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
a_other- the other object to compare- Returns:
- -1, 0, 1
- Since:
- 3.0
-
setMatrixWidth
public void setMatrixWidth(int a_width)
Sets the width of the matrix memory. Important to call before using setMatrix/getMatrix!- Parameters:
a_width- the width the matrix should have- Since:
- 3.2
-
setMatrix
public CultureMemoryCell setMatrix(int a_x, int a_y, java.lang.Object a_value)
Stores a value in the matrix memory. Use setMatrixWidth(int) beforehand!- Parameters:
a_x- the first coordinate of the matrix (width)a_y- the second coordinate of the matrix (height)a_value- the value to store- Returns:
- created or used memory cell
- Since:
- 3.2
-
getMatrix
public CultureMemoryCell getMatrix(int a_x, int a_y)
Reads a value from the matrix memory that was previously stored with setMatrix(...).- Parameters:
a_x- the first coordinate of the matrix (width)a_y- the second coordinate of the matrix (height)- Returns:
- read value
- Since:
- 3.2
-
-
DMelt 3.0 © DataMelt by jWork.ORG