GenePools class in Global context

Manages all genotypes in the experiment, organized in one or more groups. Some functions refer to the "selected genotype" i.e. the genotype number "GenePools.genotype" in the pool number "GenePools.group". For example to access the first genoype in the first group you could do:
GenePools.group=0; GenePools.genotype=0; var name=Genotype.name;
However, the preferred way doesn't refer to the static Genotype object:
var name=GenePools[0][0].name;

Apart from the Genotypes in the group, there is also one temporary Genotype object used by genetic operators and some functions from GenePools. Genotype points to that object when "GenePools.genotype"=-1. The following code accesses that object before adding it to the genotype group:
GenePools.newGenotype("X");
//makes the temporary object from the "X" genotype, GenePools.genotype is now -1
GenePools.mutateSelected();
//the temporary object is mutated
Genotype.info="my favorite genotype";
//modify the temporary object
GenePools.copySelected(0);
//copy the current, i.e. temporary genotype to the genotype group #0

26 members:

integer genotype
integer

selected genotype

index of the currently selected genotype or -1 if no genotype is selected

integer group
integer

selected group

index of the currently selected group (gene pool)

integer size
integer

Number of groups

function addGroup
doesn't return a value

function addGroup(string name)

add genotype group

function addPerformanceFromCreature
doesn't return a value

function addPerformanceFromCreature()

Updates the current Genotype's performance values merging them with the current Creture's performance. It assumes the Genotype.popsiz has a reasonable value and performs the proper weighting. Use your own function instead if these conditions are not met in your experiment.

function clear
doesn't return a value

function clear()

remove all groups except the first one

function clearGroup
doesn't return a value

function clearGroup(integer index)
function copySelected
doesn't return a value

function copySelected(integer groupindex)

copy selected genotype to another group

function crossoverSelected
doesn't return a value

function crossoverSelected(integer other_index)

Crossover selected genotype with another one (from the genotype group). The resulting genotype is stored in the static Genotype object detached from the genotype group. After calling this function GenePools.genotype is -1 indicating that no genotype from the group is selected.

function deleteGroup
doesn't return a value

function deleteGroup(integer index)

remove genotype group

function deleteOne
doesn't return a value

function deleteOne(integer genotype_index)

delete one individual from the gene pool = decrease popsiz and delete the genotype if the popsiz goes to 0

function deleteSelected
doesn't return a value

function deleteSelected()

delete selected genotype from the gene pool (uses the selected genotype object)

function findGenotype
returns integer

function findGenotype()

find a genotype matching the current genotype. It only makes sense when the current genotype is a result of the genetic operator.

function findGenotypeForCreature
returns integer

function findGenotypeForCreature()

find a genotype matching the selected creature

function get
returns GenePool

function get(integer index)
function getFromCreature
doesn't return a value

function getFromCreature()

Copy a genotype from the selected creature. The resulting genotype is stored in the static Genotype object detached from the genotype group.

function getFromCreatureObject
doesn't return a value

function getFromCreatureObject(Creature)

Copy a genotype from the creature object passed in argument. The resulting genotype is stored in the static Genotype object detached from the genotype group.

function likeThisRoulette
returns integer

function likeThisRoulette(float minimum_similarity)

get random genotype similar to the selected one, fitness proportional

function mutateSelected
doesn't return a value

function mutateSelected()

Mutate selected genotype. The resulting genotype is stored in the static Genotype object detached from the genotype group. After calling this function GenePools.genotype is -1 indicating that no genotype from the group is selected.

function newGenotype
doesn't return a value

function newGenotype(string genotype)

Make the new genotype from the supplied string and select the genotype. The resulting genotype is stored in the static Genotype object detached from the genotype group. After calling this function GenePools.genotype is -1 indicating that no genotype from the group is selected. (call "copySelected" if you want to add this gentype to the genotype group)

function random
returns integer

function random()

get random genotype

function randomLikeThis
returns integer

function randomLikeThis(float minimum_similarity)

get random genotype similar to the selected one

function revroulette
returns integer

function revroulette()

get reverse fitness proportional genotype

function roulette
returns integer

function roulette()

get fitness proportional genotype

function tournament
returns integer

function tournament(integer genotypes_in_tournament)

get tournament winner genotype

function worst
returns integer

function worst()

get worst genotype


Global context