ec.rule
Class RuleSetConstraints

java.lang.Object
  extended by ec.rule.RuleSetConstraints
All Implemented Interfaces:
Clique, Setup, java.io.Serializable

public class RuleSetConstraints
extends java.lang.Object
implements Clique

RuleSetConstraints is an basic class for constraints applicable to rulesets. There are two categories of parameters associated with this class. First, there are parameters which guide the initial number of rules to be created when a ruleset is initialized for the first time, or totally reset. Second, there are parameters which indicate how rulesets are to be mutated under the "default" rule mutation operator.

First the initialization parameters. You need to specify a distribution from which the system will pick random integer values X. When a ruleset is to be initialized, a random value X is picked from this distribution, and the ruleset will be created with X initial rules. You can specify the distribution in one of two ways. First, you can specify a minimum and maximum number of rules; the system will then pick an X uniformly from between the min and the max. Second, you can specify a full distribution of size probabilities for more control. For example, to specify that the system should make individuals with 0 rules 0.1 of the time, 1 rule 0.2 of the time, and 2 rules 0.7 of the time, you set reset-num-sizes to 3 (for rule sizes up to but not including 3), and then set reset-size.0 to 0.1, reset-size.1 to 0.2, and reset-size.2 to 0.7.

Next the mutation parameters. The default mutation procedure works as follows. First, every rule in the ruleset is mutated. It is up to the rule to determine by how much or whether it will be mutated (perhaps by flipping a coin) when its mutate function is called. Second, the system repeatedly flips a coin with "p-del" probability of being true, until it comes up false. The number of times it came up true is the number of rules to remove from the ruleset; rules to be removed are chosen at random. Third, the system repeatedly flips a coin with "p-add" probability of being true, until it comes up false. The number of times it came up true is the number of new randomly-generated rules to add to the ruleset; rules are added to the end of the array. Fourth, with "p-rand-order" probability, the order of rules in the ruleset array is randomized; this last item might or might not matter to you depending on whether or not your rule interpreter differs depending on rule order.

Version:
1.0

Parameters

