public class GPData extends Object implements Prototype
You can use GPData as-is if you have absolutely no data to transfer between individuals. Otherwise, you need to subclas GPData, add your own instance variables, and then override the copyTo(...) method and, depending on whether the data has pointers in it (like arrays), the clone() method as well.
Default Base
gp.data
Constructor and Description |
---|
GPData() |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
void |
copyTo(GPData gpd)
Modifies gpd so that gpd is equivalent to us.
|
Parameter |
defaultBase()
Returns the default base for this prototype.
|
void |
setup(EvolutionState state,
Parameter base)
Sets up the object by reading it from the parameters stored
in state, built off of the parameter base base.
|
public static final String P_GPDATA
public void copyTo(GPData gpd)
public Parameter defaultBase()
Prototype
defaultBase
in interface Prototype
public void setup(EvolutionState state, Parameter base)
Prototype
For prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
public Object clone()
Prototype
Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
Copyright © 2019. All rights reserved.