pyneat.species module

Divides a population into species based on genetic distance.

class pyneat.species.GenomeDistanceCache(config)[source]

Bases: object

class pyneat.species.Species(key, generation)[source]

Bases: object

Encapsulates all information about a particular species.

key

A unique identifier for the species.

Type:int
created

The generation in which the species was created.

Type:int
last_improved

The last generation where the fitness of the species improved.

Type:int
members

A dictionary of {genome ID: genome} pairs for each genome in the species.

Type:dict
representative

The genome that is the representative of the species, against which new genomes will be compared to see if they belong in this species.

Type:Genome
fitness

The species fitness.

Type:float
adjusted_fitness

The sum of the adjusted fitnesses for each genome in the species.

Type:float
fitness_history

All previous fitness values. One for each generation this species has survived for.

Type::list:`float`
get_fitnesses()[source]

Get the fitnesses of each genome that belongs to this species.

Returns:The fitness of each genome that belongs to this species.
Return type:list
update(representative, members)[source]

Replace the current individuals with a new set of individuals.

Parameters:
  • representative (Genome) – The genome that is the new representative
  • this species. (for) –
  • members (dict) – A dictionary of genome ID and genome pairs of the new members of the species.
class pyneat.species.SpeciesSet(config, reporters)[source]

Bases: neat.config.DefaultClassConfig

Encapsulates the speciation scheme.

species_set_config

The speciation configuration.

Type:DefaultClassConfig
reporters

The set of reporters that log events.

Type:ReporterSet
species_key_generator

Keeps track of the next species ID.

Type:generator
species

A dictionary of species ID, species pairs.

Type:dict
genome_to_species

A dictionary of genome ID, species ID pairs.

Type:dict
get_species(genome_key)[source]

Get the species to given individual belongs to.

Parameters:genome_key (int) – The unique key of the genome to check.
Returns:The species the individual belongs to.
Return type:Species
get_species_id(genome_key)[source]

Get the species ID of the species the given individual belongs to.

Parameters:genome_key (int) – The unique key of the genome to check.
Returns:The key of the species the individual belongs to.
Return type:int
classmethod parse_config(param_dict)[source]

Parse the speciation parameter values

Parameters:param_dict (dict) – A dictionary of parameter values.
Returns:The speciation configuration.
Return type:DefaultClassConfig
speciate(config, population, generation)[source]

Speciate the population.

Parameters:
  • config (Config) – The global NEAT configuration.
  • population (dict) – A dictionary of genome ID, genome pairs.
  • generation (int) – The current generation.