culebra.abc.Fitness class¶
- class Fitness(values: Sequence[float, ...] | None = None)¶
Bases:
BaseConstruct a default fitness object.
Class attributes¶
- Fitness.names = ()¶
Names of the objectives.
- Fitness.thresholds = ()¶
A list with the similarity thresholds defined for all the objectives. Fitness objects are compared lexicographically. The comparison applies a similarity threshold to assume that two fitness values are similar (if their difference is lower than or equal to the similarity threshold)
- Fitness.weights = ()¶
A
tuplecontaining an integer value for each objective being optimized. The weights are used in the fitness comparison. They are shared among all fitnesses of the same type. When subclassingFitness, the weights must be defined as a tuple where each element is associated to an objective. A negative weight element corresponds to the minimization of the associated objective and positive weight to the maximization.
Class methods¶
- classmethod Fitness.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¶
Methods¶
- Fitness.dominates(other: Fitness, which: slice = slice(None, None, None)) bool¶
Check if this fitness dominates another one.
- Parameters:
- Returns:
Trueif each objective of this fitness is not strictly worse than the corresponding objective of the other and at least one objective is strictly better- Return type:
- Fitness.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
Dunder methods¶
Intended to compare (lexicographically) two fitnesses.

