Interactive Evolutionary Computation in PythonHuman, simulated and AI evaluators. The easyiec toolbox

Chapter 3
Interactive algorithms

This chapter presents the evolutionary strategies of the package as variations of one ask–tell loop: what each strategy shows, which answers it can use, and how it turns them into the next gallery. It starts with the interactive genetic algorithm and the Blind Watchmaker, continues with the EASY-IEC evolution strategy and the continuous optimizers CMA-ES, PSO and differential evolution, and ends with strategies that seek diversity (MAP-Elites, novelty) or trade-offs (reference-point NSGA-II). Model-based strategies follow in chapter 4; their comparison with simulated users in chapter 10.

3.1 One loop, many strategies

Every strategy implements two methods. ask returns a query: a gallery for selection, ranking or rating, a set of duels, or the samples of a slider. tell receives the answer and updates the strategy’s state: a population, a search distribution, a swarm, an archive or a statistical model. A strategy declares the protocols it understands; the select protocol is the default, as in EASY-IEC. Strategies work in the unit cube (section 2.2) and see the problem only through its search space, so the same strategy evolves Julia sets, PID controllers and colour palettes. Two further hooks are shared: steer receives a direction in the unit cube from verbal steering (section 5.5) and biases the next offspring towards it, the bias decaying geometrically; and edits by the evaluator arrive as new individuals that the strategy treats like chosen ones (Lamarckian inheritance).

3.2 The interactive genetic algorithm and the Blind Watchmaker

The interactive genetic algorithm (IGA) is the workhorse of IEC [1]. The evaluator chooses (or ranks, rates, compares) the candidates; parents are drawn with probability proportional to their utility in [0,1] plus a small floor, recombined by BLX-α [28], simulated binary [29], arithmetic or uniform crossover, and mutated by a Gaussian step in the unit cube whose size is annealed from generation to generation. Chosen and explicitly kept candidates, and the best one in any case, survive unchanged, as in Picbreeder [12], so that a good design is never lost because of an unlucky offspring. A fraction of random immigrants can be added to keep the gallery varied.

Dawkins’ Blind Watchmaker [10] shows one parent surrounded by its mutants; the evaluator picks one, which becomes the next parent (Watchmaker). The package adapts the mutation step with a one-fifth-rule analogue: the step shrinks when the parent itself is chosen again — no mutant was better — and grows when a mutant wins. The scheme is intuitive and fast but greedy: the gallery soon consists of near-copies (fig. 3.1). NoveltyIEC counters this: it breeds a pool four times larger than the gallery and shows the candidates that are both close to the parents and far, in feature space, from everything shown so far — the novelty measure of Lehman and Stanley [30], used here as a filter rather than as the objective.

Figure 3.1. Left: mean normalized distance between the shown genomes per query for the Blind Watchmaker, the interactive GA and NoveltyIEC, breeding biomorphs for the same simulated user. Right: best ground-truth utility. The novelty filter keeps the galleries varied without slowing the progress.

Open in ColabExample plot_07_watchmaker_novelty.py in the gallery

3.3 The EASY-IEC evolution strategy

EASY-IEC [2] is an evolution strategy in which the evaluator’s clicks define the selection. Each individual carries a genome 𝐳 and its own vector of step sizes 𝛔 (devi in the MATLAB toolbox), initialized to 1∕(2d) around an initial chromosome. A candidate clicked once becomes a parent; clicked twice it is also copied unchanged into the next gallery. The rest of the gallery consists of offspring: two parents are recombined intermediately (the mean of the genomes, the geometric mean of the step sizes), and the offspring is mutated by log-normal self-adaptation [31],

σi′=σi exp⁡(τ′𝒩(0,1)+τ𝒩i(0,1)),zi′=zi+σi′𝒩i(0,1), τ=1 2d,τ′=1 2d. (3.1)

The step sizes are inherited with the genome, so they are selected together with it: when the evaluator keeps choosing similar candidates, offspring with small steps survive and the search contracts automatically; when the evaluator jumps to a distant candidate, large steps come back. InteractiveES generalizes the scheme to (μ∕ρ,λ) and (μ∕ρ+λ) selection with intermediate or discrete recombination; Breukelaar, Emmerich and Bäck studied this family with simulated users [13].

Algorithm\special {t4ht^+}

bench = run_benchmark( 
    problems={"ellipsoid-6": lambda: SyntheticPreference(dim=6, kind="ellipsoid", seed=2)}, 
    strategies={"EASY-IEC": lambda: EasyIEC(pop_size=9), "(μ+λ)-ES": lambda: InteractiveES(pop_size=9), 
                "GA": lambda: InteractiveGA(pop_size=9)}, 
    users={"user": lambda p, s: ei.SimulatedUser(p, target="random", noise=0.05, seed=s)}, 
    seeds=range(10), generations=20) 
print(bench.summary.groupby("strategy")["best_true"].agg(["mean", "std"]).round(3))
   

Figure 3.2

