Individual

class evolib.core.individual.Indiv(para=None)[source]

Bases: object

Represents an individual in an evolutionary optimization algorithm.

copy(*, reset_id=True, reset_fitness=False, reset_age=False, reset_evaluation=False, reset_origin=False)[source]

Create a copy of the individual, with optional resets.

Parameters:
  • reset_id (bool) – If True (default), assign a new unique ID to the copy.

  • reset_fitness (bool) – If True, set fitness to None in the copy.

  • reset_age (bool) – If True, set age to 0 in the copy.

  • reset_origin (bool) – If True, set origin = Origin.OFFSPRING

Returns:

A (possibly reset) copy of this individual.

Return type:

Indiv

crossover()[source]

Apply crossover to this individual.

Delegates the crossover process to the underlying parameter object para. This ensures that crossover behavior is defined polymorphically in the specific ParaBase subclass (e.g. Vector, ParaNet, …).

Return type:

None

get_status()[source]

Get a one-line status string of the parameter representation.

Return type:

str

is_child()[source]

Return True if the individual is an offspring.

Return type:

bool

is_parent()[source]

Return True if the individual is a parent.

Return type:

bool

mutate()[source]

Apply mutation to this individual.

Delegates the mutation process to the underlying parameter object para. This ensures that mutation behavior is defined polymorphically in the specific ParaBase subclass (e.g. Vector, ParaNet, …).

Return type:

None

print_status()[source]

Print a human-readable status summary of this individual and its components.

Return type:

None

to_dict()[source]

Return a dictionary with selected attributes for logging or serialization.

Return type:

Dict

age: int

Current age of the individual. 0 means “no limit”.

Type:

age (int)

birth_gen: int

Generation in which this individual was created. Set by the reproduction operator. Defaults to 0 for the initial population.

Type:

birth_gen (int)

exit_gen: int | None

Generation in which this individual was removed from the population. None if still alive. Can be assigned during analysis.

Type:

exit_gen (Optional[int])

extra_metrics: dict[str, float]

Optional extra per-individual metrics for logging.

Type:

extra_metrics (dict[str, float])

fitness: float | None

Fitness value of the individual. None means the individual has not yet been evaluated.

Type:

fitness (float)

heli_reintegrated: bool

True if this individual was reintegrated into the main population after a HELI subpopulation run.

Type:

heli_reintegrated (bool)

heli_seed: bool

True if this individual was created as a HELI seed during micro-evolution incubation.

Type:

heli_seed (bool)

id: str

unique identifier (UUID)

is_elite: bool

Flag to explicitly mark elites for logging/analysis.

Type:

is_elite (bool)

property is_evaluated: bool

Return True if the individual has a valid fitness value.

is_structural_mutant: bool

Indicates whether this individual resulted from a structural mutation (e.g., add/remove neuron, connection, etc.). Used for distinguishing structural from weight-only mutations.

Type:

is_structural_mutant (bool)

max_age: int

Maximum allowed age of the individual.

Type:

max_age (Optional[int])

origin: Origin

Origin of the individual (e.g. Origin.PARENT, Origin.OFFSPRING).

Type:

origin (str)

para: Any

None.

Type:

para (Any)

Type:

Parameter values of the individual. Default

parent_id: str | None

Unique identifier of the parent individual. Used for lineage and survival tracking.

Type:

parent_id (Optional[str])