1 | This package, and the 'breed' subpackage contained inside, implement basic |
---|
2 | vector representations common in evolution |
---|
3 | strategies and genetic algorithms. The package is straightforward. There |
---|
4 | are various VectorIndividuals, each with an associated VectorSpecies that |
---|
5 | it uses to maintain certain constraints (such as the minimum and maximum |
---|
6 | gene values in the vector). |
---|
7 | |
---|
8 | VectorIndividuals can be used with any breeding pipeline you care to design, |
---|
9 | but since certain crossover and mutation methods are so common, the individuals |
---|
10 | themselves implement those methods, and the VectorMutationPipeline and |
---|
11 | VectorCrossoverPipeline are designed not to perform those methods but simply |
---|
12 | to trigger the individuals into performing it themselves. Thus if you |
---|
13 | want to create a custom crossover procedure that's different from the |
---|
14 | standard ones, you can do so simply by overriding the appropriate |
---|
15 | defaultCrossover() method in the individual class, rather than making |
---|
16 | a new pipeline. |
---|
17 | |
---|
18 | VectorIndividuals also have significant numbers of hooks for variable-length |
---|
19 | vector representations. |
---|
20 | |
---|
21 | Note that there are different VectorIndividuals for different basic types. For |
---|
22 | example, there's a BitVectorIndividual and a FloatVectorIndividual, etc. |
---|
23 | This doesn't use Java's generics facility. Why? Because Java's generics |
---|
24 | are *extremely* slow. They simplify the implementation of code like this but |
---|
25 | at a very very high cost, and so ECJ just breaks out the individuals on a per- |
---|
26 | type basis for efficiency purposes. |
---|
27 | |
---|
28 | The various vector representations and their associated species and basic |
---|
29 | types are: |
---|
30 | |
---|
31 | INDIVIDUAL SPECIES BASIC TYPE |
---|
32 | BitVectorIndividual VectorSpecies boolean |
---|
33 | ByteVectorIndividual IntegerVectorSpecies byte |
---|
34 | ShortVectorIndividual IntegerVectorSpecies short |
---|
35 | IntegerVectorIndividual IntegerVectorSpecies int |
---|
36 | LongVectorIndividual IntegerVectorSpecies long |
---|
37 | FloatVectorIndividual FloatVectorSpecies float |
---|
38 | DoubleVectorIndividual FloatVectorSpecies double |
---|
39 | GeneVectorIndividual GeneVectorSpecies VectorGene |
---|
40 | |
---|
41 | |
---|
42 | Some items to note about certain species: |
---|
43 | |
---|
44 | |
---|
45 | ec.vector.VectorSpecies |
---|
46 | |
---|
47 | This is the superclass of all vector species, and defines three kinds of |
---|
48 | crossover: one-point, two-point, and uniform crossover (referred to as 'any'), |
---|
49 | with a per-gene crossover probability for uniform crossover. Additionally, |
---|
50 | a mutation probability specifies a per-gene likelihood of performing |
---|
51 | mutation on that gene (the kind of mutation depends on the particular |
---|
52 | vector individual being used). |
---|
53 | |
---|
54 | VectorSpecies also allows you to specify a *chunk size*. Chunks are regions |
---|
55 | in which no crossover is allowed. Crossover only occurs on chunk boundaries. |
---|
56 | This allows you, for example, to indicate that an individual consists of |
---|
57 | chunks 12 boolean values long (say), and that they are to be treated as atomic |
---|
58 | units by the crossover operator -- it can't cross over within the chunk. |
---|
59 | |
---|
60 | VectorSpecies is the species for BitVectorIndividual, as BitVectorIndividual |
---|
61 | doesn't need any special features. |
---|
62 | |
---|
63 | |
---|
64 | ec.vector.IntegerVectorSpecies |
---|
65 | |
---|
66 | IntegerVectorSpecies is a VectorSpecies and so has all the same features as it. |
---|
67 | Also, it allows you to specify min and max gene values for each |
---|
68 | gene in three different ways. First, you can specify a global min and max |
---|
69 | value for all genes. Second, you can specify _segments_ (regions in the |
---|
70 | genome) which all share the same min and max values. Third, you can specify |
---|
71 | individual min and max values for each independent gene. These three methods |
---|
72 | can be mixed as well: independent gene values override segments, which override |
---|
73 | global values. Note that segments are not the same thing as chunks. |
---|
74 | |
---|
75 | The default mutation procedure for IntegerVectorSpecies genes is gene |
---|
76 | randomization. Override this as you see fit. |
---|
77 | |
---|
78 | |
---|
79 | ec.vector.FloatVectorSpecies |
---|
80 | |
---|
81 | This class, like IntegerVectorSpecies, has all the features of VectorSpecies, |
---|
82 | and furthermore has min and max gene values specified on a global, segment, |
---|
83 | and per-gene basis. |
---|
84 | |
---|
85 | The default mutation procedure for FloatVectorSpecies can be either |
---|
86 | randomization or adding gaussian random noise with a specified mutation |
---|
87 | standard deviation. If the random noise exceeds the min and max bounds |
---|
88 | for that gene, FloatVectorSpecies will retry (you can specify how many |
---|
89 | times) before giving up and not mutating the gene. |
---|
90 | |
---|
91 | |
---|
92 | ec.vector.GeneVectorSpecies |
---|
93 | |
---|
94 | This class is a VectorSpecies and so has all of its features. However the |
---|
95 | atomic type of the vector array isn't a number or boolean, but rather a |
---|
96 | specific object called a VectorGene; or more specifically, a subclass of |
---|
97 | VectorGene which you specify (with the 'gene' parameter). The objective |
---|
98 | of this Species and GeneVectorIndividual is to enable you to have arbitrary |
---|
99 | genes of any kind you like -- just stick your data in your VectorGene |
---|
100 | subclass. |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | |
---|
105 | Other classes of importance: |
---|
106 | |
---|
107 | |
---|
108 | ec.vector.VectorGene |
---|
109 | |
---|
110 | This class is used with GeneVectorIndividual and GeneVectorSpecies to give you |
---|
111 | flexibility with regard to the makeup of genes in the individual. To implement |
---|
112 | a VectorGene subclass, you'll need to provide a few basic methods (equality |
---|
113 | testing, hash codes, the reset method, the mutation method) and optionally some |
---|
114 | print facilities, depending on your needs. |
---|
115 | |
---|
116 | |
---|
117 | ec.vector.breed.VectorMutationPipeline |
---|
118 | |
---|
119 | Defines a basic mutation breeding pipeline for vector individuals. The class |
---|
120 | is very simple: when it is charged to produce a child, it requests a child |
---|
121 | from its source, then calls defaultMutate() on that child and returns it. |
---|
122 | |
---|
123 | |
---|
124 | ec.vector.breed.VectorCrossoverPipeline |
---|
125 | |
---|
126 | Defines a basic crossover breeding pipeline for vector individuals. The class |
---|
127 | is very simple: when it is charged to produce children, it requests a child |
---|
128 | from each of its sources, then calls defaultCrossover() on one child, passing |
---|
129 | in the other child, to get them to cross over with one another. It then returns |
---|
130 | the children. |
---|
131 | |
---|
132 | |
---|
133 | ec.vector.breed.ListCrossoverPipeline [UNTESTED] |
---|
134 | |
---|
135 | Defines one-point and two-point crossover for vector individuals whose length may |
---|
136 | vary. This crossover pipeline may be useful for representations which are lists |
---|
137 | rather than fixed-length vectors. |
---|
138 | |
---|
139 | |
---|
140 | ec.vector.breed.MultiCrossoverPipeline [UNTESTED] |
---|
141 | |
---|
142 | Performs a version of N-person multiple crossover. The size of N is determined |
---|
143 | by the number of sources provided to the pipeline. For each gene, the gene |
---|
144 | values among the N indivdiuals are shuffled. The resulting children are then |
---|
145 | returned. |
---|
146 | |
---|
147 | |
---|