|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jenes.GeneticAlgorithm<T> jenes.algorithms.SimpleGA<T>
T
- extends Chromosomepublic abstract class SimpleGA<T extends Chromosome>
A facade providing a simple interface to GeneticAlgorithm.
SimpleGA
implements a three stages genetic algorithm made of
TournamentSelector
(default) or RouletteWheelSelector
OnePointCrossover
(default) or TwoPointsCrossover
SimpleMutator
SimpleGA
algorithm.
SimpleGA
is abstract as the evalation of individuals is problem dependent. It is possible
to subclass SimpleGA
in different ways. For instance
provides an anonimous inner subclass ofSimpleGAsga = new SimpleGA (pop, GENERATION_LIMIT) { protected void evaluateIndividual(Individual individual) { // Make your evaluation here ... } };
SimpleGA
.
Constructors allows to decide which selection method (i.e. Tournament or Roulette Wheel) or crossover method (i.e. One Point or Two Points) to adopt. Also crossover and mutation probability can be specified at constraction time.
SimpleGA
is a GeneticAlgorithm
subclass. Thus, it is possible to use all inheritated
methods and properties. For example,
sga.setElitism(10); sga.setMutationRate(0.2); sga.setBiggerIsBetter(false); sga.evolve();
Among the available method, there are those able to alter the algorithm's body. Although
this is possible, we discourage from using them as this would result in lesser comphrensible code. Instead we suggest
to directly subclass GeneticAlgorithm
.
Nested Class Summary | |
---|---|
static class |
SimpleGA.CrossoverMethod
Provides the available crossover methods |
static class |
SimpleGA.SelectionMethod
Provides the available selection methods |
Nested classes/interfaces inherited from class jenes.GeneticAlgorithm |
---|
GeneticAlgorithm.ElitismStrategy, GeneticAlgorithm.ResizeStrategy, GeneticAlgorithm.Statistics |
Field Summary | |
---|---|
static SimpleGA.CrossoverMethod |
DEFAULT_CROSSOVER_METHOD
The default crossover method |
static double |
DEFAULT_CROSSOVER_PROBABILITY
The default crossover probability |
static int |
DEFAULT_ELITISM
The default elitism factor |
static GeneticAlgorithm.ElitismStrategy |
DEFAULT_ELITISM_STRATEGY
The default elitism strategy |
static int |
DEFAULT_GENERATION_LIMIT
The default generation limit |
static double |
DEFAULT_MUTATION_PROBABILITY
The default mutation probability |
static SimpleGA.SelectionMethod |
DEFAULT_SELECTION_METHOD
The default selection method |
Fields inherited from class jenes.GeneticAlgorithm |
---|
algorithmListeners, body, DEFAULT_HISTORY_SIZE, elitism, elitismStrategy, generation, generationLimit, generationListeners, initialPopulation, MAX_HISTORY_SIZE, MIN_HISTORY_SIZE, random, randomization, resizeStrategy, statistics |
Constructor Summary | |
---|---|
SimpleGA(Population<T> population)
Builds a new SimpleGa with the default generation limit, crossover and mutation probability, elitism, selection and crossover methods, and elitism strategy. |
|
SimpleGA(Population<T> population,
int generations)
Builds a new SimpleGa with the default crossover and mutation probability, elitism, selection and crossover methods, and elitism strategy. |
|
SimpleGA(Population<T> population,
int generations,
double crossover,
double mutation)
Builds a new SimpleGa with the default elitism, selection and crossover methods, and elitism strategy. |
|
SimpleGA(Population<T> population,
int generations,
double crossover,
double mutation,
int elitism)
Builds a new SimpleGa with the default selection and crossover methods, and elitism strategy. |
|
SimpleGA(Population<T> population,
int generations,
double crossover,
double mutation,
int elitism,
SimpleGA.SelectionMethod selmethod,
SimpleGA.CrossoverMethod crossmethod)
Builds a new SimpleGa with the default elitism strategy. |
|
SimpleGA(Population<T> population,
int generations,
double crossover,
double mutation,
int elitism,
SimpleGA.SelectionMethod selmethod,
SimpleGA.CrossoverMethod crossmethod,
GeneticAlgorithm.ElitismStrategy es)
Builds a new SimpleGa. |
Method Summary | |
---|---|
Crossover<T> |
getCrossover()
Returns the crossover used by this genetic algorithm. |
double |
getCrossoverProbability()
Returns the crossover probability. |
double |
getMaxIllegalRate()
Returns the maximum rate of illegal individuals. |
double |
getMutationProbability()
Returns the mutation probability. |
Mutator<T> |
getMutator()
Returns the mutator used by this genetic algorithm. |
Selector<T> |
getSelector()
Returns the selector used by this genetic algorithm |
void |
setCrossoverProbability(double p)
Sets the crossover probability. |
void |
setMaxIllegalRate(double rate)
Sets the max rate of illegal individuals. |
void |
setMutationProbability(double p)
Sets the mutation probability. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_GENERATION_LIMIT
public static final double DEFAULT_CROSSOVER_PROBABILITY
public static final double DEFAULT_MUTATION_PROBABILITY
public static final int DEFAULT_ELITISM
public static final SimpleGA.SelectionMethod DEFAULT_SELECTION_METHOD
public static final SimpleGA.CrossoverMethod DEFAULT_CROSSOVER_METHOD
public static final GeneticAlgorithm.ElitismStrategy DEFAULT_ELITISM_STRATEGY
Constructor Detail |
---|
public SimpleGA(Population<T> population)
population
- the initial populationpublic SimpleGA(Population<T> population, int generations)
population
- the initial populationgenerations
- the generation limitpublic SimpleGA(Population<T> population, int generations, double crossover, double mutation)
population
- the initial populationgenerations
- the generation limitcrossover
- the crossover probabilitymutation
- the mutation probabilitypublic SimpleGA(Population<T> population, int generations, double crossover, double mutation, int elitism)
population
- the initial populationgenerations
- the generation limitcrossover
- the crossover probabilitymutation
- the mutation probabilityelitism
- the elisitm factorpublic SimpleGA(Population<T> population, int generations, double crossover, double mutation, int elitism, SimpleGA.SelectionMethod selmethod, SimpleGA.CrossoverMethod crossmethod)
population
- the initial populationgenerations
- the generation limitcrossover
- the crossover probabilitymutation
- the mutation probabilityelitism
- the elisitm factorselmethod
- the selector method to usecrossmethod
- the crossover method to usepublic SimpleGA(Population<T> population, int generations, double crossover, double mutation, int elitism, SimpleGA.SelectionMethod selmethod, SimpleGA.CrossoverMethod crossmethod, GeneticAlgorithm.ElitismStrategy es)
population
- the initial populationgenerations
- the generation limitcrossover
- the crossover probabilitymutation
- the mutation probabilityelitism
- the elisitm factorselmethod
- the selector method to usecrossmethod
- the crossover method to usees
- the elitism strategy to useMethod Detail |
---|
public final Selector<T> getSelector()
public final double getMaxIllegalRate()
public final void setMaxIllegalRate(double rate)
rate
- the new maximum rate of illegal individualspublic final Crossover<T> getCrossover()
public final double getCrossoverProbability()
public final void setCrossoverProbability(double p)
p
- the new crossover probabilitypublic final Mutator<T> getMutator()
public final double getMutationProbability()
public final void setMutationProbability(double p)
p
- the new mutation probability
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |