culebra.solution.parameter_optimization.Species class

class Species(lower_bounds: Sequence[int | float], upper_bounds: Sequence[int | float], types: Sequence[type[int] | type[float]] | None = None, names: Sequence[str] | None = None)

Bases: Species

Create a new species.

Parameters:
Raises:
  • TypeError – If any of the attributes is not a Sequence

  • ValueError – If the sequences have different lengths

  • ValueError – If the sequences are empty

  • ValueError – If the type of any bound does not match with its corresponding type in types

  • ValueError – If any lower bound is greater to or equal than its corresponding upper bound

  • ValueError – If any name is not an instance of str

  • ValueError – If there is any repeated name

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:

Properties

property Species.lower_bounds: tuple[int | float, ...]

Lower bound for each parameter.

Return type:

tuple[int | float]

property Species.names: tuple[str, ...]

Name of each parameter.

Return type:

tuple[str]

property Species.num_params: int

Number of parameters to be optimized.

Return type:

int

property Species.types: tuple[type[int] | type[float], ...]

Type of each parameter.

Return type:

tuple[type]

property Species.upper_bounds: tuple[int | float, ...]

Upper bound for each parameter.

Return type:

tuple[int | float]

Methods

Species.dump(filename: str) None

Serialize this object and save it to a file.

Parameters:

filename (str) – The file name.

Raises:
Species.is_member(sol: Solution) bool

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

Parameters:

sol (Solution) – The solution

Returns:

True if the solution belongs to the species. False otherwise

Return type:

bool