Robot Simulator of the Robotics Group for Self-Organization of Control: ga_tools/ Directory Reference

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

# ga_tools Directory Reference

The ga_tools directory contains a toolkit for evolutionary algorithms. More...

## Directories
directory | FitnessStrategies
directory | GenerationSizeStrategies
directory | MutationFactorStrategies
directory | MutationStrategies
directory | RandomStrategies
directory | SelectionStrategies
directory | Values
## Files
file | Gen.cpp
file | Gen.h [code]
file | GenContext.cpp
file | GenContext.h [code]
file | Generation.cpp
file | Generation.h [code]
file | GenPrototype.cpp
file | GenPrototype.h [code]
file | Individual.cpp
file | Individual.h [code]
file | ga_tools/README
| This file is used for the doxygen documentation.

file | restore.h [code]
file | SingletonGenAlgAPI.cpp
file | SingletonGenAlgAPI.h [code]
file | SingletonGenEngine.cpp
file | SingletonGenEngine.h [code]
file | SingletonGenFactory.cpp
file | SingletonGenFactory.h [code]
file | SingletonIndividualFactory.cpp
file | SingletonIndividualFactory.h [code]

## Detailed Description

The ga_tools directory contains a toolkit for evolutionary algorithms.

This includes evolutionary strategies as well as the implementation of genetic algorithms and genetic programming. The class SingletonGenAlgAPI represents the API for the toolkit which you can use to access the package. The class SingletonGenEngine is the engine performing the genetic operations. The class IValue makes it possible to create all kinds of genes that are then handled automatically. This can be a number, a binary code, a program or a graphical primitive. The class IRandomStrategy is needed to create random individuals with your own gene types. The class IFitnessStrategy is designed to help you creating your own fitness strategy. With these and other strategies is it possible to customize and prepare the algorithm for your own needs.

The following subdirectories are included:

- ga_tools/Values : The interface and one special implementation for the gene values. It contains the IValue class.
- ga_tools/SelectionStrategies : The selection strategy interface and some implementations (tournament select, random select and elitism select).
- ga_tools/RandomStrategies : The random strategy interface and an implementation to create double values for the IValue class implementation.
- ga_tools/MutationStrategies : The mutation strategy interface and some implementation. Here you can implement your own mutation for your own gene-values.
- ga_tools/MutationFactorStrategies : Only for the specified ValueMutationStrategy, here you can make your own optimization for the value mutation.
- ga_tools/GenerationSizeStrategy : A strategy to change the size of the generation, for more information about this, look for selection force.
- ga_tools/FitnessStrategy : Contains a helper class that allows you to convert your own fitness function from a maximum-value-is-good to a minimum-value-is-good version as it is required by the algorithm.
- ga_tools/include : All header files. Do not modify this directory (automatically generated).
- ga_tools/simulation : Some example templates and simulations, which use the ga_tools package in combination with ode_robots and selforg.

Examples

The usage of this package is actually very easy even though it might look complicated at the first glance. To begin with you have to check which classes you have to overload to implement your problem. This means which strategies must be changed. In the best case you only have to alter the fitness strategy. Then you write your own versions of this class like in template_cycled_GA_Simulation. Now you have to initiate the algorithm. For this you need some of the following information:

- mutation probability in one/thousand (a low value of 3% - 5% is written as 30 or 50)
- number of individual at start
- number of children (must be greater or equal than the number of individual at start
- number of generation With this information you create and set the strategies. First the generation size strategy, then the selection strategy, then fitness, mutation and finally the random strategy. After this you have to create the prototypes of the genes and register them. That's all. Now you can work with the algorithm. If you think this is a lot of work, then keep in mind that all the rest goes now very smoothly. You only have to call a create function to get the strategy and then apply it -- only two calls per strategy.

You can find out how to work with the algorithm and the initialization by considering one of the simulations in the ga_tools folder e.g.

- template_cycled_GA_Simulation/main.cpp A simple example for the usage of the restart function for ga_tools inside the ode_robots simulation. See also ode_robots

- template_tasked_GA_Simulation/main.cpp An example for the usage of the tasked simulation with ga_tools for a scalable set of simulation on many CPU's. So the ga_tool can simulate every individual in one separate thread!

- robot_chain_tasked_GA_Simulation/main.cpp A simple example which calculate the neuron values for the robot chain with the template_tasked_GA_Simulation.