Package libai.genetics
Class Engine
- java.lang.Object
-
- libai.genetics.Engine
-
public class Engine extends java.lang.Object
Engine class provides complete algorithm to evolve populations of chromosomes, regardless of these kind. This implementation of the genetic algorithm contemplates the elitism variant for the selection. The mutation and cross are more chromosome-dependent that the algorithm-dependent, therefore, chromosomes are instantiated for its class and evaluated through the Fitness instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Chromosome
evolve(int ages)
Evolve the population forages
static java.util.Random
getDefaultRandomGenerator()
protected void
initialize(int chromosomeSize)
Initialize population with sizechromosomeSize
void
setProgressBar(javax.swing.JProgressBar _progress)
-
-
-
Constructor Detail
-
Engine
public Engine(java.lang.Class chromotype, int individuals, int _chromosomeSize, double _pc, double _pm, Fitness _evaluator)
Constructor. Initialize a population ofindividuals
of typechromotype
. Each chromosome has a length of_chromosomeSize
, with a crossing probability of_pc
and a mutation probability of_pm
. To evaluate the fitness of each chromosome will use_evaluator
.- Parameters:
chromotype
- The class for the chromosomesindividuals
- The number of individuals for this population_chromosomeSize
- The size of each chromosome_pc
- The crossing probability._pm
- The mutation probability._evaluator
- The fitness evaluator.
-
-
Method Detail
-
getDefaultRandomGenerator
public static java.util.Random getDefaultRandomGenerator()
-
initialize
protected void initialize(int chromosomeSize)
Initialize population with sizechromosomeSize
- Parameters:
chromosomeSize
- The size of the chromosome.
-
evolve
public Chromosome evolve(int ages)
Evolve the population forages
- Parameters:
ages
-ages
- Returns:
- The best chromosome for all these epochs.
-
setProgressBar
public void setProgressBar(javax.swing.JProgressBar _progress)
-
-