20 """Use a feasibility-weighted Expected Improvement of the Deep Archive.
22 The exact archive holds the best feasible design for each configuration
23 in every occupied cell. The supplied grid shows the best across
24 configurations. Each surrogate prediction competes with the
25 incumbent from its own configuration when present. A candidate for a
26 missing configuration receives a more permissive reference based on
27 estimated unfilled cells in the previous batch's cheap pool.
29 Predictions are assigned by posterior-mean descriptor. At most one
30 planned proposal per configuration and cell enters a batch. The
31 default allocates the shared budget competitively. Equal allocation
32 guarantees that configuration attempt counts differ by at most one,
33 including warm-up and an incomplete final batch. Both modes use the
34 same per-layer acquisition; callbacks follow ConditionalBayesianQD.
36 :param container: Empty parentless Grid or CVTGrid with capacity for every cell.
37 :param budget: Budget in exact evaluation attempts.
38 :param variables: Mapping of conditional variable specifications.
39 :param configurations: Ordered ConditionalConfiguration sequence.
40 :param allocation: ``competitive`` (default) or ``equal`` attempt allocation.
41 :param kwargs: ConditionalBayesianQD proposal and surrogate settings.
44 def __init__(self, container, budget, variables, *, configurations, allocation="competitive", **kwargs):
45 if container.parents
or container.capacity < len(container.solutions):
46 raise ValueError(
"Bayesian Deep QD requires a parentless archive with capacity for each cell.")
47 if allocation
not in (
"competitive",
"equal"):
48 raise ValueError(
"Choose competitive or equal allocation.")
50 super().__init__(container, budget, variables, configurations=configurations, **kwargs)
53 def __deepcopy__(self, memo):
56 return super().__deepcopy__(memo)
59 """Reset acquisition models and counters, retaining the live archive."""
63 self.
_beta = (1.,) * count
67 """Return the latest deep-archive coverage multipliers in configuration order."""
70 def _prepare_deep_context(self):
74 self.
_beta = tuple(1. + max(estimate - observed, 0) / total
for estimate, observed
in zip(predicted, filled))
76 qualities = [row[0]
for observations
in self.
_observations for _, row
in observations]
77 low, high = min(qualities), max(qualities)
80 raise ValueError(
"The EIDA acquisition needs a finite observed fitness span.")
84 def _plan_batch(self, size):
86 return super()._plan_batch(size)
89 if getattr(self,
"allocation",
"competitive") ==
"competitive":
96 else None for offset
in range(size)]
97 if all(branch
is None for branch
in plan):
102 for branch
in dict.fromkeys(plan):
108 rows = sorted(self.
_rank_pool(branch, pool, floor), key=
lambda row: row[:3], reverse=
True)
110 for _, _, _, cell, vector
in rows:
111 cells.setdefault(cell, vector)
112 branch_picks[branch] = iter(cells.values())
114 choices = branch_picks.get(branch)
115 self.
_promoted.append(next(choices,
None)
if choices
is not None else None)
117 def _next_vector(self):
118 if getattr(self,
"allocation",
"competitive") ==
"competitive":
119 return super()._next_vector()
124 self._modelled_proposals += 1
127 def _rank_pool(self, branch, vectors, floor):
128 ranked = super()._rank_pool(branch, vectors, floor)
130 self.
_predicted[branch] = len({row[3]
for row
in ranked
if row[1] >= .5})
133 def _acquisition_reference(self, branch, cell, floor):
139 reference = super()._acquisition_reference(branch, cell, floor)
142 bonus = self.
_beta[branch] - 1.
146 return max(floor, reference - bonus * gap - bonus * self.
_quality_span)
148 def _acquisition_key(self, cell, vector):
149 return cell, vector[0]
151 def _offer_feasible(self, individual, cell):