Using configuration files for Paradiseo-EO EAs

Introduction

This tutorial allows to use automatically configuration files for your EAs. With these files, you can test different configuration parameters without compile your code between each test.

This tutorial is inspired of the one available on the following page: http://eodev.sourceforge.net/eo/tutorial/html/eoLesson3.html

Modification of your code

For instance, imagine that the stopping criterion of your EA is a maximum number of generations. Therefore, you have a variable that contains this value:

unsigned int maxGen=100;

Before testing your EA with a different value you need to modify your code and to compile it again... It is a waste of time.

Paradiseo-EO contains a special object that can help you : the eoParser.


You need to add this code at the beginning of your 'main' function:

eoParser parser(argc, argv);
PARAMETERS
string str_status = parser.ProgramName() + ".status";
eoValueParam<string> statusParam(str_status.c_str(), "status","Status file",'S');
parser.processParam( statusParam, "Persistence" );

if (parser.userNeedsHelp())
{
parser.printHelp(cout);
exit(1);
}

if (statusParam.value() != "")
{
ofstream os(statusParam.value().c_str());
os << parser;
}

At the place of PARAMETERS, you can put all your useful parameters according to the following syntax:

eoValueParam<PARAM_TYPE> myParam(DEFAULT_VALUE, SMALL_NAME, LONG_NAME, ONE_LETTER_NAME);
parser.processParam( myParam, CONFIGURATION_FILE_SECTION );
PARAM_TYPE my_param = myParam.value();

In our example, the code is :

eoValueParam<unsigned int> maxGenParam(100, "maxGen", "Maximum number of generations",'G');
parser.processParam( maxGenParam, "Stopping criterion" );
unsigned maxGen = maxGenParam.value();

Using your new configuration file

If you execute your new code for the first time and if your main application is "myEA" for example, a new file called myEA.status will be create. Its content will be:

###### General ######
# --help=0 # -h : Prints this message
# --stopOnUnknownParam=1 # Stop if unkown param entered

###### Persistence ######
# --status=myEA.status # -S : Status file

###### Stopping criterion ######
# --maxGen=100 # -G : Maximum number of generations

Thanks to this file, you can easily modify the program parameters. Each parameter can be directly changed in the file. For instance, the line:

# --maxGen=100 # -G : Maximum number of generations

Becomes :

--maxGen=200 # -G : Maximum number of generations

Then type in your terminal:

>> myEA @myEA.status

To use your new parameters.

Another way to modify only few parameters is to indicate their value directly during the launch.

For example with the small name:

>> myEA --maxGen=250

Or with the one letter name

>> myEA -G250

Epilogue

Thanks to this tutorial, you can now easily test all the combination of your program parameters.

Good luck.