Page 34 - 49A Field Guide to Genetic Programming
P. 34
20 3 Getting Ready to Run Genetic Programming
The terminal set may consist of:
• the program’s external inputs. These typically take the form of named
variables (e.g., x, y).
• functions with no arguments. These may be included because they
return different values each time they are used, such as the function
rand() which returns random numbers, or a function dist to wall()
that returns the distance to an obstacle from a robot that GP is con-
trolling. Another possible reason is because the function produces side
effects. Functions with side effects do more than just return a value:
they may change some global data structures, print or draw something
on the screen, control the motors of a robot, etc.
• constants. These can be pre-specified, randomly generated as part of
the tree creation process, or created by mutation.
Using a primitive such as rand can cause the behaviour of an individual
program to vary every time it is called, even if it is given the same inputs.
This is desirable in some applications. However, we more often want a
set of fixed random constants that are generated as part of the process of
initialising the population. This is typically accomplished by introducing
a terminal that represents an ephemeral random constant. Every time this
terminal is chosen in the construction of an initial tree (or a new subtree
to use in an operation like mutation), a different random value is generated
which is then used for that particular terminal, and which will remain fixed
for the rest of the run. The use of ephemeral random constants is typically
denoted by including the symbol < in the terminal set; see Chapter 4 for an
example.
3.2 Step 2: Function Set
The function set used in GP is typically driven by the nature of the problem
domain. In a simple numeric problem, for example, the function set may
consist of merely the arithmetic functions (+, -, *, /). However, all sorts
of other functions and constructs typically encountered in computer pro-
grams can be used. Table 3.1 shows a sample of some of the functions one
sees in the GP literature. Sometimes the primitive set includes specialised
functions and terminals which are designed to solve problems in a specific
problem domain. For example, if the goal is to program a robot to mop the
floor, then the function set might include such actions as move, turn, and
swish-the-mop.