22 """Use bounded Gaussian mutation and a VoronoiArchive.
24 Draw an initial population uniformly, then mutate parents sampled
25 uniformly from the retained archive. Feedback within a batch is
26 applied one candidate at a time in proposal order.
28 :param container: The VoronoiArchive that will hold evaluated elites.
29 :param budget: Attempted evaluations.
30 :param dimension: Number of real genome coordinates.
31 :param ind_domain: Shared inclusive genome bounds.
32 :param sigma: Gaussian standard deviation as a fraction of the genome range.
33 :param initial_samples: Uniform proposals for an empty archive.
34 Defaults to archive capacity.
35 :param batch_size: Number of proposals evaluated before feedback.
36 :param seed: Seed for private proposal randomness.
37 :param extinction_period: Optional interval in completed batches between extinctions.
38 :param extinction_size: Live population cap in extinction batches.
39 :param kwargs: Standard QDpy optimiser options.
42 def __init__(self, container, budget, dimension, *, ind_domain=(0., 1.), sigma=.08,
43 initial_samples=
None, batch_size=1, seed=0, extinction_period=
None, extinction_size=
None,
45 if not isinstance(container, VoronoiArchive):
46 raise TypeError(
"Supply a VoronoiArchive.")
49 if not 0. < self.
_scale < np.inf:
50 raise ValueError(
"Use finite genome bounds and a positive finite mutation scale.")
52 if (extinction_period
is None) != (extinction_size
is None):
53 raise ValueError(
"Supply both extinction_period and extinction_size.")
55 if extinction_period
is not None:
57 self.
extinction_size = _positive_int(extinction_size,
"extinction_size")
59 raise ValueError(
"extinction_size must be below the normal archive capacity.")
60 initial = container.capacity
if initial_samples
is None else _positive_int(initial_samples,
"initial_samples")
62 dimension = _positive_int(dimension,
"dimension")
63 for candidate
in container:
64 values = np.asarray(candidate, dtype=float)
65 if (values.shape != (dimension,)
or not np.isfinite(values).all()
67 raise ValueError(
"Warm-start genomes must match the search dimension and bounds.")
68 kwargs.setdefault(
"optimisation_task", container.fitness_weights)
69 super().__init__(container, _positive_int(budget,
"budget"), dimension=dimension,
70 batch_size=_positive_int(batch_size,
"batch_size"), **kwargs)
73 """Reset search accounting and the private random stream."""
75 self.
_rng = np.random.default_rng(self.
seed)
80 """Return the number of completed extinction batches."""
81 return getattr(self,
"_extinctions", 0)
85 """Return removals made to enforce the reduced population cap."""
86 return getattr(self,
"_pruned", 0)
94 base_ind[:] = point.tolist()
99 period = getattr(self,
"extinction_period",
None)
100 extinction = period
is not None and (self.
current_iter + 1) % period == 0
101 for slot, ind
in enumerate(evaluated):