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.
G1DBase Class - The base class for 1D chromosomes
Parameters: |
|
---|
New in version 0.6: Added te G1DBase class
Appends an item to the end of the list
>>> genome.append(44)
Parameters: |
|
---|
Remove all genes from Genome
Copy genome to ‘g’
>>> genome_origin.copy(genome_destination)
Parameters: |
|
---|
Returns the internal list of the genome
... note:: this method was created to solve performance issues :rtype: the internal list
Returns the list supposed size
Warning
this is different from what the len(obj) returns
Removes an item from the list
>>> genome.remove(44)
Parameters: |
|
---|
Returns a resumed string representation of the Genome
Assigns a list to the internal list of the chromosome
Parameters: |
|
---|
GTreeBase Class - The base class for the tree genomes
Parameters: |
|
---|
New in version 0.6: Added te GTreeBase class
Clone this GenomeBase
Return type: | the clone genome |
---|
Note
If you are planning to create a new chromosome representation, you must implement this method on your class.
Copy the current contents GTreeBase to ‘g’
Parameters: |
|
---|
Note
If you are planning to create a new chromosome representation, you must implement this method on your class.
Return a new list with all nodes
Return type: | the list with all nodes |
---|
Return the tree height
Return type: | the tree height |
---|
Returns the depth of a node
Return type: | the depth of the node, the depth of root node is 0 |
---|
Returns the height of a node
Note
If the node has no childs, the height will be 0.
Return type: | the height of the node |
---|
Return the number of the nodes on the tree starting at the start_node, if start_node is None, then the method will count all the tree nodes.
Return type: | the number of nodes |
---|
Returns a random node from the Tree
Parameters: |
|
---|---|
Return type: | random node |
Return the tree root node
Return type: | the tree root node |
---|
Returns a tree-formated string of the tree. This method is used by the __repr__ method of the tree
Return type: | a string representing the tree |
---|
Creates a cache on the tree, this method must be called every time you change the shape of the tree. It updates the internal nodes list and the internal nodes properties such as depth and height.
Sets the root of the tree
Parameters: |
|
---|
Traversal the tree, this method will call the user-defined callback function for each node on the tree
Parameters: |
|
---|
GTreeNodeBase Class - The base class for the node tree genomes
Parameters: |
|
---|
New in version 0.6: Added te GTreeNodeBase class
Adds a child to the node
Parameters: |
|
---|
Clone this GenomeBase
Return type: | the clone genome |
---|
Note
If you are planning to create a new chromosome representation, you must implement this method on your class.
Copy the current contents GTreeNodeBase to ‘g’
Parameters: |
|
---|
Note
If you are planning to create a new chromosome representation, you must implement this method on your class.
Returns the index-child of the node
Return type: | child node |
---|
Return the childs of the node
Warning
use .getChilds()[:] if you’ll change the list itself, like using childs.reverse(), otherwise the original genome child order will be changed.
Return type: | a list of nodes |
---|
Get the parent node of the node
Return type: | the parent node |
---|
Return True if the node is a leaf
Return type: | True or False |
---|
Replaces a child of the node
Parameters: |
|
---|
Sets the parent of the node
Parameters: |
|
---|
GenomeBase Class - The base of all chromosome representation
Clone this GenomeBase
Return type: | the clone genome |
---|
Note
If you are planning to create a new chromosome representation, you must implement this method on your class.
Copy the current GenomeBase to ‘g’
Parameters: |
|
---|
Note
If you are planning to create a new chromosome representation, you must implement this method on your class.
This is the reproduction function slot, the crossover. You can change the default crossover method using:
genome.crossover.set(Crossovers.G1DListCrossoverUniform)
Called to evaluate genome
Parameters: |
|
---|
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 |
---|
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 |
---|
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.
Called to initialize genome
Parameters: |
|
---|
Called to mutate the genome
Parameters: |
|
---|---|
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.G1DListMutatorSwap)
Clear score and fitness of genome
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.
Parameters: |
|
---|