Description Usage Arguments Class Fields and Methods Author(s) References See Also Examples
Represents a genetic algorithm (GA) itself. The basic GA uses at least one population of chromosomes, a “fitness” function, and a stopping rule (see references).
The Galgo object is not limited to a single population,
it implements a list of populations where any element in the list can be either
a Niche
object or a World
object. Nervertheless, any user-defined object
that implements evolve, progeny, best, max, bestFitness, and maxFitness
methods
can be part of the populations
list.
The “fitness” function is by far the most important part of a GA, it evaluates a Chromosome
to determine
how good the chromosome is respect to a given goal. The function can
be sensitive to data stored in .GlobalEnv
or any other object (see *evaluate()
for further details).
For this package and in the case of the microarray,
we have included several fitness functions to classify samples using different methods.
However, it is not limited for a classification problem for microarray data, because
you can create any fitness function in any given context.
The stopping rule has three options. First, it is simply a desired fitness
value implemented as a numeric fitnessGoal
, and If the maximum fitness value of a population
is equal or higher than fitnessGoal
the GA ends. Second, maxGenerations
determine
the maximum number of generations a GA can evolve. The current generation is increased after
evaluating the fitness function to the entire population list. Thus, if the current
generation reach maxGenerations
the GA stops. Third, if the result of the
user-defined callBackFunc
is NA
the GA stops. In addition, you can always break any
R program using Ctrl-C
(or Esc
in Windows).
When the GA ends many values are used for futher analysis.
Examples are the best chromosome (best
method), its fitness (bestFitness
method),
the final generation (generation
variable), the evolution of the maximum fitness (maxFitnesses
list variable),
the maximum chromosome in each generation (maxChromosome
list variable), and the elapsed time (elapsedTime
variable).
Moreover, flags like goalScored
, userCancelled
, and running
are available.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | Galgo(id=0,
populations=list(),
fitnessFunc=function(...) 1,
goalFitness=0.9,
minGenerations=1,
maxGenerations=100,
addGenerations=0,
verbose=20,
callBackFunc=function(...) 1,
data=NULL,
gcCall=0,
savePopulations=FALSE,
maxFitnesses=c(),
maxFitness=0,
maxChromosomes=list(),
maxChromosome=NULL,
bestFitness=0,
bestChromosome=NULL,
savedPopulations=list(),
generation=0,
elapsedTime=0,
initialTime=0,
userCancelled=FALSE,
goalScored=FALSE,
running=FALSE,
...)
|
id |
A way to identify the object. |
populations |
A list of populations of any class |
fitnessFunc |
The function that will be evaluate any chromosome in the populations. This function should receive two parameteres, the |
goalFitness |
The desired fitness. The GA will evolve until it reach this value or any other stopping rule is met. See description section. |
minGenerations |
The minimum number of generations. A GA evolution will not ends before this generation number even that |
maxGenerations |
The maximum number of generations that the GA could evolve. |
addGenerations |
The number of generations to over-evolve once that |
verbose |
Instruct the GA to display the general information about the evolution. When |
callBackFunc |
A user-function to be called after every generation. It should receive the |
data |
Any user-data can be stored in this variable (but it is not limited to |
gcCall |
How often 10 calls to garbage collection function gc(). This sometimes helps for memory issues. |
savePopulations |
If TRUE, it save the population array in a savedPopulations variable of the galgo object. |
maxFitnesses |
Internal object included for generality not inteded for final users. |
maxFitness |
Internal object included for generality not inteded for final users. |
maxChromosomes |
Internal object included for generality not inteded for final users. |
maxChromosome |
Internal object included for generality not inteded for final users. |
bestFitness |
Internal object included for generality not inteded for final users. |
bestChromosome |
Internal object included for generality not inteded for final users. |
savedPopulations |
Internal object included for generality not inteded for final users. |
generation |
Internal object included for generality not inteded for final users. |
elapsedTime |
Internal object included for generality not inteded for final users. |
initialTime |
Internal object included for generality not inteded for final users. |
userCancelled |
Internal object included for generality not inteded for final users. |
goalScored |
Internal object included for generality not inteded for final users. |
running |
Internal object included for generality not inteded for final users. |
... |
Other user named values to include in the object (like pMutation, pCrossover or any other). |
Package: galgo
Class Galgo
Object
~~|
~~+--
Galgo
Directly known subclasses:
public static class Galgo
extends Object
Methods:
best | Returns the best chromosome. | |
bestFitness | Returns the fitness of the best chromosome. | |
clone | Clones itself and all its objects. | |
evaluate | Evaluates all chromosomes with a fitness function. | |
evolve | Evolves the chromosomes populations of a Galgo (Genetic Algorithm). | |
generateRandom | Generates random values for all populations in the Galgo object. | |
length | Gets the number of populations defined in the Galgo object. | |
max | Returns the chromosome whose current fitness is maximum. | |
maxFitness | Returns the fitness of the maximum chromosome. | |
plot | Plots information about the Galgo object. | |
print | Prints the representation of a Galgo object. | |
refreshStats | Updates the internal values from the current populations. | |
reInit | Erases all internal values in order to re-use the object. | |
summary | Prints the representation and statistics of the galgo object. | |
Methods inherited from Object:
as.list, unObject, $, $<-, [[, [[<-, as.character, attach, clone, detach, equals, extend, finalize, getFields, getInstanciationTime, getStaticInstance, hasField, hashCode, ll, load, objectSize, print, save
Victor Trevino. Francesco Falciani Group. University of Birmingham, U.K. http://www.bip.bham.ac.uk/bioinf
Goldberg, David E. 1989 Genetic Algorithms in Search, Optimization and Machine Learning. Addison-Wesley Pub. Co. ISBN: 0201157675
Gene
,
Chromosome
,
Niche
,
World
,
BigBang
,
configBB.VarSel
(),
configBB.VarSelMisc
().
1 2 3 4 5 6 7 8 9 10 | cr <- Chromosome(genes=newCollection(Gene(shape1=1, shape2=100),5))
ni <- Niche(chromosomes = newRandomCollection(cr, 10))
wo <- World(niches=newRandomCollection(ni,2))
ga <- Galgo(populations=list(wo), goalFitness = 0.75, callBackFunc=plot,
fitnessFunc=function(chr, parent) 5/sd(as.numeric(chr)))
ga
evolve(ga)
# missing a classification example
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.