Next: Chromosome Definition
Up: The Language
Previous: Moderator Specifications
The simplest construct of the DARWIN language is the gene. The genes are
used to build up chromosomes. The DARWIN gene implements the initializer, printer,
crossover, mutator and evaluator as its moderators.
The gene definition syntax is as follows :
gene_typedef |
::= |
"gene" id |
|
|
"{" memb_decls "}" |
|
|
genome_moderators ";" |
genome_moderator |
::= |
initializer ":" prototype |
|
 |
crossover ":" prototype |
|
 |
mutator ":" prototype |
|
 |
evaluator ":" prototype |
|
 |
printer ":" prototype |
For example, a gene representing a rectangular region is defined as follows.
gene TRectangle
{
char x;
char y;
int orientation;
frozen int width;
frozen int height;
}
Note the usage of keyword "frozen", which instructs the compiler that no
special handling for these members is needed, that is no code effecting
these data members will be generated.
In addition, we have not used the
full expressive power of the DARWIN gene definition, which allows specifying
domain information on a given member.
For example, if a rectangle can be positioned only at discrete x and y
coordinate values in the range [0..100], then we have the following
gene definition :
gene TRectangle
{
char x < [0..100];
char y < [0..100];
int orientation < [0,1];
frozen int width;
frozen int height;
} < evaluator : RectangleEval, init : RectangleInit;
Now we have a better representation of our gene, and the evaluator moderator
specified. Since the crossover, mutator and printer are not
specified, the DARWIN compiler is instructed to generate default handling
code for these moderators. Note that the names of the moderators can be abbreviated.
The DARWIN gene definition is a set of basic typed data members,
which may optionally specify domains. The semantics of the gene
definition is defined below.
- The gene initializer
- is called when a new
gene is created by the DARWIN program. Usually this happens as
a result of creating a chromosome, which in turn initializes
all its gene members. The initializer if not specified, is generated by
the compiler by looking at the gene member domains. The domain
of a data member not specifying a more restrictive domain is
taken to be the data space of the underlying data type. The generated
initializer produces statements to randomize each of the non-frozen
gene members, by taking into concern its domain.
- The gene crossover
- moderator is responsible for providing the crossover
operator on the gene. It can be called by the chromosome crossover
moderator if a gene member of the chromosome is selected as a crossover
point. The default gene crossover operator implements a one-point
binary crossover.
- The gene mutator
- implements the mutation operator. This function
creates an anomaly in the gene and is calls by the chromosome
mutator if a population decides to mutate a chromosome, which
in turn selects to mutate the given gene. The generated gene
mutator performs a bit flip at a random position if
no domain is specified for the member at the given gene position, and
a domain specific randomized change otherwise.
- The gene printer
- is provided for printing the values of the gene members
in a more readable form.
- The gene evaluator
- is only needed if no evaluator for the chromosome
containing the given gene is provided. In such a case, the evaluator
should provide a floating-point value specifying the measure this gene
contributes to the total welfare of the solution encoded by the
owning chromosome. No default evaluator can be generated by the DARWIN
compiler.
Next: Chromosome Definition
Up: The Language
Previous: Moderator Specifications
Gokturk Ucoluk
2003-09-15