culebra.solution.abc.Individual
class¶
- class Individual(species: Species, fitness_cls: Type[Fitness])¶
Construct a default solution.
- Parameters:
species (
species_cls
) – The species the solution will belong tofitness (Any subclass of
Fitness
) – The solutions’s fitness class
- Raises:
Class attributes¶
Class methods¶
- classmethod Individual.load_pickle(filename: str) Base ¶
Load a pickled object from a file.
- Parameters:
filename (
str
) – The file name.- Raises:
TypeError – If filename is not a valid file name
ValueError – If the filename extension is not
PICKLE_FILE_EXTENSION
Properties¶
Methods¶
- Individual.save_pickle(filename: str) None ¶
Pickle this object and save it to a file.
- Parameters:
filename (
str
) – The file name.- Raises:
TypeError – If filename is not a valid file name
ValueError – If the filename extension is not
PICKLE_FILE_EXTENSION
- abstract Individual.crossover(other: Individual) Tuple[Individual, Individual] ¶
Cross this individual with another one.
This method must be overridden by subclasses to return a correct value.
- Parameters:
other (
Individual
) – The other individual- Raises:
NotImplementedError – if has not been overridden
- Returns:
The two offspring
- Return type:
- abstract Individual.mutate(indpb: float) Tuple[Individual] ¶
Mutate the individual.
This method must be overridden by subclasses to return a correct value.
- Parameters:
indpb (
float
) – Independent probability for each gene to be mutated.- Raises:
NotImplementedError – if has not been overridden
- Returns:
The mutant
- Return type:
Dunder methods¶
Intended to compare (lexicographically) two individuals according to their fitness.
- Individual.__hash__() int ¶
Return the hash number for this solution.
The hash number is used for equality comparisons. Currently is implemented as the hash of the solution’s string representation.