geneticengine.solutions

Submodules

Attributes

__ALL__

Classes

TreeNode

Base class for protocol classes.

Individual

Helper class that provides a standard way to create an ABC using

Package Contents

class geneticengine.solutions.TreeNode

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
gengy_labeled: bool
gengy_distance_to_term: int
gengy_nodes: int
gengy_weighted_nodes: int
gengy_types_this_way: dict[type, list[Any]]
gengy_init_values: tuple[Any]
gengy_synthesis_context: LocalSynthesisContext
class geneticengine.solutions.Individual(metadata=None)

Bases: Generic[P], abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:

metadata (dict[str, Any] | None)

fitness_store: weakref.WeakKeyDictionary[geneticengine.problems.Problem, geneticengine.problems.Fitness]
metadata: dict[str, Any]
abstractmethod get_phenotype()
Return type:

P

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)

geneticengine.solutions.__ALL__