propulate.pollinator
Module Contents
Classes
Initialize |
Attributes
- propulate.pollinator.log
- class propulate.pollinator.Pollinator(loss_fn: Callable | Generator[float, None, None], propagator: propulate.propagators.Propagator, rng: random.Random, island_idx: int = 0, island_comm: mpi4py.MPI.Comm = MPI.COMM_WORLD, propulate_comm: mpi4py.MPI.Comm = MPI.COMM_WORLD, worker_sub_comm: mpi4py.MPI.Comm = MPI.COMM_SELF, generations: int = 0, checkpoint_path: pathlib.Path | str = Path('./'), migration_topology: numpy.ndarray | None = None, migration_prob: float = 0.0, emigration_propagator: Type[propulate.propagators.Propagator] = SelectMin, immigration_propagator: Type[propulate.propagators.Propagator] = SelectMax, island_displs: numpy.ndarray | None = None, island_counts: numpy.ndarray | None = None, surrogate_factory: Callable[[], propulate.surrogate.Surrogate] | None = None)
Bases:
propulate.propulator.PropulatorInitialize
Pollinatorwith given parameters.- Parameters:
loss_fn (Union[Callable, Generator[float, None, None]]) – The loss function to be minimized.
propagator (propulate.propagators.Propagator) – The propagator to apply for breeding.
rng (random.Random) – The separate random number generator for the Propulate optimization.
island_idx (int, optional) – The island index. Default is 0.
island_comm (MPI.Comm, optional) – The intra-island communicator for communication within this island. Default is
MPI.COMM_WORLD.propulate_comm (MPI.Comm, optional) – The Propulate world communicator, consisting of rank 0 of each worker’s sub communicator. Default is
MPI.COMM_WORLD.worker_sub_comm (MPI.Comm, optional) – The sub communicator for each (multi rank) worker. Default is
MPI.COMM_SELF.generations (int, optional) – The number of generations to run. Default is -1, i.e., run into wall-clock time limit.
checkpoint_path (pathlib.Path, optional) – The path where checkpoints are loaded from and stored. Default is current working directory.
migration_topology (numpy.ndarray, optional) – The 2D matrix where entry (i,j) specifies how many individuals are sent by island i to island j.
migration_prob (float, optional) – The per-worker migration probability. Default is 0.0.
emigration_propagator (Type[propulate.propagators.Propagator], optional) – The emigration propagator, i.e., how to choose individuals for emigration that are sent to the destination island. Should be some kind of selection operator. Default is
SelectMin.immigration_propagator (Type[propulate.propagators.Propagator], optional) – The immigration propagator, i.e., how to choose individuals to be replaced by immigrants on a target island. Should be some kind of selection operator. Default is
SelectMax.island_displs (numpy.ndarray, optional) – An array with
propulate_commrank of each island’s worker 0. Element i specifies the rank of worker 0 on island with index i in the Propulate communicator.island_counts (numpy.ndarray, optional) – An array with the number of workers per island. Element i specifies the number of workers on island i.
surrogate_factory (Callable[[], propulate.surrogate.Surrogate], optional) – Function that returns a new instance of a
Surrogatemodel. Only used whenloss_fnis a generator function.
- _send_emigrants() None
Perform migration, i.e. island sends individuals out to other islands.
- _receive_immigrants() None
Check for and possibly receive immigrants send by other islands.
- _deactivate_replaced_individuals() None
Check for and receive individuals from other intra-island workers to be deactivated due to immigration.
- _check_for_duplicates(active: bool, debug: int = 1) Tuple[List[List[propulate.population.Individual | int]], List[propulate.population.Individual]]
Check for duplicates in current population.
For pollination, duplicates are allowed as emigrants are sent as copies and not deactivated on sending island.
- Parameters:
active (bool) – Whether to consider active individuals (True) or all individuals (False).
debug (int, optional) – The debug level; 0 - silent; 1 - moderate, 2 - noisy (debug mode). Default is 1.
- Returns:
List[List[propulate.population.Individual | int]] – The individuals and their occurrences.
List[propulate.population.Individual] – All unique individuals in the population.
- propulate(logging_interval: int = 10, debug: int = 1) None
Execute evolutionary algorithm using island model with pollination in parallel.
- Parameters:
logging_interval (int, optional) – The logging interval. Default is 10.
debug (int, optional) – The debug level; 0 - silent; 1 - moderate, 2 - noisy (debug mode). Default is 1.