Differential Evolution C++ library
The test project (de_test)

What is de_test

The de_test project included in the package is a command line application that is used to find the max or min values of several test functions commonly used to benchmark optimization algorithms. These functions, such as Ackley, De Jong etc, are generally hard to optimize because of properties like many local minimia or global minimia surrounded by a high gradient region etc. Here is a page describing several of these functions http://www.geatbx.com/docu/fcnindex-01.html#P247_13252 .

The purpose of this project is to illustrate the use of the DE C++ library in a real application, but de_test can be used as a starting point for more complex application or can even be used to solve real optimization problems by adding new objective functions.

Building de_test

If this package is used on Windows, and either Visual Studio 2008 or 2010 are available, there is no need to download or install anything else - all necessary files and components are already in the zip file.

The zipped packge comes with Visual Studio 2008 and 2010 solutions and projects for de_test: de_test9.sln for VS2008, de_test10.sln for VS2010. The package also contains all required boost header and library files for these projects.

All is then needed is to open the solution in the Visual Studio IDE and build either the Debug or Release Win32 configurations.

To build on other platforms, one will first need to make sure that all the necessary boost binaries are available (date/time, thread, command line, and regex). The current boost version as of this writing is 1.48.0. The next step is to compile and link all source files using the make tools for that platform. The code is supposed to be 100% portable, so there shouldn't be any problems building it.

Running de_test

Again, if the package is used on Windows, pre-built debug and release executables (de_test.exe) generated using Visual Studio 2008 are already available in the bin\debug and bin\release\de_test directories. They can be run immediately, no need to build or install anything beforehand.

On platforms other than Windows one will first have to build the binaries in order to run the test application.

Command line arguments


The de_test command line application requires setting several command line arguments for a succesful run.

The arguments can be passed either on the command line or in a configuration file.

Each argument has a short form (e.g. -w) and a long form (--weight). Both forms are supported when they are passed on the command line, but only the long form (without the --) is supported in the configuration file.

Here is the list of supported arguments presented as  short_form, long_form (=default_value if any) - comments

  • ?, help - shows the command line usage message
  • w, weight - sets the weight factor
  • c, crossover - sets the crossover factor
  • p, populationsize - sets the number of individuals in the population
  • g, generations - sets the masimum number of generations
  • m, mutationstrategy (=1) - set to a value between 1-5, for one of the 5 available mutation strategies
  • s, selectionstrategy (=1) - set to 1 for "best parent child selection" or 2 for "tournament selection".
  • i, minimize - 0 to maximize, 1 to minimize
  • f, configfile - the name of the configuration file
  • r, processorcount - the number of parallel processors to run the objective function in
  • n, constraint - one constraint, using the format "type;min;max" where min and max are floating point values and type is one of real, int (set and boolean constraint types are not exposed through the command line, although they are implemented). Several constraints can be set on the command line, one per variable.
  • v, variablescount (=20)- number of variables per individual - it is usually much higher than the number of variables required by the objective function
  • x, defconstraintmin (=-1e6) - default min constraint, used for variables that don't have constraints set explicitly on the command line
  • y, defconsraintmax (=1e6) - default max constraint, used for variables that don't have constraints set explicitly on the command line.
  • o, functiontooptimize - one of the following values:
    1. -(x^2) [max: 0]
    2. x^2 [min:0]
    3. x^6 - 10*x^3 [min: -25]
    4. sphere function (first De Jong function) [min: 0]
    5. Auckley function [min: 0]
    6. second De Jong function [min: 0]
    7. six hump camel back function [min -1.031628453...]

Configuration file

As mentioned before, the application arguments can be passed in a configuration file whose path and name are specified on the command line using the argument -f (or --configfile). Configurations files are more convenient if one is supposed to run the application repeatedly while experimenting with various argument values.

The configuration file contains one argument per line:
arg_long_name_1=value_1
arg_long_name_2=value_2
...


Only argument long names are allowed in the configuration file.

For example to specify that the weight factor is to be set to 0.9, we'll enter:
weight=0.9

The user is encouraged to expirement with different values for weight, crossover, number of variables, population size etc to see how the algorithm behaves in a variety of setups