Individual¶
- class evolib.core.individual.Indiv(para=None)[source]¶
Bases:
objectRepresents 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:
- 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
- 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
- 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)
- 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)