propulate.population

Module Contents

Classes

Individual

Initialize an individual with given parameters.

class propulate.population.Individual(position: MutableMapping[str, str | int | float | Any] | numpy.ndarray, limits: Mapping[str, Tuple[float, float] | Tuple[int, int] | Tuple[str, Ellipsis]], velocity: numpy.ndarray | None = None, generation: int = -1, rank: int = -1)

Initialize an individual with given parameters.

Parameters:
  • generation (int) – The current generation (-1 if unset).

  • rank (int) – The rank (-1 if unset).

__getitem__(key: str) float | int | str

Return decoded value for input key.

__setitem__(key: str, newvalue: float | int | str | Any) None

Encode and set value for given key.

__delitem__(key: str) None

Do not implement deleting items.

__len__() int

Give number of genes, i.e., parameter space dimension. Each categorical variable adds only one dimension.

__contains__(key: str) bool

Check if individual contains key.

values() ValuesView

Return dict values view.

items() ItemsView

Return dict items view.

keys() KeysView

Return dict keys view.

abstract clear() None

Not implemented.

abstract update(*args: Any, **kwargs: Any) None

Not implemented.

__repr__() str

Return string representation of an Individual instance.

__iter__() Generator[str, None, None]

Return standard iterator.

__eq__(other: object) bool

Define equality operator == for class Individual.

Checks for equality of traits, loss, generation, worker rank, birth island, and active status. Other attributes, like migration steps, are not considered.

Parameters:

other (Individual) – Other individual to compare individual under consideration to.

Returns:

True if individuals are the same, false if not.

Return type:

bool

Raises:

TypeError – If other is not an instance or subclass of Individual.

equals(other: object) bool

Define alternative equality check for class Individual.

Checks for equality of traits and loss. Other attributes, like birth island or generation, are not considered.

Parameters:

other (Individual) – The other individual to compare the individual under consideration to.

Returns:

True if individuals are the same, false if not.

Return type:

bool

Raises:

TypeError – If other is not an instance or subclass of Individual.