Joint population optimization with SQUAD¶
SQUAD adjusts a fixed population together. The objective rewards
quality and subtracts a Gaussian overlap penalty for neighboring
solutions. Choose gamma in descriptor units. Set
neighbors=0 to optimize each point independently with Adam.
from qdpy.algorithms import GradientEvaluation, squad_search, soft_qd_score
def evaluate(genome):
(x,) = genome
return GradientEvaluation(1 - (x - .5)**2, (x,), [[1 - 2*x], [1.]])
result = squad_search(evaluate, [[.1], [.4], [.8]], epochs=20,
gamma=.18, quality_floor=0., seed=11)
print(soft_qd_score([g.fitness.values[0] for g in result.population],
[tuple(g.features) for g in result.population],
[[.1], [.5], [.9]], sigma=.1))
The Jacobian contains the raw objective derivative followed by one row
per descriptor. The signed objective must exceed quality_floor at
every evaluated point. For minimization, use maximize=False and put
the floor in negated objective units. Each epoch spends one evaluation
per point, in addition to the initial evaluation. The final population
keeps raw fitness and descriptors.
Use a smaller batch_size and a limited neighbors count for larger
populations. Each minibatch selects neighbors from the current
population and updates only the points in the batch. A reporting Grid
or CVTGrid can bin the final measured population.
The Soft QD helper averages the maximum discounted quality at each
supplied probe, and the search optimizes the pairwise approximation.