|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ec.Individual | +--ec.rule.RuleIndividual
RuleIndividual is an Individual with an array of RuleSets, each of which is a set of Rules. RuleIndividuals belong to some subclass of RuleSpecies (or just RuleSpecies itself).
RuleIndividuals really have basically one parameter: the number of RuleSets to use. This is determined by the num-rulesets parameter.
Parameters
base.num-rulesets int >= 1 |
(number of rulesets used) |
base.ruleset.n Classname, subclass of or = ec.rule.RuleSet |
(class of ruleset n) |
Parameter bases
base.ruleset.n | RuleSet n |
Default Base
rule.individual
Field Summary | |
static java.lang.String |
EVALUATED_PREAMBLE
|
static java.lang.String |
P_INDIVIDUAL
|
static java.lang.String |
P_NUMRULESETS
|
static java.lang.String |
P_RULESET
|
RuleSet[] |
rulesets
The individual's rulesets. |
Fields inherited from class ec.Individual |
evaluated, fitness, species |
Constructor Summary | |
RuleIndividual()
|
Method Summary | |
Parameter |
defaultBase()
Returns the default base for this prototype. |
boolean |
equals(java.lang.Object ind)
Returns true if I am genetically "equal" to ind. |
int |
hashCode()
Returns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code. |
void |
printIndividual(EvolutionState state,
int log,
int verbosity)
Should print the individual in a way that can be read by computer, including its fitness, using state.output.println(...,verbosity,log) You can get fitness to print itself at the appropriate time by calling fitness.printFitness(state,log,verbosity); |
void |
printIndividual(EvolutionState state,
java.io.PrintWriter writer)
Should print the individual in a way that can be read by computer, including its fitness. |
void |
printIndividualForHumans(EvolutionState state,
int log,
int verbosity)
Should print the individual out in a pleasing way for humans, including its fitness, using state.output.println(...,verbosity,log) You can get fitness to print itself at the appropriate time by calling fitness.printFitnessForHumans(state,log,verbosity); |
java.lang.Object |
protoClone()
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context. |
void |
readIndividual(EvolutionState state,
java.io.LineNumberReader reader)
Doesn't read in the species |
void |
reset(EvolutionState state,
int thread)
|
void |
setup(EvolutionState state,
Parameter base)
This should be used to set up only those things which you share in common with all other individuals in your species; individual-specific items which make you you should be filled in by Species.newIndividual(...), and modified by breeders. |
long |
size()
Returns the "size" of the individual. |
Methods inherited from class ec.Individual |
deepClone, protoCloneSimple |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String P_RULESET
public static final java.lang.String P_NUMRULESETS
public static final java.lang.String P_INDIVIDUAL
public static final java.lang.String EVALUATED_PREAMBLE
public RuleSet[] rulesets
Constructor Detail |
public RuleIndividual()
Method Detail |
public Parameter defaultBase()
Prototype
public java.lang.Object protoClone() throws java.lang.CloneNotSupportedException
Prototype
The question here is whether or not this means to perform a "deep" or "light" ("shallow") clone, or something in-between. You may need to deep-clone parts of your object rather than simply copying their references, depending on the situation:
Implementations.
public Object protoClone() throws CloneNotSupportedException
{
return super.clone();
}
public Object protoClone() throws CloneNotSupportedException
{
myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
// ...you should use protoClone and not
// protoCloneSimple to clone subordinate objects...
return myobj;
}
public Object protoClone() throws CloneNotSupportedException
{
MyObject myobj = (MyObject)(super.protoClone());
// put your deep-cloning code here...
// ...you should use protoClone and not
// protoCloneSimple to clone subordinate objects...
return myobj;
}
If you know that your superclasses will never change their protoClone() implementations, you might try inlining them in your overridden protoClone() method. But this is dangerous (though it yields a small net increase).
In general, you want to keep your deep cloning to an absolute minimum, so that you don't have to call protoClone() but one time.
The approach taken here is the fastest that I am aware of while still permitting objects to be specified at runtime from a parameter file. It would be faster to use the "new" operator; but that would require hard-coding that we can't do. Although using java.lang.Object.clone() entails an extra layer that deals with stripping away the "protected" keyword and also wrapping the exception handling (which is a BIG hit, about three times as slow as using "new"), it's still MUCH faster than using java.lang.Class.newInstance(), and also much faster than rolling our own Clone() method.
protoClone
in class Individual
public boolean equals(java.lang.Object ind)
Individual
equals
in class Individual
public int hashCode()
Individual
hashCode
in class Individual
public void setup(EvolutionState state, Parameter base)
Individual
setup
in class Individual
ec.Individual
Prototype.setup(EvolutionState,Parameter)
public void printIndividualForHumans(EvolutionState state, int log, int verbosity)
Individual
printIndividualForHumans
in class Individual
public void printIndividual(EvolutionState state, int log, int verbosity)
Individual
printIndividual
in class Individual
public void printIndividual(EvolutionState state, java.io.PrintWriter writer)
Individual
printIndividual
in class Individual
public void readIndividual(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException, java.lang.CloneNotSupportedException
readIndividual
in class Individual
public long size()
Individual
size
in class Individual
public void reset(EvolutionState state, int thread)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |