jenes.tutorials.problem2
Class PatternGA
java.lang.Object
jenes.GeneticAlgorithm<IntegerChromosome>
jenes.tutorials.problem2.PatternGA
public class PatternGA
- extends GeneticAlgorithm<IntegerChromosome>
Tutorial showing how to extend GeneticAlgorithm
and how to use
the flexible and configurable breeding structure in Jenes.
The problem consists in searching a pattern of integers with a given precision.
Solutions flow through two different crossovers in parallel. Some are processed by
a single point crossover, the other by a double point crossover.
After solutions are mutated.
This class implements the algorithm by extending GeneticAlgorithm
.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Luigi Troiano, Pierpaolo Lombardi
Fields inherited from class jenes.GeneticAlgorithm |
algorithmListeners, body, DEFAULT_GENERATION_LIMIT, DEFAULT_HISTORY_SIZE, elitism, elitismStrategy, fullEvaluationForced, generation, generationLimit, generationListeners, initialPopulation, MAX_HISTORY_SIZE, MIN_HISTORY_SIZE, random, randomization, resizeStrategy, statistics |
Methods inherited from class jenes.GeneticAlgorithm |
addAlgorithmEventListener, addGenerationEventListener, addStage, applyElitism, evaluatePopulation, evaluatePopulation, evolve, evolve, evolve, getBody, getCurrentPopulation, getElitism, getElitismStrategy, getGeneration, getGenerationLimit, getHistoryAt, getHistorySize, getInitialPopulation, getNextPopulation, getRandomization, getResizeStrategy, getStatistics, isBiggerBetter, isFullEvaluationForced, onGeneration, onInit, onStart, onStop, randomizeIndividual, randomizePopulation, removeAlgorithmEventListener, removeGenerationEventListener, setBiggerIsBetter, setElitism, setElitismStrategy, setFullEvaluationForced, setGenerationLimit, setHistorySize, setRandomization, setRandomization, setResizeStrategy, start, stop, toString, updateStatistics |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
PatternGA
public PatternGA(Population<IntegerChromosome> pop,
int numGen)
setTarget
public void setTarget(int[] target)
setPrecision
public void setPrecision(int precision)
evaluateIndividual
public void evaluateIndividual(Individual<IntegerChromosome> individual)
- Description copied from class:
GeneticAlgorithm
- Evaluates a single individual. This evaluation of individuals is
specifically related to the problem to solve, thus it is an abstract
method requiring an implementation by the sublass.
- Specified by:
evaluateIndividual
in class GeneticAlgorithm<IntegerChromosome>
- Parameters:
individual
- the individual to be evaluated
end
protected boolean end()
- Description copied from class:
GeneticAlgorithm
- Provides the algorithm termination condition. By default it returns false
as reaching the generation limit is the sole ending criterion Subclasses
can override this method in order to provide a problem specific
termination condition.
- Overrides:
end
in class GeneticAlgorithm<IntegerChromosome>
- Returns:
- true if the ga evolution reached the termination condition, false
otherwise