GEATbx: Main page  Tutorial  Algorithms  M-functions  Parameter/Options  Example functions  www.geatbx.com

# 4 Variable Representation

One important step in deciding which evolutionary algorithm is to use is a close look to the format/representation of your variables (phenotype). A second step is the direct decision on which format the evolutionary algorithm should work (genotype). The representation determines the overall algorithm, that means, the used evolutionary operators.

In the GEATbx different representations are directly supported:

1. real value representation,
2. binary value representation,
3. integer value representation,
4. ordering representation.

## 4.1 Conversion between Variable Representations

The use of a representation and necessary conversion is controlled by the parameter VariableFormat and the conversion function bindecod (fully transparent to the user). The toolbox provides low-level functions for conversion between the representations:

Tab. 4-1: Combinations of variable representation and conversion

 VariableFormat EA works on variable representation conversion 0 real real no 1 binary real bin2real 2 integer integer no 3 binary integer bin2int 4 binary binary no 5 integer ordering/permutation no

In the end it can be stated:

• Use nearly always the "natural" representation of the variables (no conversion)!
• If the variables of the objective function are real use the real value presentation for the evolutionary algorithm as well.
• If the variables of the objective function are binary use the binary value presentation for the evolutionary algorithm as well.
• If the variables of the objective function are integer use the integer value presentation for the evolutionary algorithm.

## 4.2 Examples of Variable Representation

### 4.2.1 Real --- Real

The variables of the objective function are in real value representation(phenotype: real). Now it could be chosen between binary and real value representation for the evolutionary algorithm. Recommended is the real value representation (tbx3real). It works much quicker than the binary one.

`geamain2('objfun1')`

All default parameters of the GEATbx are defined for a real representation. objfun1 is an objective function using real representation.

This example is implemented in the demo function demofun1.

### 4.2.2 Real (phenotype) --- Binary (genotype)

However, if the decision comes to use the binary values inside the evolutionary algorithm (genotype: binary), the population is initialized as if the variables would be binary (initbp), the evolutionary operators (mutbin and, for instance, recsp) are applied, and before the evaluation of the objective function the binary values are converted to real values (bindecod and bin2real).

`geamain2('objfun1', tbx3sga)`

The toolbox function tbx3sga defines all the options for a binary representation according to the definition of the simple genetic algorithm SGA. objfun1 is an objective function using real representation.

This example is implemented in the demo function demosga.

### 4.2.3 Integer (phenotype) --- Integer (genotype) or Binary (genotype)

In this case the variables are in integer representation (phenotype: integer). The evolutionary algorithm can work on integer values (mutint and recdis). The toolbox function tbx3int defines these options. The example demointeger1 contains a similar implementation (optimizing a normally real function using an integer representation).

The evolutionary algorithm can also work on binary values (mutbin and, for instance, recsp) and convert them to integer (bin2int) before evaluation of the objective function. Just set the parameter VariableFormat = 3 and the conversion is handled by the toolbox.

### 4.2.4 Binary --- Binary

There exist a number of problems asking for a binary representation (for instance, feature selection). The toolbox function tbx3bin defines default parameters for a binary representation used by the EA (mutbin, recdprs and VariableFormat = 4).

`geamain2('objone1', tbx3bin)`

objone1 is an objective function using binary representation (MAXONE problem). A complete demo of this representation is contained in demobin1.

## 4.3 Simultaneous Use of Multiple Representations

Up to now it has been assumed that all the variables of a problem to be solved exist in the same representation. This is, however, not always the case. When solving some problems in practice variables of differing types have to be dealt with simultaneously. This means that some of an individual's variables are real and others are integer or binary.

As previously mentioned, each variable representation has different operators which are best suited to it. In addition, certain singularities have to be taken into account for each data type. A way has to be found to optimize all the variables simultaneously despite these different re-quirements.

An extensive discussion of the different possibilities can be found in Chapter 'Parameter Optimization of Variables of different Representations' in "GEATbx Introduction".

### 4.3.1 Integer and Binary (phenotype) --- Integer (genotype)

A binary variable is equivalent to an integer variable within the limits [0, 1]. Thus, without any restrictions integer and binary variables can simultaneously be optimized using the integer representation.

The toolbox function tbx3int defines the options for integer representation. A full blown demo example is currently not available. Anyone a good objective function asking for binary and integer variables?

### 4.3.2 Real and Integer and Binary (phenotype) --- Integer (genotype)

Support for this conversion will be available soon. If you are interested, send me an email to speed up the implementation of this feature.

 GEATbx: Main page  Tutorial  Algorithms  M-functions  Parameter/Options  Example functions  www.geatbx.com

This document is part of version 3.8 of the GEATbx: Genetic and Evolutionary Algorithm Toolbox for use with Matlab - www.geatbx.com.
The Genetic and Evolutionary Algorithm Toolbox is not public domain.