SELAB3 Python Code
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
morphevo.genome.GenotypeGraph Class Reference

GenotypeGraph is a directed graph encoding for the genome of an arm. More...

Public Member Functions

None __init__ (self, float anchor_length=1.0)
 
None add_module (self, ModuleType module_type, float length)
 Add a module to the graph, will join nodes if type is the same as last node. More...
 
GenotypeGraphNode get_last_node (self)
 Get the last node in the graph encoding. More...
 
GenotypeGraph mutate (self)
 Create a new graph encoding that is a mutation of itself. More...
 
int|None get_change_index (self, float chance)
 Get the index where a change (addition of deletion) can occur. More...
 
Module get_random_module (self)
 Iterator to iterate graph module after module instead of node after node. More...
 
def iterate_graph (self, bool ignore_anchor=True)
 Iterator to iterate graph module after module instead of node after node. More...
 
def __iter__ (self)
 
def __len__ (self)
 Return amount of modules in the arm without anchor. More...
 

Public Attributes

 anchor
 

Detailed Description

GenotypeGraph is a directed graph encoding for the genome of an arm.

Constructor & Destructor Documentation

◆ __init__()

None morphevo.genome.GenotypeGraph.__init__ (   self,
float   anchor_length = 1.0 
)
Parameters
anchor_lengthThe length of the anchor module.

Member Function Documentation

◆ __len__()

def morphevo.genome.GenotypeGraph.__len__ (   self)

Return amount of modules in the arm without anchor.

◆ add_module()

None morphevo.genome.GenotypeGraph.add_module (   self,
ModuleType  module_type,
float  length 
)

Add a module to the graph, will join nodes if type is the same as last node.

Parameters
module_typeThe type of the module.
lengthThe length of the module.

◆ get_change_index()

int | None morphevo.genome.GenotypeGraph.get_change_index (   self,
float  chance 
)

Get the index where a change (addition of deletion) can occur.

This depends on the outcome of a chance. If chance fails None is returned to represent no mutation.

Returns
Index of mutation or None.

◆ get_last_node()

GenotypeGraphNode morphevo.genome.GenotypeGraph.get_last_node (   self)

Get the last node in the graph encoding.

Returns
The last node in the graph encoding.

◆ get_random_module()

Module morphevo.genome.GenotypeGraph.get_random_module (   self)

Iterator to iterate graph module after module instead of node after node.

Returns
Module

◆ iterate_graph()

def morphevo.genome.GenotypeGraph.iterate_graph (   self,
bool   ignore_anchor = True 
)

Iterator to iterate graph module after module instead of node after node.

Parameters
ignore_anchorChoice to skip anchor in iteration.

◆ mutate()

GenotypeGraph morphevo.genome.GenotypeGraph.mutate (   self)

Create a new graph encoding that is a mutation of itself.

Returns
The mutated graph encoding.

The documentation for this class was generated from the following file: