Portions of a generic genetic-algorithms library
Contents |
Introduction
Over the last few months I have become interested in problems associated with the modeling of non-linear systems. This interest has lead me to look into artificial neural networks, and how they can be trained using genetic algorithms. For those with an interest in this area, development environments like Matlab provide an ideal platform for quick implementation and testing. However, at deployment time, a Matlab script is of little use to clients with a limited budget, or to developers targeting some embedded platforms [What about on non-x86 architectures e.g. the supercomputer situated in the engineering department - that don't run Matlab?].
... to be continued ...
What is the motivation here? Off-line training of neural networks via genetic algorithms to model non-linear systems in a low cost environment.
Theoretical Background
Some Basic theory on genetic algorithms (perhaps some background on artificial neural networks, and artificial neural network training?)
Requirements
What should a generic genetic-algorithms library do, and why? How might this change?
Examples of Genetic-Algorithms Libraries
Describe the Matlab GA libraries, and how they are used. What other examples are there?
A First Attempt
This is the starting point - something I put together around 6 months ago.
My first working attempt at a generic genetic-algorithms library is shown in Fig. 1. This section will dissect and critique portions of the initial library design.
Creating New Candidates
A set of candidates are required to initiate the algorithm. The creation of this initial set or generation of candidates is the responsibility of the library user.
The First Attempt
In the first attempt, a modified Factory pattern was used here, this was taken from a Microsoft Patterns and Practices article by Doug Purdy. An abstract factory class is provided by the library, the user is expected to provide a concrete candidate factory class.
A New Design
To facilitate building candidates, the user should provide the genetic algorithm with a concrete candidate factory.
Selection of the Fittest
Upon creating a generation of candidates, the process of creating a new generation begins. To start, a portion of the candidates are selected from the current generation based on fitness. The fitness of each candidate is calculated, then one of several candidate selection algorithms is applied to the current generation. The selection strategy may vary per iteration. The library user is responsible for choosing and configuring the selection strategy.
The First Attempt
Fitness calculations are known about by
- the GeneticAlgorithms class
- the Generation class
- the Candidate class
A New Design
Creating New Candidates via Reproduction
A new generation begins by selecting a set of candidates based on fitness. These candidates become the parents in the new generation; they reproduce to create a new set of genetically similar candidates. Reproduction, also known as crossover, is performed using one of several possible crossover algorithms. The same reproduction strategy is usually applied to the entire generation in any one iteration. It is often kept constant throughout the algorithm life-cycle. The library user is responsible for choosing the crossover strategy.
The First Attempt
A New Design
Mutating Candidates
Following the reproduction process, a proportion of the children produced may be mutated. In mutation, there are two responsibilities. One is performing the mutation - defining this algorithm is the responsibility of the library user. The other is selecting candidates for mutation - here the library user is responsible for choosing from one of several selection strategies defined within the library.