This representation is a 2D Binary String, the string looks like this matrix:
00101101010 00100011010 00101101010 10100101000
Initializator
Initializators.G2DBinaryStringInitializator()
The Binatry String Initializator for G2DBinaryString
Mutator
Mutators.G2DBinaryStringMutatorFlip()
The Flip Mutator for G2DBinaryString
Crossover
Crossovers.G2DBinaryStringXSinglePoint()
The Single Point Crossover for G2DBinaryString
New in version 0.6: Added the module G2DBinaryString
G3DBinaryString Class - The 2D Binary String chromosome
Inheritance diagram for G2DBinaryString.G2DBinaryString:
>>> genome = G2DBinaryString.G2DBinaryString(10, 12)
Parameters: |
|
---|
Return a new instace copy of the genome
Return type: | the G2DBinaryString clone instance |
---|
Copy genome to ‘g’
>>> genome_origin.copy(genome_destination)
Parameter: | g – the destination G2DBinaryString instance |
---|
This is the reproduction function slot, the crossover. You can change the default crossover method using:
genome.crossover.set(Crossovers.G2DBinaryStringXUniform)
Called to evaluate genome
Parameter: | args – this parameters will be passes to the evaluator |
---|
This is the evaluation function slot, you can add a function with the set method:
genome.evaluator.set(eval_func)
Get the Fitness Score of the genome
Return type: | genome fitness score |
---|
Return the specified gene of List
>>> genome.getItem(3, 1)
0
Parameters: |
|
---|---|
Return type: | the item at x,y position |
Gets an internal parameter
>>> genome.getParam("rangemax")
100
Note
All the individuals of the population shares this parameters and uses the same instance of this dict.
Parameters: |
|
---|
Get the Raw Score of the genome
Return type: | genome raw score |
---|
Returns a tuple (height, widht)
>>> genome.getSize()
(3, 2)
This is the initialization function of the genome, you can change the default initializator using the function slot:
genome.initializator.set(Initializators.G2DBinaryStringInitializator)
In this example, the initializator Initializators.G1DBinaryStringInitializator() will be used to create the initial population.
Called to initialize genome
Parameter: | args – this parameters will be passed to the initializator |
---|
Called to mutate the genome
Parameter: | args – this parameters will be passed to the mutator |
---|---|
Return type: | the number of mutations returned by mutation operator |
This is the mutator function slot, you can change the default mutator using the slot set function:
genome.mutator.set(Mutators.G2DBinaryStringMutatorSwap)
Set the specified gene of List
>>> genome.setItem(3, 1, 0)
Parameters: |
|
---|
Set the internal params
>>> genome.setParams(rangemin=0, rangemax=100, gauss_mu=0, gauss_sigma=1)
Note
All the individuals of the population shares this parameters and uses the same instance of this dict.
Parameter: | args – this params will saved in every chromosome for genetic op. use |
---|