public class RuleSet extends java.lang.Object implements Prototype
Besides the Rules themselves, the only thing else a RuleSet contains is a pointer to a corresponding RuleSetConstraints object, which holds all of its modification parameters. See RuleSetConstraints for a description of these parameters.
In addition to serialization for checkpointing, RuleSets may read and write themselves to streams in three ways.
Parameters
base.constraints string |
(name of the rule set constraints) |
Default Base
rule.ruleset
Modifier and Type | Field and Description |
---|---|
byte |
constraints
An index to a RuleSetConstraints
|
static java.lang.String |
N_RULES
The message to appear when printing the rule set
|
int |
numRules
How many rules are there used in the rules array
|
static java.lang.String |
P_CONSTRAINTS
The constraint for the rule set
|
static java.lang.String |
P_RULESET |
Rule[] |
rules
The rules in the rule set
|
Constructor and Description |
---|
RuleSet() |
Modifier and Type | Method and Description |
---|---|
void |
addRandomRule(EvolutionState state,
int thread)
Add a random rule to the rule set
|
void |
addRule(Rule rule)
Add a rule directly to the rule set.
|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
RuleSetConstraints |
constraints(RuleInitializer initializer) |
void |
copyNoClone(RuleSet other)
Clears out existing rules, and loads the rules from the other ruleset without cloning them.
|
Parameter |
defaultBase()
Returns the default base for this prototype.
|
boolean |
equals(java.lang.Object _other) |
int |
hashCode()
The hash code for the rule set.
|
void |
join(RuleSet other)
Makes a copy of the rules in another RuleSet and adds the rule copies.
|
void |
mutate(EvolutionState state,
int thread)
Mutates rules in the RuleSet independently with the given probability.
|
int |
numRules()
How many rules are there used in the rules array
|
void |
postprocessRules(EvolutionState state,
int thread)
Should be called by pipelines to "fix up" the rulesets after they have been
mutated or crossed over.
|
void |
preprocessRules(EvolutionState state,
int thread)
Should be called by pipelines to "fix up" the rulesets before they have been
mutated or crossed over.
|
void |
printRuleSet(EvolutionState state,
int log)
Prints the rule set such that the computer can read it later
|
void |
printRuleSet(EvolutionState state,
int log,
int verbosity)
Deprecated.
Verbosity no longer has an effect
|
void |
printRuleSet(EvolutionState state,
java.io.PrintWriter writer)
Prints the rule set such that the computer can read it later
|
void |
printRuleSetForHumans(EvolutionState state,
int log)
Prints out the rule set in a readable fashion.
|
void |
printRuleSetForHumans(EvolutionState state,
int log,
int verbosity)
Deprecated.
Verbosity no longer has an effect
|
void |
randomizeRulesOrder(EvolutionState state,
int thread)
Randomizes the order of the rules in the rule set.
|
void |
readRuleSet(EvolutionState state,
java.io.DataInput dataInput)
Reads RuleSets in from a binary stream
|
void |
readRuleSet(EvolutionState state,
java.io.LineNumberReader reader)
Reads the rule set
|
Rule |
removeRandomRule(EvolutionState state,
int thread)
Removes a randomly-chosen rule from the rule set and returns it.
|
Rule |
removeRule(int index)
Removes a rule from the rule set and returns it.
|
void |
reset(EvolutionState state,
int thread)
A reset method for randomly reinitializing the RuleSet
|
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.
|
RuleSet[] |
split(EvolutionState state,
int thread,
RuleSet[] sets)
Splits the rule set into a number of disjoint rule sets, copying the rules and adding
them to the sets as appropriate.
|
RuleSet[] |
split(int[] points,
RuleSet[] sets)
Splits the rule set into n pieces, according to points, which *must* be sorted.
|
RuleSet[] |
splitIntoTwo(EvolutionState state,
int thread,
RuleSet[] sets,
double prob)
Splits the rule set into a two disjoint rule sets, copying the rules and adding
them to the sets as appropriate.
|
void |
writeRuleSet(EvolutionState state,
java.io.DataOutput dataOutput)
Writes RuleSets out to a binary stream
|
public static final java.lang.String N_RULES
public static final java.lang.String P_RULESET
public static final java.lang.String P_CONSTRAINTS
public byte constraints
public Rule[] rules
public int numRules
public final RuleSetConstraints constraints(RuleInitializer initializer)
public java.lang.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;
}
public int numRules()
public void reset(EvolutionState state, int thread)
public void mutate(EvolutionState state, int thread)
public void preprocessRules(EvolutionState state, int thread)
public void postprocessRules(EvolutionState state, int thread)
public void randomizeRulesOrder(EvolutionState state, int thread)
public void addRandomRule(EvolutionState state, int thread)
public void addRule(Rule rule)
public Rule removeRule(int index)
public Rule removeRandomRule(EvolutionState state, int thread)
public void join(RuleSet other)
public void copyNoClone(RuleSet other)
public RuleSet[] split(int[] points, RuleSet[] sets)
public RuleSet[] split(EvolutionState state, int thread, RuleSet[] sets)
public RuleSet[] splitIntoTwo(EvolutionState state, int thread, RuleSet[] sets, double prob)
public void printRuleSetForHumans(EvolutionState state, int log)
public void printRuleSetForHumans(EvolutionState state, int log, int verbosity)
public void printRuleSet(EvolutionState state, int log)
public void printRuleSet(EvolutionState state, int log, int verbosity)
public void printRuleSet(EvolutionState state, java.io.PrintWriter writer)
public void readRuleSet(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException
java.io.IOException
public void writeRuleSet(EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
java.io.IOException
public void readRuleSet(EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
java.io.IOException
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 int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object _other)
equals
in class java.lang.Object