[6152] | 1 | This README is with regard to the 'ec' package in this directory. Various |
---|
| 2 | subdirectories contain READMEs of their own for their respective packages. |
---|
| 3 | If you're looking for overall documentation for ECJ, see the README file |
---|
| 4 | for the parent directory of this one (that is, the 'ecj' directory). |
---|
| 5 | |
---|
| 6 | The 'ec' package contains top-level abstract classes defining most of the |
---|
| 7 | major elements of evolutionary or stochastic search processes. You probably |
---|
| 8 | don't want abstract classes: instead you may wish to examine the 'simple' |
---|
| 9 | subpackage for concrete implementations of these classes which perform |
---|
| 10 | basic evolutionary tasks. |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | DESIGN PATTERNS IN ECJ |
---|
| 16 | ---------------------- |
---|
| 17 | |
---|
| 18 | ECJ's basic classes sit on a set of simple interfaces defining what would now |
---|
| 19 | be called 'design patterns'. Nearly all classes in ECJ use one or more of |
---|
| 20 | these interfaces, and together the interfaces are largely responsible for |
---|
| 21 | ECJ's dynamic loading facilities. |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | ec.Setup |
---|
| 25 | |
---|
| 26 | ec.Setup is ECJ's top-level design pattern interface. Setup defines a single |
---|
| 27 | method, setup(...), which acts as a sort of alternative constructor for |
---|
| 28 | instances which implement it. In ECJ most classes are loaded at runtime |
---|
| 29 | from ECJ's ParameterDatabase. Instances from such classes are dynamically |
---|
| 30 | instantiated using their default (no-argument) constructor; the setup(...) |
---|
| 31 | method then is called to give the objects a chance to set themselves up |
---|
| 32 | properly from the ParameterDatabase. This approach was largely done because |
---|
| 33 | early versions of reflection in Java were inadequate. |
---|
| 34 | |
---|
| 35 | ec.Prototype |
---|
| 36 | |
---|
| 37 | Prototypes are Setups which are cloneable. An class implementing Prototype |
---|
| 38 | is meant to have a single instance of the class (the "prototypical instance") |
---|
| 39 | loaded and setup from the Parameter Database; further instances of the class |
---|
| 40 | are constructed by cloning the prototypical instance. A large number of |
---|
| 41 | ECJ objects are Prototype, including Individuals and various components of |
---|
| 42 | Individuals (such as genetic programming tree nodes). |
---|
| 43 | |
---|
| 44 | Many ECJ Prototypes support the so-called "flyweight" design pattern, whereby |
---|
| 45 | large numbers of lightweight instances share a common single special object |
---|
| 46 | which acts as a repository of default information common to all of them. |
---|
| 47 | In Java this could be implemented using static members, but static members |
---|
| 48 | are challenging to serialize (an important thing in ECJ), and so ECJ instead |
---|
| 49 | uses an actual object instead. |
---|
| 50 | |
---|
| 51 | ec.Group |
---|
| 52 | |
---|
| 53 | Groups are very similar to Prototypes: their primary difference is that there |
---|
| 54 | is no prototypical Group: rather, new Groups can be cloned from currently |
---|
| 55 | in-use Groups using the method emptyClone(). Examples of Groups include |
---|
| 56 | Populations and Subpopulations. |
---|
| 57 | |
---|
| 58 | ec.Singleton |
---|
| 59 | |
---|
| 60 | Singletons are also Setups but are meant to be global objects: only one |
---|
| 61 | instance is ever loaded and setup during the course of a run. Most top-level |
---|
| 62 | objects (like ECJ's EvolutionState, Breeder, Evaluator, etc. objects) are |
---|
| 63 | Singletons. |
---|
| 64 | |
---|
| 65 | ec.Clique |
---|
| 66 | |
---|
| 67 | Cliques are Setups which are small groups of instances of a single class. |
---|
| 68 | Like Singletons, Cliques are global. Once the collection of Cliques are loaded |
---|
| 69 | and setup, no more are usually created. Cliques are associated with globally |
---|
| 70 | accessible tables which enable access to all members of the clique. Cliques |
---|
| 71 | include genetic programming function sets, genetic programming types, etc. |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | THE MAKEUP OF AN EVOLUTIONARY SYSTEM |
---|
| 76 | ------------------------------------ |
---|
| 77 | |
---|
| 78 | ec.Population |
---|
| 79 | ec.Subpopulation |
---|
| 80 | ec.Individual |
---|
| 81 | |
---|
| 82 | ECJ's evolutionary system is centered around a single Population, which |
---|
| 83 | contains an array of Subpopulations. Each Subpopulation contains an array of |
---|
| 84 | Individuals. This structure is largely to support techniques such as |
---|
| 85 | coevolution which require more than one "population". In ECJ such methods |
---|
| 86 | use one or more Subpopulation class to support this. Though you will likely |
---|
| 87 | use Population and Subpopulation classes directly, almost certainly you'll |
---|
| 88 | need to subclass Individual to define its representation. A number of |
---|
| 89 | predefined Individuals are available for you. |
---|
| 90 | |
---|
| 91 | ec.Species |
---|
| 92 | |
---|
| 93 | Individuals in ECJ support the flyweight pattern (see discussion of |
---|
| 94 | ec.Prototype above) and ec.Species is their collective object. Many Individuals |
---|
| 95 | in ECJ share a common Species. Each Subpopulation is also associated |
---|
| 96 | with the Species used by Individuals in that Subpopulation. Note that |
---|
| 97 | multiple subpopulations, and different groups of Individuals, might |
---|
| 98 | use the same Species in theory. |
---|
| 99 | |
---|
| 100 | The Species object contains the prototypical Individual from which other |
---|
| 101 | Individuals of that Species are cloned; and also contain Breeding Pipelines |
---|
| 102 | (see below) which enable Individuals to be bred from other Individuals of |
---|
| 103 | that Species. |
---|
| 104 | |
---|
| 105 | ec.Fitness |
---|
| 106 | |
---|
| 107 | Each ECJ individual contains a Fitness. Different kinds of individuals |
---|
| 108 | can have different kinds of fitness objects (say, multiobjective fitness |
---|
| 109 | objects, or single-objective GA-style fitness objects, etc.). The Fitness |
---|
| 110 | class is abstract: various Fitness subclasses perform different kinds of |
---|
| 111 | Fitness concepts. |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | DOING EVOLUTION |
---|
| 117 | --------------- |
---|
| 118 | |
---|
| 119 | ec.Evolve |
---|
| 120 | |
---|
| 121 | This class is the entry point for ECJ (it contains the main() method), but |
---|
| 122 | in fact it does relatively little: its main task is to load an EvolutionState |
---|
| 123 | from the parameter database, then get it going. |
---|
| 124 | |
---|
| 125 | ec.EvolutionState |
---|
| 126 | |
---|
| 127 | ECJ's top-level evolutionary loop is handled by subclasses of EvolutionState. |
---|
| 128 | EvolutionState also contains pointers to all the major elements of evolution, |
---|
| 129 | and ultimately everything in the entire evolutionary system. Thus the entire |
---|
| 130 | process can be serialized (checkpointed) to disk simply by serializing |
---|
| 131 | EvolutionState. When ECJ creates an evolutionary process, it first constructs |
---|
| 132 | an EvolutionState, then has the EvolutionState set up the rest of the process |
---|
| 133 | from the parameter database. Because EvolutionState holds everything, it is |
---|
| 134 | often passed to many functions. |
---|
| 135 | |
---|
| 136 | ec.Initializer |
---|
| 137 | ec.Finisher |
---|
| 138 | |
---|
| 139 | To create a random population and begin evolution, EvolutionState calls upon a |
---|
| 140 | subclass of Initializer. Likewise, just before quitting, EvolutionState |
---|
| 141 | calls upon some subclass of Finisher to clean up. |
---|
| 142 | |
---|
| 143 | ec.Evaluator |
---|
| 144 | ec.Problem |
---|
| 145 | |
---|
| 146 | EvolutionState calls upon Evaluator to evaluate the population. Most |
---|
| 147 | Evaluators are straightforward: go through the population and evaluate each |
---|
| 148 | individual in turn. But certain techniques require custom evaluation (such |
---|
| 149 | as coevolution). The evaluator relies on a Problem subclass to do its dirty |
---|
| 150 | work: actually testing a given individual and assessing its fitness. The |
---|
| 151 | experimenter (you) is required to provide a Problem subclass for his problem. |
---|
| 152 | Most of the examples in the "app" directory are largely Problem implementations. |
---|
| 153 | Often the Evaluator can work in parallel, cloning several Problems, then |
---|
| 154 | creating several threads, one thread per Problem, in order to assess the |
---|
| 155 | population more rapidly. |
---|
| 156 | |
---|
| 157 | ec.Breeder |
---|
| 158 | ec.BreedingSource |
---|
| 159 | ec.BreedingPipeline |
---|
| 160 | ec.SelectionMethod |
---|
| 161 | |
---|
| 162 | To breed a population to form a new population the EvolutionState relies on |
---|
| 163 | a subclass of Breeder. Most Breeders work by constructing a "breeding |
---|
| 164 | pipeline" which selects individuals from the original population, mutates and |
---|
| 165 | crosses them over, and produces new children. The breeding pipeline typically |
---|
| 166 | contains two kinds of objects: SelectionMethod objects, which pick individuals |
---|
| 167 | from the old population; and BreedingPipeline objects, which receive |
---|
| 168 | individuals from SelectionMethods or from other BreedingPipeline objects, and |
---|
| 169 | then mutate or cross over the individuals. Both BreedingPipeline and |
---|
| 170 | SelectionMethod objects are BreedingSources (things other BreedingPipelines |
---|
| 171 | can get individuals from). Many breeders can work in parallel, |
---|
| 172 | constructing several breeding pipelines, one per thread, to speed up the task |
---|
| 173 | of breeding individuals and forming the next generation. |
---|
| 174 | |
---|
| 175 | ec.Exchanger |
---|
| 176 | |
---|
| 177 | In between breeding and evaluation, the EvolutionState calls on a subclass |
---|
| 178 | of Exchanger. The default implementations do nothing at all, but certain |
---|
| 179 | versions (like IslandExchange) take this opportunity to exchange individuals |
---|
| 180 | with far-of processes on other machines. |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | STATISTICS |
---|
| 185 | ---------- |
---|
| 186 | |
---|
| 187 | ec.Statistics |
---|
| 188 | |
---|
| 189 | ECJ relies on one or more subclasses of Statistics to write out statistics |
---|
| 190 | information to various logs. Statistics can be strung out in a chain, enabling |
---|
| 191 | you to include as many different Statistics objects as you like. Different |
---|
| 192 | Statistics subclasses are available to do various tasks. Statistics objects |
---|
| 193 | are called at all sorts of times in the run, in-between nearly every major |
---|
| 194 | operation, to give you a lot of hooks in which to probe the current state of |
---|
| 195 | the system. |
---|
| 196 | |
---|