geneticengine.solutions.individual

Module Contents

Classes

Individual

Abstract base class for generic types.

Attributes

G

P

geneticengine.solutions.individual.G
geneticengine.solutions.individual.P
exception geneticengine.solutions.individual.IndividualNotEvaluatedException

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class geneticengine.solutions.individual.Individual(genotype, representation, metadata=None)

Bases: Generic[G, P]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
genotype: G
representation: geneticengine.representations.api.Representation[G, P]
phenotype: P | None
fitness_store: weakref.WeakKeyDictionary[geneticengine.problems.Problem, geneticengine.problems.Fitness]
metadata: dict[str, Any]
get_phenotype()
has_fitness(problem)
Parameters:

problem (geneticengine.problems.Problem)

Return type:

bool

set_fitness(problem, fitness)
Parameters:
get_fitness(problem=None)
Parameters:

problem (geneticengine.problems.Problem | None)

Return type:

geneticengine.problems.Fitness

ensure_fitness(problem)
Parameters:

problem (geneticengine.problems.Problem)

static key_function(problem)
Parameters:

problem (geneticengine.problems.Problem)

__str__()

Return str(self).

Return type:

str