Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Fractals: Julia sets, strange attractors, IFS and flames#
Fractals are the classical playground of interactive evolution (Sims, 1991; Ventrella’s and Draves’ electric sheep): small genomes, endless variety, and a quality — beauty — that only a viewer can judge. easyiec has four families: Julia sets of \(z\mapsto z^2+c\) with smooth colouring, Clifford and de Jong attractors, iterated function systems (Barnsley, 1988) and fractal flames with nonlinear variations (Draves and Reckase, 2003).
One random gallery per family#
import matplotlib.pyplot as plt
import numpy as np
import easyiec as ei
from easyiec.problems import FractalFlame, IFSFractal, JuliaSet, StrangeAttractor
from easyiec.strategies import InteractiveGA
rng = np.random.default_rng(4)
families = [JuliaSet(), StrangeAttractor(), IFSFractal(), FractalFlame()]
fig, axes = plt.subplots(4, 6, figsize=(10, 7))
for row, p in zip(axes, families):
for ax in row:
ax.imshow(p.to_image(p.random(rng), 140))
ax.axis("off")
row[0].set_title(p.title, fontsize=8, loc="left")
fig.tight_layout()

Breeding attractors towards a mood#
A simulated viewer whose taste is a set of target image features: bright, colourful and fairly complex.
problem = StrangeAttractor()
user = ei.SimulatedUser(problem, target={"brightness": 0.45, "colorfulness": 0.6, "complexity": 0.7}, noise=0.03,
seed=1)
result = ei.run(problem, InteractiveGA(pop_size=9), user, generations=12, seed=1)
ei.viz.plot_history(result.log, problem, steps=[0, 5, 11], size=1.0)
plt.show()

Total running time of the script: (0 minutes 5.834 seconds)