In this tutorial we shows how to use SimpleGA,
a standard GeneticAlgorithm subclass. It represents the classical
configuration of a genetic algorithm, using only the main operators
(selector, crossover and mutator) in a very simple pipe. It's useful
when no complex operators are needed and a fast ga set-up is required.
The goal of this tutorial is to minimize the Shannon entropy of a set of
values within the range [0,1]. Package: jenes.tutorial.old.problem4 Files: EntropyProblem.java 1. Choose a problem suitable chromosome and create the initial population;A DoubleChromosome is suitable for this problem with each allele within the range [0,1].
2. Set-up the genetic algorithm To use SimpleGA we have to subclass it and implement the evaluateIndividual method. A possible implementation is showed below.
The fitness of each individual is equal to the entropy value according
to the classical entropy definition: entropy is the measure of the
amount of information that is missing before reception and is sometimes
referred to as Shannon entropy.
3. Choose the operators to be used by genetic algorithm and add them as stages in the gaWith SimpleGA our genetic algorithm is already configured regarding the operators to use. By default it uses tournament selection, one-point crossover (with probability= 0.8) and simple mutator (with probability=0.2). Besides SimpleGA uses by default a random replacing strategy. Anyway, it's possibile to modify this default configuration configuring operators and elitism strategy as you want. In our case we use the default SimpleGA configuration.4. Customize the genetic algorithmThe whole configuration code is listed below:
|
Tutorials >