GenomeBase – the genomes base module

This module have the class which every representation extends, if you are planning to create a new representation, you must take a inside look into this module.

class GenomeBase.GenomeBase

GenomeBase Class - The base of all chromosome representation

clone()

Clone this GenomeBase

Return type:the clone genome
copy(g)

Copy the current GenomeBase to ‘g’

Parameter:g – the destination genome
crossover

This is the reproduction function slot, the crossover. You can change the default crossover method using:

genome.crossover.set(Crossovers.G1DListCrossoverUniform)
evaluate(**args)

Called to evaluate genome

Parameter:args – this parameters will be passes to the evaluator
evaluator

This is the evaluation function slot, you can add a function with the set method:

genome.evaluator.set(eval_func)
getFitnessScore()

Get the Fitness Score of the genome

Return type:genome fitness score
getParam(key, nvl=None)

Gets an initialization parameter

Example:
>>> genome.getParam("rangemax")
100
Parameters:
  • key – the key of param
  • nvl – if the key doesn’t exist, the nvl will be returned
getRawScore()

Get the Raw Score of the genome

Return type:genome raw score
initializator

This is the initialization function of the genome, you can change the default initializator using the function slot:

genome.initializator.set(Initializators.G1DListInitializatorAllele)

In this example, the initializator Initializators.G1DListInitializatorAllele() will be used to create the initial population.

initialize(**args)

Called to initialize genome

Parameter:args – this parameters will be passed to the initializator
mutate(**args)

Called to mutate the genome

Parameter:args – this parameters will be passed to the mutator
mutator

This is the mutator function slot, you can change the default mutator using the slot set function:

genome.mutator.set(Mutators.G1DListMutatorSwap)
resetStats()
Clear score and fitness of genome
setParams(**args)

Set the initializator params

Example:
>>> genome.setParams(rangemin=0, rangemax=100, gauss_mu=0, gauss_sigma=1)
Parameter:args – this params will saved in every chromosome for genetic op. use

Recent Blog Posts

Previous topic

Scaling – scaling schemes module

Next topic

GAllele – the genome alleles module

This Page