Galgo: The representation of a Genetic Algorithm

Description Usage Arguments Class Fields and Methods Author(s) References See Also Examples

Description

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.

Usage

 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,
	...)

Arguments

id

A way to identify the object.

populations

A list of populations of any class World, Niche, or user-defined population.

fitnessFunc

The function that will be evaluate any chromosome in the populations. This function should receive two parameteres, the Chromosome object and the parent object (defined as a parameter as well). The parent object is commonly a object of class BigBang when used combined. Theoretically, the fitness function may return a numeric non-negative finite value, but commonly in practice these values are limited from 0 to 1. The offspring factors in class Niche where established using the 0-1 range assumption.

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 fitnessGoal has been reach.

maxGenerations

The maximum number of generations that the GA could evolve.

addGenerations

The number of generations to over-evolve once that goalFitness has been met. Some solutions reach the goal from a large “jump” (or quasi-random mutation) and some other from “plateau”. addGenerations helps to ensure the solutions has been “matured” at least that number of generations.

verbose

Instruct the GA to display the general information about the evolution. When verbose==1 this information is printed every generation. In general every verbose number of generation would produce a line of output. Of course if verbose==0 would not display a thing at all.

callBackFunc

A user-function to be called after every generation. It should receive the Galgo object itself. If the result is NA the GA ends. For instance, if callBackFunc is plot the trace of all generations is nicely viewed in a plot; however, in long runs it can consume time and memory.

data

Any user-data can be stored in this variable (but it is not limited to data, the user can insert any other like myData, mama.mia or whatever in the ... argument).

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).

Class

Package: galgo
Class Galgo

Object
~~|
~~+--Galgo

Directly known subclasses:

public static class Galgo
extends Object

Fields and Methods

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

Author(s)

Victor Trevino. Francesco Falciani Group. University of Birmingham, U.K. http://www.bip.bham.ac.uk/bioinf

References

Goldberg, David E. 1989 Genetic Algorithms in Search, Optimization and Machine Learning. Addison-Wesley Pub. Co. ISBN: 0201157675

See Also

Gene, Chromosome, Niche, World, BigBang, configBB.VarSel(), configBB.VarSelMisc().

Examples

 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
 

galgo documentation built on May 2, 2019, 4:20 a.m.