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

A class that represents a Genome, it contains an encoding, methods for evaluation, methods to mutate and methods to compare to other genomes. More...

Public Member Functions

None __init__ (self, Optional[Genome] parent_genome=None)
 Create a Genome, if no parent is given a random encoding will be generated. More...
 
None mutate (self)
 Mutate the encoding of the genome.
 
str get_urdf (self)
 Get the urdf string for an encoding. More...
 
float calculate_diversity_from (self, Genome other_genome)
 Calculate the diversity to another genome. More...
 
Genome crossover (self, Genome other_genome)
 Do a crossover with another genome. More...
 
int get_amount_of_joints (self)
 Count the amount of joints a genotype represents. More...
 
int __hash__ (self)
 

Public Attributes

 amount_of_modules
 
 genotype_graph
 
 workspace
 
 genome_id
 

Detailed Description

A class that represents a Genome, it contains an encoding, methods for evaluation, methods to mutate and methods to compare to other genomes.

Constructor & Destructor Documentation

◆ __init__()

None morphevo.genome.Genome.__init__ (   self,
Optional[Genome]   parent_genome = None 
)

Create a Genome, if no parent is given a random encoding will be generated.

Otherwise, it will use the mutated encoding of its parent as encoding.

Parameters
parent_genomeThe optional parent.

Member Function Documentation

◆ calculate_diversity_from()

float morphevo.genome.Genome.calculate_diversity_from (   self,
Genome  other_genome 
)

Calculate the diversity to another genome.

This function compares modules on the same level of the arm. If a module is a different type the difference for that level is 1 on the amount of modules in the longest arm (same for missing modules). Else you calculate the percentage of length difference between the modules.

Parameters
other_genomeThe genome you want to compare with.
Returns
A percentage on how different the genomes are.

◆ crossover()

Genome morphevo.genome.Genome.crossover (   self,
Genome  other_genome 
)

Do a crossover with another genome.

For every module you will run a chance to determine of which parent you will include its module. If one parent is shorter the top modules of the other parent can still be included at the end of the arm.

Parameters
other_genomeThe other genome to crossover with.
Returns
A new genome with an encoding that is the result of crossover on its parents.

◆ get_amount_of_joints()

int morphevo.genome.Genome.get_amount_of_joints (   self)

Count the amount of joints a genotype represents.

Returns
amount of joints.

◆ get_urdf()

str morphevo.genome.Genome.get_urdf (   self)

Get the urdf string for an encoding.

Returns
The urdf string for an encoding.

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