base.size
int >= 1
(number of rule set constraints)
base.n.name
String
(name of rule set constraint n)
base.n.reset-min-size
int >= 0 (default=0)
(for rule set constraint n, the minimum number of rules that rulesets may contain upon initialization (resetting), see discussion above)
base.n.reset-max-size
int >= base.n.reset-min-size (default=0)
(for rule set constraint n, the maximum number of rules that rulesets may contain upon initialization (resetting), see discussion above)
base.n.reset-num-sizes
int >= 0 (default=unset)
(for rule set constraint n, the number of sizes in the size distribution for initializtion, see discussion above)
base.n.reset-size.i
0.0 <= float <= 1.0
(for rule set constraint n, the probability that i will be chosen as the number of rules upon initialization, see discussion above)
base.n.p-add
0.0 <= float <= 1.0
(the probability that a new rule will be added, see discussion)
base.n.p-del
0.0 <= float <= 1.0
(the probability that a rule will be deleted, see discussion)
base.n.p-rand-order
0.0 <= float <= 1.0
(the probability that the rules' order will be randomized, see discussion)
Author:
Liviu Panait and Sean Luke
See Also:
Serialized Form

Field Summary
static int CHECK_BOUNDARY
           
 byte constraintNumber
          The byte value of the constraints -- we can only have 256 of them
 int maxSize
           
 int minSize
           
 java.lang.String name
          The name of the RuleSetConstraints object
 float p_add
           
static java.lang.String P_ADD_PROB
           
 float p_del
           
static java.lang.String P_DEL_PROB
           
static java.lang.String P_MAXSIZE
           
static java.lang.String P_MINSIZE
           
static java.lang.String P_NAME
           
static java.lang.String P_NUMSIZES
           
static java.lang.String P_RAND_ORDER_PROB
           
 float p_randorder
           
static java.lang.String P_RESETMAXSIZE
           
static java.lang.String P_RESETMINSIZE
           
static java.lang.String P_RESETSIZE
           
static java.lang.String P_RULE
           
static java.lang.String P_SIZE
          num rulesets
 int resetMaxSize
           
 int resetMinSize
           
 Rule rulePrototype
          The prototype of the Rule that will be used in the RuleSet (the RuleSet contains only rules with the specified prototype).
static int SIZE_OF_BYTE
          The size of a byte
 float[] sizeDistribution
           
 
Constructor Summary
RuleSetConstraints()
           
 
Method Summary
static RuleSetConstraints constraintsFor(java.lang.String constraintsName, EvolutionState state)
          You must guarantee that after calling constraintsFor(...) one or several times, you call state.output.exitIfErrors() once.
 int numRulesForReset(RuleSet ruleset, EvolutionState state, int thread)
          Returns a stochastic value picked to specify the number of rules to generate when calling reset() on this kind of Rule.
 int pickSize(EvolutionState state, int thread)
          Assuming that either resetMinSize and resetMaxSize, or sizeDistribution, is defined, picks a random size from resetMinSize...resetMaxSize inclusive, or randomly from sizeDistribution.
 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.
 java.lang.String toString()
          Converting the rule to a string ( the name )
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZE_OF_BYTE

public static final int SIZE_OF_BYTE
The size of a byte

See Also:
Constant Field Values

P_NAME

public static final java.lang.String P_NAME
See Also:
Constant Field Values

P_SIZE

public static final java.lang.String P_SIZE
num rulesets

See Also:
Constant Field Values

P_RULE

public static final java.lang.String P_RULE
See Also:
Constant Field Values

CHECK_BOUNDARY

public static final int CHECK_BOUNDARY
See Also:
Constant Field Values

P_RESETMINSIZE

public static final java.lang.String P_RESETMINSIZE
See Also:
Constant Field Values

P_RESETMAXSIZE

public static final java.lang.String P_RESETMAXSIZE
See Also:
Constant Field Values

P_NUMSIZES

public static final java.lang.String P_NUMSIZES
See Also:
Constant Field Values

P_RESETSIZE

public static final java.lang.String P_RESETSIZE
See Also:
Constant Field Values

P_MINSIZE

public static final java.lang.String P_MINSIZE
See Also:
Constant Field Values

P_MAXSIZE

public static final java.lang.String P_MAXSIZE
See Also:
Constant Field Values

minSize

public int minSize

maxSize

public int maxSize

resetMinSize

public int resetMinSize

resetMaxSize

public int resetMaxSize

sizeDistribution

public float[] sizeDistribution

P_ADD_PROB

public static final java.lang.String P_ADD_PROB
See Also:
Constant Field Values

p_add

public float p_add

P_DEL_PROB

public static final java.lang.String P_DEL_PROB
See Also:
Constant Field Values

p_del

public float p_del

P_RAND_ORDER_PROB

public static final java.lang.String P_RAND_ORDER_PROB
See Also:
Constant Field Values

p_randorder

public float p_randorder

rulePrototype

public Rule rulePrototype
The prototype of the Rule that will be used in the RuleSet (the RuleSet contains only rules with the specified prototype).


constraintNumber

public byte constraintNumber
The byte value of the constraints -- we can only have 256 of them


name

public java.lang.String name
The name of the RuleSetConstraints object

Constructor Detail

RuleSetConstraints

public RuleSetConstraints()
Method Detail

pickSize

public int pickSize(EvolutionState state,
                    int thread)
Assuming that either resetMinSize and resetMaxSize, or sizeDistribution, is defined, picks a random size from resetMinSize...resetMaxSize inclusive, or randomly from sizeDistribution.


numRulesForReset

public int numRulesForReset(RuleSet ruleset,
                            EvolutionState state,
                            int thread)
Returns a stochastic value picked to specify the number of rules to generate when calling reset() on this kind of Rule. The default version picks from the min/max or distribution, but you can override this to do whatever kind of thing you like here.


toString

public java.lang.String toString()
Converting the rule to a string ( the name )

Overrides:
toString in class java.lang.Object

constraintsFor

public static RuleSetConstraints constraintsFor(java.lang.String constraintsName,
                                                EvolutionState state)
You must guarantee that after calling constraintsFor(...) one or several times, you call state.output.exitIfErrors() once.


setup

public void setup(EvolutionState state,
                  Parameter base)
Description copied from interface: Setup
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.

Specified by:
setup in interface Setup