Next: The basic tree
Up: Genetic Programming in C/C++
Previous: Assigning a fitness
One would ask, why a C implementation of genetic programming is at all
desirable. Koza does explain why he chose LISP, and the following
lists reasons why C might be viewed as a bad tool to construct a
genetic programming platform:
- C lacks the interpretive nature of LISP, and most certainly
lacks the ease of representation.
- To write C code that generates other code and operates upon
itself is a daunting task indeed.
- Another major drawback to the C approach is the lack of
automated garbage collection and memory allocation. This can become a
sore spot, since the members of the population change constantly, and,
as will be expained shortly, makes the C implementation much more
difficult.
But a compiled language implementation does provide the following
advantages:
- faster performance, both in speed and size. In general, the
programs we wrote took up about one to two megabytes of memory. LISP
interpreters can be very large, and because of the nature of the
beast, they can be slow as well.
- greater portability. Most platforms support standard ANSI C
code, and because of the relatively small memeory requirements, the C
code can be compilied on a variety of machines with little or no
change.
- better structure support. The flexibility of creating complex
structure does open the possibility of some rather strange, and useful
implementations.
- a familiar interface. C programming is commonplace, and
therefore the implementation of genetic programming in C allows a
wider audience to write and understand the code in which the
underlying processes are written.
As was stated previously, the major hangup with using C for genetic
programming is the lack of an intuitive interface to writing
self-modifying code. However, by developing an alternative
representation for what a ``program'' is, we were able to develop a
simple structure to hold the population of programs, in addition to
some relatively short code to genetically manipulate these structures.
Next: The basic tree
Up: Genetic Programming in C/C++
Previous: Assigning a fitness