|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectec.Individual
ec.rule.RuleIndividual
public class 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.
From ec.Individual:
In addition to serialization for checkpointing, Individuals may read and write themselves to streams in three ways.
In general, the various readers and writers do three things: they tell the Fitness to read/write itself, they read/write the evaluated flag, and they read/write the Rulesets. If you add instance variables to a RuleIndividual or subclass, you'll need to read/write those variables as well.
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 |
P_NUMRULESETS
|
static java.lang.String |
P_RULESET
|
RuleSet[] |
rulesets
The individual's rulesets. |
| Fields inherited from class ec.Individual |
|---|
birthday, count, evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species |
| Constructor Summary | |
|---|---|
RuleIndividual()
|
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context. |
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 |
mutate(EvolutionState state,
int thread)
Mutates the Individual. |
void |
parseGenotype(EvolutionState state,
java.io.LineNumberReader reader)
Overridden for the RuleIndividual genotype. |
void |
postprocessIndividual(EvolutionState state,
int thread)
Called by pipelines after they've modified the individual and it might need to be "fixed" -- basically a hook for you to override. |
void |
preprocessIndividual(EvolutionState state,
int thread)
Called by pipelines before they've modified the individual and it might need to be "fixed" -- basically a hook for you to override. |
void |
printIndividual(EvolutionState state,
int log)
Should print the individual in a way that can be read by computer, including its fitness, with a verbosity of Output.V_NO_GENERAL. |
void |
printIndividual(EvolutionState state,
java.io.PrintWriter writer)
Overridden for the RuleIndividual genotype, writing each ruleset in turn. |
void |
printIndividualForHumans(EvolutionState state,
int log)
Should print the individual out in a pleasing way for humans, with a verbosity of Output.V_NO_GENERAL. |
void |
readGenotype(EvolutionState state,
java.io.DataInput dataInput)
Overridden for the RuleIndividual genotype. |
void |
reset(EvolutionState state,
int thread)
|
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. |
long |
size()
Returns the "size" of the individual. |
void |
writeGenotype(EvolutionState state,
java.io.DataOutput dataOutput)
Overridden for the RuleIndividual genotype, writing each ruleset in turn. |
| Methods inherited from class ec.Individual |
|---|
compareTo, distanceTo, genotypeToString, genotypeToStringForHumans, printIndividual, printIndividualForHumans, readIndividual, readIndividual, toString, writeIndividual |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String P_RULESET
public static final java.lang.String P_NUMRULESETS
public RuleSet[] rulesets
| Constructor Detail |
|---|
public RuleIndividual()
| Method Detail |
|---|
public Parameter defaultBase()
Prototype
public java.lang.Object clone()
PrototypeTypically 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;
}
clone in interface Prototypeclone in class Individual
public void preprocessIndividual(EvolutionState state,
int thread)
public void postprocessIndividual(EvolutionState state,
int thread)
public boolean equals(java.lang.Object ind)
Individual
equals in class Individualpublic int hashCode()
Individual
hashCode in class Individual
public void setup(EvolutionState state,
Parameter base)
PrototypeFor 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.
setup in interface Prototypesetup in interface Setupsetup in class Individual
public void printIndividualForHumans(EvolutionState state,
int log)
Individual
printIndividualForHumans in class Individual
public void printIndividual(EvolutionState state,
int log)
Individual
printIndividual in class Individual
public void printIndividual(EvolutionState state,
java.io.PrintWriter writer)
printIndividual in class Individual
public void writeGenotype(EvolutionState state,
java.io.DataOutput dataOutput)
throws java.io.IOException
writeGenotype in class Individualjava.io.IOException
public void readGenotype(EvolutionState state,
java.io.DataInput dataInput)
throws java.io.IOException
readGenotype in class Individualjava.io.IOException
public void parseGenotype(EvolutionState state,
java.io.LineNumberReader reader)
throws java.io.IOException
parseGenotype in class Individualjava.io.IOExceptionpublic long size()
Individual
size in class Individual
public void reset(EvolutionState state,
int thread)
public void mutate(EvolutionState state,
int thread)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||