culebra.solution.parameter_optimization.Solution class¶
- class Solution(species: Species, fitness_cls: type[Fitness], values: Sequence[int | float] | None = None)¶
Bases:
SolutionConstruct a default solution.
Class attributes¶
Class methods¶
- classmethod Solution.load(filename: str) Base¶
Load a serialized object from a file.
- Parameters:
filename (str) – The file name.
- Returns:
The loaded object
- Raises:
TypeError – If filename is not a valid file name
ValueError – If the filename extension is not
SERIALIZED_FILE_EXTENSION
Properties¶
- property Solution.named_values_cls: type[NamedTuple]¶
Named tuple class to hold the parameter values.
- Return type:
- property Solution.values: NamedTuple[int | float, ...]¶
Parameter values evolved by the solution.
- Return type:
- Setter:
Set new parameter values.
- Parameters:
- Raises:
ValueError – If the values do not meet the species constraints
Methods¶
- Solution.dump(filename: str) None¶
Serialize 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
SERIALIZED_FILE_EXTENSION
Private methods¶
Dunder methods¶
Intended to compare (lexicographically) two solutions according to their fitness.
- Solution.__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.
- Return type:

