Package de.sfuhrm.genetic

Framework for a calculating genetic algorithm optimization.

Steps for usage

You are usually conducting work with these classes:
  1. Instantiate your AlgorithmDefinition with how to create, update and evaluate so-called hypothesis.
  2. Create a GeneticAlgorithm with the help of a GeneticAlgorithmBuilder.
  3. Call either GeneticAlgorithm.findMaximum() for the generational loop to be executed for you (less control), or GeneticAlgorithm.calculateNextGeneration(java.util.List) for one generational step to be executed for you (more control).
  4. Evaluate the results, and eventually adapt the parameters in the GeneticAlgorithmBuilder.

What's a hypothesis

A hypothesis is a model of a possible solution that can be any Java object. A hypothesis needs to be evaluated with a fitness towards the fitness in respect to the solution of the problem. Examples:
  • A hypothesis for solving a 9x9 Sudoku can be a two-dimensional 9x9 int array.
  • A hypothesis for one Tic-Tac-Toe move can be a x/y coordinate pair of the next move.

Genetic operations in AlgorithmDefinition

The genetic operations are defined on hypothesis basically the following:
  • Random initialization: A (usually valid) hypothesis is generated using random values for its components / genes.
  • Mutation: A single gene/bit/character/cell of the hypothesis is flipped to another (usually valid) value.
  • Cross-over: Two hypothesis are combined at a so-called cross-over point and are recombined to typically two off-springs. The critical part in the cross-over is that the two off-springs should be valid. This restricts the genetic representation of the hypothesis.
Author:
Stephan Fuhrmann