culebra.abc.Species class

class Species

Bases: Base

Base class for all the species in culebra.

Each solution returned by a Trainer must belong to a species which constraints its parameter values.

Class methods

classmethod Species.load(filename: str) Base

Load a serialized object from a file.

Parameters:

filename (str) – The file name.

Returns:

The loaded object

Raises:

Methods

Species.dump(filename: str) None

Serialize this object and save it to a file.

Parameters:

filename (str) – The file name.

Raises:
abstract Species.is_member(sol: Solution) bool

Check if a solution meets the constraints imposed by the species.

This method must be overridden by subclasses to return a correct value.

Parameters:

sol (Solution) – The solution

Returns:

True if the solution belongs to the species, or False otherwise

Return type:

bool

Private methods

Species._get_repr_properties() dict[str, object]

Return the subset of properties used for __repr__.

Filters and evaluates all class-level @property attributes, returning only those intended for representation purposes. Private properties (names starting with _) are excluded.

Returns:

Mapping of property names to their corresponding values.

Return type:

dict[str, object]