Figure 3.2. Mean best ground-truth utility (bands: bootstrap 95 % intervals over ten seeds) of EASY-IEC, a (μ+λ)-ES and the interactive GA on a six-dimensional ellipsoid landscape with a simulated user.

Open in ColabExample plot_01_easyiec_es.py in the gallery

3.4 CMA-ES, particle swarms and pairwise differential evolution

CMA-ES. The covariance matrix adaptation evolution strategy [32] samples a gallery from 𝒩(𝐦,σ2𝐂) and updates the mean, the step size and the covariance from the ranks of the candidates only. This makes it a natural interactive optimizer: a ranking, or even a selection, is all it needs. InteractiveCMAES implements the standard update equations of the tutorial with weighted recombination of the better half, cumulative step-size adaptation and rank-one and rank-μ covariance updates; the order of the candidates comes from Feedback.order, so it runs with every protocol. After a few generations the covariance has learned the correlations between genes that the evaluator’s choices reveal (fig. 3.3).

Interactive PSO. Madár, Abonyi and Szeifert [3] replaced the fitness of particle swarm optimization [33] by the evaluator: the particle chosen in a generation becomes the global best, chosen particles update their personal bests, and the velocities follow the constriction form

𝐯k←w𝐯k+c1𝐫1⊙(𝐩k−𝐳k)+c2𝐫2⊙(𝐠−𝐳k),𝐳k←𝐳k+ 𝐯k,(3.2)

with w=0.7298 and c1=c2=1.49618 [34], velocity clipping and reflection at the cube’s faces.

Pairwise differential evolution. Differential evolution [35] builds a trial vector for every member of the population from the scaled difference of two others (F=0.6, binomial crossover with CR=0.9) and keeps whichever of trial and target is better. The selection step is a single question — is the trial better than its parent? — so InteractiveDE asks it as a duel. A query contains several duels side by side, which suits AI judges and the escalation of section 5.6, where a duel is the natural unit of disagreement.

Figure 3.3

Figure 3.3. The state of two strategies after 20 generations on a five-dimensional ellipsoid: the principal axis lengths σλi of the CMA-ES search distribution (left) and the swarm of the interactive PSO in the first two genes, with velocities and the global best (right).

Open in ColabExample plot_02_cmaes_pso_de.py in the gallery

3.5 Diversity: interactive MAP-Elites

Designers often want a repertoire of good, different solutions rather than one winner. MAP-Elites [36] divides a two-dimensional behaviour space into cells and keeps the best individual found in each. InteractiveMAPElites uses two phenotype features as behaviour descriptors (for images, by default, the entropy and the colourfulness) and asks the evaluator only where a decision is needed: a newcomer that falls into an empty cell is stored without a question; a newcomer that falls into an occupied cell is shown in a duel with the incumbent elite, and the winner keeps the cell. A gallery of elites is shown now and then for parent selection. The effort thus concentrates on contested niches, and the archive offers a map of the possible rather than a single answer (fig. 3.4).

Figure 3.4

Figure 3.4. The elites of an interactive MAP-Elites archive of Julia sets after 25 queries, labelled by their cell (entropy bin, colourfulness bin). Each elite is the best image the simulated user has seen in its niche.

Open in ColabExample plot_04_map_elites.py in the gallery

3.6 Trade-offs: reference-point NSGA-II

Engineering problems often have several computable objectives — integral error, overshoot, control effort, settling time — whose trade-off only the engineer can settle. InteractiveNSGA2 combines Pareto-based evolution with interaction. Between two queries, a silent population of 40 individuals evolves for five generations under non-dominated sorting and crowding [37]; then a gallery of representatives of the first front is shown, and the chosen candidates act as reference points: their normalized objective vectors bias the crowding distance of the next silent phase towards the chosen region of the front [38]. The evaluator never sees a Pareto front, only step responses, yet the population concentrates on the part of the front that matches the evaluator’s taste (fig. 3.5).

strategy = InteractiveNSGA2(pop_size=8, inner_size=40, inner_generations=5) 
user = ei.SimulatedUser(problem, target="default", noise=0.05, seed=1) 
result = ei.run(problem, strategy, user, generations=10, seed=1) 
print(problem.describe(result.best.genome))
   

Figure 3.5

Figure 3.5. The silent population of reference-point NSGA-II after ten interactions in the plane of integral absolute error and control effort (total variation of the controller output). Blue: its non-dominated front; circles: the candidates the simulated engineer chose last.

Open in ColabExample plot_05_nsga2_reference.py in the gallery

In a nutshell: Interactive algorithms

  • All strategies share the ask–tell loop, the unit cube, steering and Lamarckian edits; each declares the protocols it understands.
  • The interactive GA and the Watchmaker are simple and greedy; NoveltyIEC keeps galleries varied.
  • EASY-IEC is a self-adaptive evolution strategy: step sizes are selected with the genomes, so the search contracts and expands with the evaluator’s choices.
  • CMA-ES needs only ranks; the interactive PSO turns choices into personal and global bests; DE asks one duel per trial vector.
  • Interactive MAP-Elites asks only about contested niches; reference-point NSGA-II lets choices steer a silent Pareto search.