propulate.islands

Module Contents

Classes

Islands

Initialize an island model with the given parameters.

Attributes

log

propulate.islands.log
class propulate.islands.Islands(loss_fn: Callable | Generator[float, None, None], propagator: propulate.propagators.Propagator, rng: random.Random, generations: int = 0, num_islands: int = 1, island_sizes: numpy.ndarray | None = None, migration_topology: numpy.ndarray | None = None, migration_probability: float = 0.0, emigration_propagator: Type[propulate.propagators.Propagator] = SelectMin, immigration_propagator: Type[propulate.propagators.Propagator] = SelectMax, pollination: bool = True, checkpoint_path: str | pathlib.Path = Path('./'), ranks_per_worker: int = 1, surrogate_factory: Callable[[], propulate.surrogate.Surrogate] | None = None)

Initialize an island model with the given parameters.

Parameters:
  • loss_fn (Union[Callable, Generator[float, None, None]]) – The loss function to be minimized.

  • propagator (propulate.propagators.Propagator) – The propagator, i.e., evolutionary operator, to apply for breeding.

  • rng (random.Random) – The separate random number generator for the Propulate optimization.

  • generations (int, optional) – The number of generations. Default is 0.

  • num_islands (int, optional) – The number of separate equally sized evolutionary islands. Ignored if island_sizes is not None. Differences of +-1 are possible due to load balancing. Default is 1.

  • island_sizes (numpy.ndarray[int], optional) – An array with numbers of workers for each island (heterogeneous case).

  • migration_topology (numpy.ndarray[int], optional) – A two-dimensional matrix where entry (i,j) specifies how many individuals are sent by island i to island j

  • migration_probability (float, optional) – The probability of migration after each generation.

  • 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 on the target island to be replaced by the immigrants. Should be some kind of selection operator. Default is SelectMax.

  • pollination (bool, optional) – If True, copies of emigrants are sent; otherwise, emigrants are removed from the original island. Default is True.

  • checkpoint_path (pathlib.Path | str, optional) – The path where checkpoints are loaded from and stored to. Default is the current working directory.

  • ranks_per_worker (int, optional) – The number of ranks per worker. Default is 1.

  • surrogate_factory (Callable[[], propulate.surrogate.Surrogate], optional) – Function that returns a new instance of a Surrogate model. Only used when loss_fn is a generator function.

Raises:

ValueError – If the overall number of ranks is not evenly divisible by the requested number of ranks per worker. If the specified number of islands is smaller than 1. If the number of workers in the custom worker distribution does not equal overall number of ranks. If a custom migration topology has the wrong shape. If the migration probability is not within [0, 1].

propulate(logging_interval: int = 10, debug: int = 1) None

Run Propulate optimization.

Parameters:
  • logging_interval (int) – The logging interval.

  • debug (int) – The debug level.

Returns:

The top-n best individuals on each island.

Return type:

List[List[propulate.population.Individual] | propulate.population.Individual]

summarize(top_n: int = 3, debug: int = 1) List[List[propulate.population.Individual] | propulate.population.Individual] | None

Summarize optimization results.

Parameters:
  • top_n (int) – The number of best results to report. Default is 3.

  • debug (int) – The debug level; 0 - silent; 1 - moderate, 2 - noisy (debug mode). Default is 1.

Returns:

The top-n best individuals on each island.

Return type:

List[List[propulate.population.Individual] | propulate.population.Individual]