[6152] | 1 | This package contains classes for representations of the form of arbitrary |
---|
| 2 | collections of objects. One common use of such collections would be as |
---|
| 3 | bags of "rules", hence the name. However there's no reason you couldn't use |
---|
| 4 | any kind of object here. Also don't be put off by the name "ruleset" -- it's |
---|
| 5 | not a set of rules, it's a collection (a bag, a multiset) of objects, that is, |
---|
| 6 | there's no reason the object can't appear more than one time. |
---|
| 7 | |
---|
| 8 | The package is very straightforward. A RuleIndividual contains a fixed-length |
---|
| 9 | array of RuleSets. Each RuleSet is an arbitrary-length array of Rules. |
---|
| 10 | A Rule is the superclass of your basic object. |
---|
| 11 | |
---|
| 12 | RuleIndividuals must belong to RuleSpecies (or a subclass), which does trivial |
---|
| 13 | checks. Various RuleSets are associated with a RuleSetConstraints object |
---|
| 14 | in which they can store common information. Presently RuleSetConstraints |
---|
| 15 | specify: |
---|
| 16 | |
---|
| 17 | - the minimum number of rules allowed in the RuleSet upon initialization |
---|
| 18 | - the maximum number of rules allowed in the RuleSet upon initialization |
---|
| 19 | or |
---|
| 20 | - a distribution from which the number of rules is drawn |
---|
| 21 | |
---|
| 22 | Additionally: |
---|
| 23 | |
---|
| 24 | - The probability that new rules will be added upon mutation |
---|
| 25 | - The probability that new rules will be deleted upon mutation |
---|
| 26 | - The probability the rules will be randomized in order upon mutation |
---|
| 27 | |
---|
| 28 | You're welcome to modify this as you see fit of course. Rules are likewise |
---|
| 29 | associated with RuleConstraints in which they can store common information |
---|
| 30 | (presently nothing is stored). |
---|
| 31 | |
---|
| 32 | To set up the constraints objects, the rule package requires that your |
---|
| 33 | initializer be a subclass of RuleInitializer. |
---|
| 34 | |
---|
| 35 | The 'breed' directory contains two breeding pipelines which might be of use. |
---|
| 36 | RuleCrossover trades rules among rulesets using the following algorithm: |
---|
| 37 | |
---|
| 38 | For i from 1 to the number of rulesets |
---|
| 39 | r1 = ruleset i in individual A |
---|
| 40 | r2 = ruleset i in individual B |
---|
| 41 | For each rule in r1 |
---|
| 42 | With a given probability, |
---|
| 43 | mark that rule to go to r2 |
---|
| 44 | For each rule in r2 |
---|
| 45 | With a given probability, |
---|
| 46 | mark that rule to go to r1 |
---|
| 47 | Exchange marked rules between r1 and r2 |
---|
| 48 | |
---|
| 49 | You specify the rule exchange probability. The RuleMutation operator simply |
---|
| 50 | calls mutateRules() on all the rulesets. The default mutateRules() function |
---|
| 51 | first calls mutate() on al the rules in the ruleset. It then deletes rules from |
---|
| 52 | the ruleset with a certain probability. It then adds new rules to the ruleset |
---|
| 53 | with a certain probability. Finally it randomizes the rule order of the ruleset |
---|
| 54 | with a certain probability. |
---|