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

GEATbx: Tutorial 2 Quick Start

Previous PageTable Of ContentsIndexList Of FiguresNext Page



2 Quick Start

The Genetic and Evolutionary Algorithm Toolbox (GEATbx) provides a number of demos. All these functions are called demo*.m (for instance demofun1). The demo-functions provide ready-to-run examples and can be called directly after the installation. All necessary parameters are already set.

2.1 First demonstration

Next SectionTop Of Page

As a first example, run the first demonstration function in Matlab:

This demo defines a number of evolutionary algorithm options, starts the optimization, displays the EA options employed on the screen (see figure 2-1), optimizes the objective function objfun1, returns intermediate information during the optimization in the Matlab command window (see figure 2-2 and 2-4), and visualizes the results graphically every few generations (see figure 2-3). The output on your screen might be slightly different, but the examples below give you a general idea of the output visualization. Below the output figures some of the options inside demofun1 are explained.

Fig. 2-1: Output in Matlab command window at start of optimization run (used options)

Fig. 2-2: Status information displayed in command window during optimization (some lines removed)

Fig. 2-3: Graphical output during optimization

Fig. 2-3: Graphical output during optimization

Fig. 2-4: Result information displayed in command window at the end of the optimization (some parts have been removed)

A number of options are defined in demofun1. Most of these options are not really necessary for a first demo function. However, you can use this function as a template. Let's have a look at some of the options.

The first step provides us with the default parameters for real valued parameters. More information can be found at Predefined Evolutionary Algorithms (in Parameter options).

The second step is to set number of subpopulations (here 5 subpopulations) and number of individuals per subpopulation (here a different number for each subpopulation, 50 individuals for the first subpopulation, 30 individuals in the second subpopulation and so on). Another useful parameter defines, how often textual status information is displayed during an optimization (here every 5 generations).

The definition of the objective function is quite important. Here we use one of the many example objective functions of the GEATbx, objfun1 implementing the hyper sphere function. The objective function is implemented in an m-function. Thus, we simply provide the name of this m-function:

All the example objective functions of the GEATbx not only contain the definition of the function, but also all the necessary parameters for the application of the function: boundaries of the variables (VLUB: vector of lower and upper bounds), a short textual description, the best objective value (when known), and the corresponding variable values. Thus, the GEATbx can always "ask" the current objective function for the parameters needed. A gateway function to access these parameters is provided.

A full description of the gateway into the objective functions is given in 'Writing Objective Functions', Chapter 3.

Now all options are defined. Thus, the evolutionary algorithm implemented in geamain2 can be called:

During the optimization status information and visualization output are displayed on the screen (see figure 2-2, 2-4, and 2-3).

If you want to have a look at the search space of the objective function (visualizing the first 2 dimensions):

2.2 Second demonstration

Previous SectionNext SectionTop Of Page

In order to give an impression of the utility of the GEATbx, a demonstration implementing 3 different evolutionary algorithms and calling many of the example objective functions is provided. Call the demonstration in the Matlab command window:

This call optimizes the objective function objfun1 with a 'Globally oriented optimization (with multiple subpopulations)' nearly identical to the implementation in demofun1.

When the demonstration is called without parameters, you can select one of the available options from a text menu. The first menu provides a selection of at least 16 different objective functions. The second menu offers 3 different evolutionary algorithms (see figure 2-5, bottom).

Fig. 2-5: Demonstration demogeatbx: option selection in menu (top: objective function, bottom: evolutionary algorithm to apply)

Using this demonstration function you can explore many of the provided objective functions. Each of the objective functions has different properties. Thus, for each objective function the 3 evolutionary algorithms behave differently. For instance, try the following combinations:

The options of the evolutionary algorithms employed are displayed in the Matlab command window at the beginning of the optimization. However, the first 2 evolutionary algorithms ('Globally oriented optimization', most options defined in tbx3real) differ only in the number of subpopulations employed. Both of these use 200 individuals. The third evolutionary algorithm ('Locally oriented optimization') uses an evolution strategy as the mutation operator and no recombination. It works with only 12 individuals. A few other options are also different. Most of the options of this evolutionary algorithm are set inside tbx3es1.

2.3 Your first optimization of an own objective function

Previous SectionNext SectionTop Of Page

Up to now you have only used the demonstration and objective functions provided. It is time to write your first objective function. Let's implement a simple quadratic function with a moved center.

An implementation of the x^2 function with a moved minimum point to [4, 8, 12, ...] is given in figure 2-6. Save these lines in an m-file with the name objexample1.m. Now the objective function is defined.

Fig. 2-6: Definition of objective function objexample1

In the command window you can now set a few optimization options before you start the optimization (all other options are taken from the set of default options). These lines can also be written to an m-file creating your own demo example and executing this m-file.

As an example, set the interval of text output to every 3 generations. The second option results in an update of the graphical output every 9 generations. The optimization stops after half a minute (termination method 2 is maximal time in minutes). Using the new objective function and the special options you can call the evolutionary algorithm. Here we also provide the number of variables or dimensions of the objective function (4 variables by defining 4 lowerand 4 upper bounds) and the boundaries of these variables (-50 and 50).

Fig. 2-7: Definition of options, size of the problem (number of variables) and execution of optimization

Using these few lines the optimization is executed and results are shown in the command window (text output) and the graphical result figure. At the end of the run the result is given in the command window (similar to figure 2-4).

The same objective function can easily be optimized for 15 variables/dimensions or more. To do so simply define a larger number of variable boundaries. Now the objective value can only reach a minimum of 140. The boundaries for the higher dimensions do not allow the (unbounded) minimal value to be found. You must therefore call the evolutionary algorithm again with extended/changed boundaries.

Fig. 2-8: Definition of a larger number of variables and with extended boundaries

An impression of the graphical output during optimization is given in figure 2-9.

Fig. 2-9: Graphical output during optimization of first own objective function

Fig. 2-9: Graphical output during optimization of first own objective function

These are the graphics which default options provided. The top left graph presents the best objective value during the last 40 generations (and the standard deviation of all objective values). The top middle graph visualizes the variables of the best individual over the last 40 generations. Out of the chaos at the beginning, an order seems to emerge and you can try to interpret the results. The top left graph shows all the objective values (to be exact only 85% of the best of each generation) over the last 40 generations. A very interesting graph is presented on the bottom left: all the variables of all the individuals of the current generation. You can clearly see the order in the variable values. The bottom middle graph shows the objective values of the individuals of the current generation and the bottom right graph the order of the subpopulations (both will be explained at a future date).

During optimization the graphical output changes quite substantially. Thus, the graphic in figure 2-9 is just a snapshot. If, however, you follow the changing display during optimization you will soon gain a good insight into the course and the state of the current optimization.

2.4 Further Steps

Previous SectionNext SectionTop Of Page

The examples shown will be sufficient for your first steps using the GEATbx. Have a look at the scripts subdirectory of your geatbx3 installation. This directory contains further demo functions - see the respective help text for more information.

The next step is to learn about 'Writing Objective Functions', see Chapter 3, and how to handle the different 'Variable Representation' in the objective function and the evolutionary algorithm, see Chapter 4.

For an 'Overview of GEA Toolbox Structure' and more information on the 'Calling Tree' of the toolbox, see Chapter 5.

Previous PageTop Of PageTable Of ContentsIndexList Of FiguresNext Page

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.
© 1994-2006 Hartmut Pohlheim, All Rights Reserved, (support@geatbx.com).